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.config.phase.custom;
@XStreamAlias("customSolverPhase")
public class CustomSolverPhaseConfig extends SolverPhaseConfig {
    // Warning: all fields are null (and not defaulted) because they can be inherited
    // and also because the input config file should match the output config file
    @XStreamImplicit(itemFieldName = "customSolverPhaseCommandClass")
        return ;
    }
    public void setCustomSolverPhaseCommandClassList(List<Class<CustomSolverPhaseCommand>> customSolverPhaseCommandClassList) {
        this. = customSolverPhaseCommandClassList;
    }
    // ************************************************************************
    // Builder methods
    // ************************************************************************
    public CustomSolverPhase buildSolverPhase(EnvironmentMode environmentMode,
            SolutionDescriptor solutionDescriptorScoreDefinition scoreDefinitionTermination solverTermination) {
        DefaultCustomSolverPhase customSolverPhase = new DefaultCustomSolverPhase();
        configureSolverPhase(customSolverPhaseenvironmentModescoreDefinitionsolverTermination);
            throw new IllegalArgumentException(
                    "Configure at least 1 <customSolverPhaseCommandClass> in the <customSolverPhase> configuration.");
        }
        List<CustomSolverPhaseCommandcustomSolverPhaseCommandList
                = new ArrayList<CustomSolverPhaseCommand>(.size());
        for (Class<CustomSolverPhaseCommandcustomSolverPhaseCommandClass : ) {
            try {
                customSolverPhaseCommandList.add(customSolverPhaseCommandClass.newInstance());
            } catch (InstantiationException e) {
                throw new IllegalArgumentException("customSolverPhaseCommandClass ("
                        + customSolverPhaseCommandClass.getName() + ") does not have a public no-arg constructor"e);
            } catch (IllegalAccessException e) {
                throw new IllegalArgumentException("customSolverPhaseCommandClass ("
                        + customSolverPhaseCommandClass.getName() + ") does not have a public no-arg constructor"e);
            }
        }
        customSolverPhase.setCustomSolverPhaseCommandList(customSolverPhaseCommandList);
        return customSolverPhase;
    }
    public void inherit(CustomSolverPhaseConfig inheritedConfig) {
        super.inherit(inheritedConfig);
        if ( == null) {
             = inheritedConfig.getCustomSolverPhaseCommandClassList();
        } else if (inheritedConfig.getCustomSolverPhaseCommandClassList() != null) {
            // The inherited customSolverPhaseCommandClassList should be before the non-inherited one
            List<Class<CustomSolverPhaseCommand>> mergedList = new ArrayList<Class<CustomSolverPhaseCommand>>(
                    inheritedConfig.getCustomSolverPhaseCommandClassList());
            mergedList.addAll();
             = mergedList;
        }
    }
New to GrepCode? Check out our FAQ X