4 Replies Latest reply on Apr 8, 2008 11:45 AM by alesj

    ControllerStates helper/util

    alesj

      I'm thinking of introducing something like this

      public class ControllerStates
      {
       public static ControllerState previousState(List<ControllerState> states, ControllerState state);
      
       public static int currentStateIndex(List<ControllerState> states, ControllerState state);
      
       public static ControllerState nextState(List<ControllerState> states, ControllerState state);
      
       ...
      }
      

      to handle this previous/next state lookup in a singe place.
      Currently there is a bunch of code that does this, mostly w/o any constraints check, e.g. no such state in states.

      I'll push it in org.jboss.dependency.spi.helpers package.
      Or should/could this be on the ControllerState already?

        • 1. Re: ControllerStates helper/util

          No. If you're going to make it part of the spi, then make it usuable and future proof.

          e.g.

          public interface Controller
          {
           ControllerState getPreviousState(ControllerState state);
           ControllerState getNextState(ControllerState state);
           boolean isAfterState(ControllerState state, ControllerState reference);
          }
          


          The array/index is just an implementation detail. Don't expose implementation details!

          • 2. Re: ControllerStates helper/util
            alesj

             

            "adrian@jboss.org" wrote:

            public interface Controller
            {
             boolean isAfterState(ControllerState state, ControllerState reference);
            }
            


            Which one here is the marker (against whom we check)?

            • 3. Re: ControllerStates helper/util
              alesj

               

              "alesj" wrote:
              "adrian@jboss.org" wrote:

              public interface Controller
              {
               boolean isAfterState(ControllerState state, ControllerState reference);
              }
              


              Which one here is the marker (against whom we check)?

              reference == marker
              state == the one we're checking

              • 4. Re: ControllerStates helper/util
                alesj

                I also need ListIterator, to start iterating from the end.