Skip to content

Commit

Permalink
Fixed checkstyle warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
oskopek committed Aug 25, 2015
1 parent 417f726 commit 35201cf
Show file tree
Hide file tree
Showing 87 changed files with 149 additions and 142 deletions.
Expand Up @@ -386,7 +386,7 @@ public RenameNodeDialog(final DefaultMutableTreeNode treeNode) {
final Object benchmarkResult = mixedCheckBox.getBenchmarkResult();

JPanel mainPanel = new JPanel(new BorderLayout());
String benchmarkResultTextFieldText = null;
String benchmarkResultTextFieldText = null;
if (benchmarkResult instanceof SolverBenchmarkResult) {
benchmarkResultTextFieldText = solverBenchmarkResultNameMapping.get(benchmarkResult);
}
Expand Down
Expand Up @@ -96,7 +96,7 @@ private void resolveNewCheckBoxState(DefaultMutableTreeNode currentNode, MixedCh
checkBox.setStatus(newStatus);
selectChildren(currentNode, newStatus);
TreeNode[] ancestorNodes = currentNode.getPath();
// examine ancestors, don't lose track of most recent changes - bottom-up approach
// examine ancestors, don't lose track of most recent changes - bottom-up approach
for (int i = ancestorNodes.length - 2; i >= 0; i--) {
DefaultMutableTreeNode ancestorNode = (DefaultMutableTreeNode) ancestorNodes[i];
MixedCheckBox ancestorCheckbox = (MixedCheckBox) ancestorNode.getUserObject();
Expand Down
Expand Up @@ -81,7 +81,7 @@ public void mouseClicked(MouseEvent e) {
private static class MixedCheckBoxModel extends ToggleButtonModel {

private MixedCheckBoxStatus getStatus() {
return isSelected() ? (isArmed() ? MixedCheckBoxStatus.MIXED : MixedCheckBoxStatus.CHECKED) : MixedCheckBoxStatus.UNCHECKED;
return isSelected() ? (isArmed() ? MixedCheckBoxStatus.MIXED : MixedCheckBoxStatus.CHECKED) : MixedCheckBoxStatus.UNCHECKED;
}

private void setStatus(MixedCheckBoxStatus status) {
Expand All @@ -98,7 +98,7 @@ private void setStatus(MixedCheckBoxStatus status) {
setArmed(true);
setPressed(true);
} else {
throw new IllegalArgumentException("Invalid argument ("
throw new IllegalArgumentException("Invalid argument ("
+ status + ") supplied.");
}
}
Expand Down
Expand Up @@ -21,7 +21,7 @@
import org.optaplanner.benchmark.impl.result.SolverBenchmarkResult;

/**
* Defines an interface for classes that will be used to rank solver benchmarks
* Defines an interface for classes that will be used to rank solver benchmarks
* in order of their respective performance.
*/
public interface SolverRankingWeightFactory {
Expand Down
Expand Up @@ -39,7 +39,7 @@
import org.slf4j.LoggerFactory;

/**
* 1 statistic of {@link ProblemBenchmarkResult}
* 1 statistic of {@link ProblemBenchmarkResult}.
*/
@XStreamInclude({
BestScoreProblemStatistic.class,
Expand Down
Expand Up @@ -30,7 +30,7 @@
import org.optaplanner.benchmark.impl.statistic.single.pickedmovetypestepscore.PickedMoveTypeStepScoreDiffSingleStatistic;

/**
* 1 statistic of {@link SingleBenchmarkResult}
* 1 statistic of {@link SingleBenchmarkResult}.
*/
@XStreamInclude({
ConstraintMatchTotalBestScoreSingleStatistic.class,
Expand Down
Expand Up @@ -42,7 +42,7 @@
import org.slf4j.LoggerFactory;

/**
* 1 statistic of {@link SingleBenchmarkResult}
* 1 statistic of {@link SingleBenchmarkResult}.
*/
@XStreamInclude({
PureSingleStatistic.class
Expand Down
Expand Up @@ -20,7 +20,7 @@
import java.util.List;

/**
* Implementations must be immutable
* Implementations must be immutable.
*/
public abstract class StatisticPoint {

Expand Down
Expand Up @@ -58,7 +58,7 @@ public void open(Solver solver) {
public void close(Solver solver) {
((DefaultSolver) solver).removePhaseLifecycleListener(listener);
}

private class MemoryUseSingleStatisticListener extends PhaseLifecycleListenerAdapter {

private long nextTimeMillisThreshold = timeMillisThresholdInterval;
Expand Down
Expand Up @@ -76,7 +76,7 @@ public void writeGraphFiles(BenchmarkReport benchmarkReport) {
XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
DrawingSupplier drawingSupplier = new DefaultDrawingSupplier();
plot.setOrientation(PlotOrientation.VERTICAL);

int seriesIndex = 0;
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
XYSeries acceptedSeries = new XYSeries(
Expand Down
Expand Up @@ -48,16 +48,16 @@ public void open(Solver solver) {
public void close(Solver solver) {
((DefaultSolver) solver).removePhaseLifecycleListener(listener);
}

private class MoveCountPerStepSingleStatisticListener extends PhaseLifecycleListenerAdapter {

@Override
public void stepEnded(AbstractStepScope stepScope) {
if (stepScope instanceof LocalSearchStepScope) {
localSearchStepEnded((LocalSearchStepScope) stepScope);
}
}
}

private void localSearchStepEnded(LocalSearchStepScope stepScope) {
long timeMillisSpent = stepScope.getPhaseScope().calculateSolverTimeMillisSpent();
pointList.add(new MoveCountPerStepStatisticPoint(timeMillisSpent,
Expand Down
Expand Up @@ -42,5 +42,5 @@ public String toCsvLine() {
return buildCsvLineWithLongs(timeMillisSpent, moveCountPerStepMeasurement.getAcceptedMoveCount(),
moveCountPerStepMeasurement.getSelectedMoveCount());
}

}
Expand Up @@ -106,7 +106,7 @@ public void stepEnded(AbstractStepScope stepScope) {
}

private void localSearchStepEnded(LocalSearchStepScope stepScope) {
if (constraintMatchEnabled ) {
if (constraintMatchEnabled) {
long timeMillisSpent = stepScope.getPhaseScope().calculateSolverTimeMillisSpent();
for (ConstraintMatchTotal constraintMatchTotal
: stepScope.getScoreDirector().getConstraintMatchTotals()) {
Expand Down
Expand Up @@ -36,7 +36,7 @@
public @interface CustomShadowVariable {

/**
* Use this when this shadow variable is updated by the {@link VariableListener} of another {@link @CustomShadowVariable}.
* Use this when this shadow variable is updated by the {@link VariableListener} of another {@link CustomShadowVariable}.
* @return null if (and only if) any of the other fields is non null.
*/
PlanningVariableReference variableListenerRef() default @PlanningVariableReference(variableName = "");
Expand Down
Expand Up @@ -177,11 +177,11 @@ public BendableBigDecimalScore power(double exponent) {
// TODO FIXME remove .intValue() so non-integer exponents produce correct results
// None of the normal Java libraries support BigDecimal.pow(BigDecimal)
for (int i = 0; i < newHardScores.length; i++) {
BigDecimal hardScore = hardScores[i];
BigDecimal hardScore = hardScores[i];
newHardScores[i] = hardScore.pow(actualExponent.intValue()).setScale(hardScore.scale());
}
for (int i = 0; i < newSoftScores.length; i++) {
BigDecimal softScore = softScores[i];
BigDecimal softScore = softScores[i];
newSoftScores[i] = softScore.pow(actualExponent.intValue()).setScale(softScore.scale());
}
return new BendableBigDecimalScore(newHardScores, newSoftScores);
Expand Down
Expand Up @@ -61,9 +61,9 @@ public long getTimeMillisSpent() {
* Note that:
* <ul>
* <li>In real-time planning, not all {@link ProblemFactChange}s might be processed:
* check {@link #isEveryProblemFactChangeProcessed()}</li>
* <li>this {@link Solution} might be uninitialized: check {@link #isNewBestSolutionInitialized()}</li>
* <li>this {@link Solution} might be infeasible: check {@link FeasibilityScore#isFeasible()}</li>
* check {@link #isEveryProblemFactChangeProcessed()}.</li>
* <li>this {@link Solution} might be uninitialized: check {@link #isNewBestSolutionInitialized()}.</li>
* <li>this {@link Solution} might be infeasible: check {@link FeasibilityScore#isFeasible()}.</li>
* </ul>
* @return never null
*/
Expand Down
Expand Up @@ -23,11 +23,11 @@
*/
public enum SelectionSorterOrder {
/**
* For example: 0, 1, 2, 3
* For example: 0, 1, 2, 3.
*/
ASCENDING,
/**
* For example: 3, 2, 1, 0
* For example: 3, 2, 1, 0.
*/
DESCENDING;

Expand Down
Expand Up @@ -545,8 +545,8 @@ public void inherit(EntitySelectorConfig inheritedConfig) {
}
cacheType = ConfigUtils.inheritOverwritableProperty(cacheType, inheritedConfig.getCacheType());
selectionOrder = ConfigUtils.inheritOverwritableProperty(selectionOrder, inheritedConfig.getSelectionOrder());
filterClassList = ConfigUtils.inheritOverwritableProperty
(filterClassList, inheritedConfig.getFilterClassList());
filterClassList = ConfigUtils.inheritOverwritableProperty(
filterClassList, inheritedConfig.getFilterClassList());
sorterManner = ConfigUtils.inheritOverwritableProperty(
sorterManner, inheritedConfig.getSorterManner());
sorterComparatorClass = ConfigUtils.inheritOverwritableProperty(
Expand Down
Expand Up @@ -181,7 +181,7 @@ public List<TerminationConfig> getTerminationConfigList() {
public void setTerminationConfigList(List<TerminationConfig> terminationConfigList) {
this.terminationConfigList = terminationConfigList;
}

// ************************************************************************
// Builder methods
// ************************************************************************
Expand Down
Expand Up @@ -114,15 +114,19 @@ public static Method getGetterMethod(Class containingClass, String propertyName)
+ (propertyName.isEmpty() ? "" : propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1));
try {
return containingClass.getMethod(getterName);
} catch (NoSuchMethodException e) {}
} catch (NoSuchMethodException e) {
// intentionally empty
}
String isserName = PROPERTY_ACCESSOR_PREFIX_IS
+ (propertyName.isEmpty() ? "" : propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1));
try {
Method method = containingClass.getMethod(isserName);
if (method.getReturnType() == boolean.class) {
return method;
}
} catch (NoSuchMethodException e) {}
} catch (NoSuchMethodException e) {
// intentionally empty
}
return null;
}

Expand Down
Expand Up @@ -322,7 +322,7 @@ public SolutionDescriptor getSolutionDescriptor() {
public Class<?> getEntityClass() {
return entityClass;
}

public boolean matchesEntity(Object entity) {
return entityClass.isAssignableFrom(entity.getClass());
}
Expand Down Expand Up @@ -363,7 +363,7 @@ public List<GenuineVariableDescriptor> getGenuineVariableDescriptorList() {
public boolean hasGenuineVariableDescriptor(String variableName) {
return effectiveGenuineVariableDescriptorMap.containsKey(variableName);
}

public GenuineVariableDescriptor getGenuineVariableDescriptor(String variableName) {
return effectiveGenuineVariableDescriptorMap.get(variableName);
}
Expand Down
Expand Up @@ -192,7 +192,7 @@ protected boolean isClassDeepCloned(Class<?> type) {

protected class FieldAccessingSolutionClonerRun {

protected Map<Object,Object> originalToCloneMap;
protected Map<Object, Object> originalToCloneMap;
protected Queue<Unprocessed> unprocessedQueue;

protected SolutionG cloneSolution(SolutionG originalSolution) {
Expand Down Expand Up @@ -276,7 +276,7 @@ protected void process(Unprocessed unprocessed) {
if (unprocessed.originalValue instanceof Collection) {
cloneValue = cloneCollection(unprocessed.field.getType(), (Collection<?>) unprocessed.originalValue);
} else if (unprocessed.originalValue instanceof Map) {
cloneValue = cloneMap(unprocessed.field.getType(), (Map<?,?>) unprocessed.originalValue);
cloneValue = cloneMap(unprocessed.field.getType(), (Map<?, ?>) unprocessed.originalValue);
} else {
cloneValue = clone(unprocessed.originalValue);
}
Expand Down Expand Up @@ -307,7 +307,7 @@ protected <E> Collection<E> constructCloneCollection(Collection<E> originalColle
} else { // Default List
return new ArrayList<E>(originalCollection.size());
}
} if (originalCollection instanceof Set) {
} else if (originalCollection instanceof Set) {
if (originalCollection instanceof SortedSet) {
Comparator<E> setComparator = ((SortedSet) originalCollection).comparator();
return new TreeSet<E>(setComparator);
Expand All @@ -324,34 +324,34 @@ protected <E> Collection<E> constructCloneCollection(Collection<E> originalColle
}
}

protected <K,V> Map<K,V> cloneMap(Class<?> expectedType, Map<K,V> originalMap) {
Map<K,V> cloneMap = constructCloneMap(originalMap);
protected <K, V> Map<K, V> cloneMap(Class<?> expectedType, Map<K, V> originalMap) {
Map<K, V> cloneMap = constructCloneMap(originalMap);
if (!expectedType.isInstance(cloneMap)) {
throw new IllegalStateException("The cloneMapClass (" + cloneMap.getClass()
+ ") created for originalMapClass (" + originalMap.getClass()
+ ") is not assignable to the field's type (" + expectedType + ")."
+ " Consider replacing the default " + SolutionCloner.class.getSimpleName() + ".");
}
for (Map.Entry<K,V> originalEntry : originalMap.entrySet()) {
for (Map.Entry<K, V> originalEntry : originalMap.entrySet()) {
K cloneKey = cloneCollectionsElementIfNeeded(originalEntry.getKey());
V cloneValue = cloneCollectionsElementIfNeeded(originalEntry.getValue());
cloneMap.put(cloneKey, cloneValue);
}
return cloneMap;
}

protected <K,V> Map<K,V> constructCloneMap(Map<K,V> originalMap) {
protected <K, V> Map<K, V> constructCloneMap(Map<K, V> originalMap) {
// Normally a Map will never be selected for cloning, but extending implementations might anyway
if (originalMap instanceof SortedMap) {
Comparator setComparator = ((SortedMap) originalMap).comparator();
return new TreeMap<K,V>(setComparator);
return new TreeMap<K, V>(setComparator);
} else if (originalMap instanceof LinkedHashMap) {
return new LinkedHashMap<K,V>(originalMap.size());
return new LinkedHashMap<K, V>(originalMap.size());
} else if (originalMap instanceof HashMap) {
return new HashMap<K,V>(originalMap.size());
return new HashMap<K, V>(originalMap.size());
} else { // Default Map
// Default to a LinkedHashMap to respect order
return new LinkedHashMap<K,V>(originalMap.size());
return new LinkedHashMap<K, V>(originalMap.size());
}
}

Expand Down
Expand Up @@ -108,7 +108,7 @@ private static List<Class<?>> sortEntityClassList(List<Class<?>> entityClassList

private final Class<? extends Solution> solutionClass;
private SolutionCloner solutionCloner;

private final Map<String, MemberAccessor> entityPropertyAccessorMap;
private final Map<String, MemberAccessor> entityCollectionPropertyAccessorMap;

Expand Down
Expand Up @@ -43,7 +43,7 @@ public int countMutations(Solution a, Solution b) {
for (EntityDescriptor entityDescriptor : solutionDescriptor.getGenuineEntityDescriptors()) {
List<Object> aEntities = entityDescriptor.extractEntities(a);
List<Object> bEntities = entityDescriptor.extractEntities(b);
for (Iterator aIt = aEntities.iterator(), bIt = bEntities.iterator() ; aIt.hasNext() && bIt.hasNext(); ) {
for (Iterator aIt = aEntities.iterator(), bIt = bEntities.iterator(); aIt.hasNext() && bIt.hasNext(); ) {
Object aEntity = aIt.next();
Object bEntity = bIt.next();
for (GenuineVariableDescriptor variableDescriptor : entityDescriptor.getGenuineVariableDescriptors()) {
Expand Down
Expand Up @@ -66,7 +66,7 @@ public void registerShadowVariableDescriptor(ShadowVariableDescriptor shadowVari
}

/**
* Primary shadow variables are direct as well as non-referencing
* Primary shadow variables are direct as well as non-referencing.
* @return never null, only direct, non-referencing shadow variables
*/
public List<ShadowVariableDescriptor> getPrimaryShadowVariableDescriptorList() {
Expand Down
Expand Up @@ -59,7 +59,7 @@ public long assignBreadth() {

@Override
public String toString() {
return depth + (isLastLayer() ? " last layer": " (" + entity + ")");
return depth + (isLastLayer() ? " last layer" : " (" + entity + ")");
}

}
Expand Up @@ -19,7 +19,7 @@
import org.optaplanner.core.impl.score.director.ScoreDirector;

/**
* Abstract superclass for {@link Move}
* Abstract superclass for {@link Move}.
* @see Move
*/
public abstract class AbstractMove implements Move {
Expand Down
Expand Up @@ -20,21 +20,19 @@
import java.util.ListIterator;

/**
* An extension on the {@link Iterable} interface that supports {@link #listIterator()} and {@link #listIterator(int)}.
* An extension on the {@link Iterable} interface that supports {@link #listIterator()} and {@link #listIterator(int)}.
* @param <T> the element type
*/
public interface ListIterable<T> extends Iterable<T> {

/**
* See {@link List#listIterator()}
*
* @see List#listIterator()
* @return never null, see {@link List#listIterator()}.
*/
ListIterator<T> listIterator();

/**
* See {@link List#listIterator()}
*
* @see List#listIterator()
* @param index lower than the size of this {@link ListIterable}, see {@link List#listIterator(int)}.
* @return never null, see {@link List#listIterator(int)}.
*/
Expand Down
Expand Up @@ -19,9 +19,11 @@
import java.util.Random;

/**
* P(x) = 2/m - 2x/m²
* Cumulative probability F(x) = x(2m - x)/m²
* Inverse cumulative probability F(p) = m(1 - (1 - p)^(1/2))
* {@code P(x) = 2/m - 2x/m²}.
* <p>
* Cumulative probability: {@code F(x) = x(2m - x)/m²}.
* <p>
* Inverse cumulative probability: {@code F(p) = m(1 - (1 - p)^(1/2))}.
*/
public class LinearDistributionNearbyRandom implements NearbyRandom {

Expand Down

0 comments on commit 35201cf

Please sign in to comment.