Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.planner.core.heuristic.selector.variable;
 
 
 
 public class PlanningValueWalker implements SolverPhaseLifecycleListener {
 
 
     private WorkingMemory workingMemory;
 
     private Object planningEntity;
     private Iterator<?> planningValueIterator;
 
     private boolean isFirstValue// TODO remove and require partially initialized entity's support in score rules
     private Object workingValue;
 
     public PlanningValueWalker(PlanningVariableDescriptor planningVariableDescriptor,
             PlanningValueSelector planningValueSelector) {
         this. = planningVariableDescriptor;
         this. = planningValueSelector;
     }
 
         return ;
     }
 
     public Object getWorkingValue() {
         return ;
     }
 
     // ************************************************************************
     // Lifecycle methods
     // ************************************************************************
 
     public void phaseStarted(AbstractSolverPhaseScope solverPhaseScope) {
         .phaseStarted(solverPhaseScope);
          = solverPhaseScope.getWorkingMemory();
     }
 
     public void beforeDeciding(AbstractStepScope stepScope) {
         .beforeDeciding(stepScope);
     }
 
     public void stepDecided(AbstractStepScope stepScope) {
         .stepDecided(stepScope);
     }
 
     public void stepTaken(AbstractStepScope stepScope) {
         .stepTaken(stepScope);
     }
 
     public void phaseEnded(AbstractSolverPhaseScope solverPhaseScope) {
         .phaseEnded(solverPhaseScope);
          = null;
          = null;
     }
 
     // ************************************************************************
     // Worker methods
     // ************************************************************************
 
     public void initWalk(Object planningEntity) {
         this. = planningEntity;
          = .iterator(planningEntity);
         Object value = .next();
         .setValue(planningEntityvalue);
          = true;
          = value;
     }
 
     public void initPlanningEntityFactHandle(FactHandle planningEntityFactHandle) {
         this. = planningEntityFactHandle;
     }
 
    public boolean hasWalk() {
        if () {
            return true;
        }
        return .hasNext();
    }
    public void walk() {
        if () {
             = false;
        } else {
            Object value = .next();
            changeWorkingValue(value);
        }
    }
    public void resetWalk() {
        Object value = .next();
        changeWorkingValue(value);
         = value;
    }
    private void changeWorkingValue(Object value) {
         = value;
    }
New to GrepCode? Check out our FAQ X