Skip to content

Commit

Permalink
Rename Penalty to IPenalty.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Apr 17, 2018
1 parent 7269a02 commit 37c12a7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Expand Up @@ -22,7 +22,7 @@
* @param <RI>
* The input type accepted by this penalty.
*/
public abstract class AbstractPenalty<RI> implements Penalty<RI> {
public abstract class AbstractPenalty<RI> implements IPenalty<RI> {

/** The input type accepted by this penalty. */
private final Class<RI> registeredInput;
Expand Down
Expand Up @@ -21,7 +21,7 @@
* @author asofold
*
*/
public final class CancelPenalty implements Penalty<CancelPenalty> {
public final class CancelPenalty implements IPenalty<CancelPenalty> {

public static final CancelPenalty CANCEL = new CancelPenalty();
private static boolean locked = false;
Expand Down
Expand Up @@ -31,17 +31,17 @@ public class DefaultPenaltyList implements IPenaltyList {
* @param <RI>
*/
private static class GenericNode<RI> {
private final List<Penalty<RI>> penalties = new LinkedList<Penalty<RI>>();
private final List<IPenalty<RI>> penalties = new LinkedList<IPenalty<RI>>();

/**
*
* @param input
* @param removeAppliedPenalties
* See {@link Penalty#apply(Object)}.
* See {@link IPenalty#apply(Object)}.
* @return True if the list has been emptied, false otherwise.
*/
private boolean apply(final RI input, final boolean removeAppliedPenalties) {
final Iterator<Penalty<RI>> it = penalties.iterator();
final Iterator<IPenalty<RI>> it = penalties.iterator();
while (it.hasNext()) {
if (it.next().apply(input) && removeAppliedPenalties) {
it.remove();
Expand All @@ -56,7 +56,7 @@ private boolean apply(final RI input, final boolean removeAppliedPenalties) {

@Override
public <RI> void addPenalty(final Class<RI> registeredInput,
final Penalty<RI> penalty) {
final IPenalty<RI> penalty) {
if (penalty == CancelPenalty.CANCEL) {
willCancel = true;
}
Expand Down
Expand Up @@ -21,7 +21,7 @@
*
* @param <RI>
*/
public interface Penalty<RI> {
public interface IPenalty<RI> {

/**
* Get the class that determines the accepted input type.
Expand Down
Expand Up @@ -41,7 +41,7 @@ public interface IPenaltyList {
* @param registeredInput
* @param penalty
*/
public <RI> void addPenalty(Class<RI> registeredInput, Penalty<RI> penalty);
public <RI> void addPenalty(Class<RI> registeredInput, IPenalty<RI> penalty);

/**
* Apply generic penalties registered exactly for the given type, using the
Expand All @@ -60,7 +60,7 @@ public <RI, I extends RI> void applyPenaltiesPrecisely(Class<RI> type,
* @param input
* @param removeAppliedPenalties
* If set to true, penalties that return true for
* {@link Penalty#apply(Object)} will be removed from the list.
* {@link IPenalty#apply(Object)} will be removed from the list.
*/
public <I> void applyAllApplicablePenalties(I input,
boolean removeAppliedPenalties);
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class PenaltyNode {
/** The probability for this node to apply. */
public final double probability;
/** Penalty to apply when this node applies. */
private final Penalty<?> penalty;
private final IPenalty<?> penalty;
/** Child nodes to test when this node applies. */
private final PenaltyNode[] childNodes;
/** Indicate that the result is set with the first child node that applies. */
Expand All @@ -47,7 +47,7 @@ public class PenaltyNode {
* @param random
* @param penalty
*/
public PenaltyNode(Random random, Penalty<?> penalty) {
public PenaltyNode(Random random, IPenalty<?> penalty) {
this(random, 1.0, penalty, null, false);
}

Expand All @@ -57,7 +57,7 @@ public PenaltyNode(Random random, Penalty<?> penalty) {
* @param probability
* @param penalty
*/
public PenaltyNode(Random random, double probability, Penalty<?> penalty) {
public PenaltyNode(Random random, double probability, IPenalty<?> penalty) {
this(random, probability, penalty, null, false);
}

Expand All @@ -71,7 +71,7 @@ public PenaltyNode(Random random, double probability, Penalty<?> penalty) {
* @param abortOnApply
* Evaluating child nodes: abort as soon as a child node applies.
*/
public PenaltyNode(Random random, double probability, Penalty<?> penalty, Collection<PenaltyNode> childNodes, boolean abortOnApply) {
public PenaltyNode(Random random, double probability, IPenalty<?> penalty, Collection<PenaltyNode> childNodes, boolean abortOnApply) {
this.random = random;
this.probability = probability;
this.penalty = penalty;
Expand Down

0 comments on commit 37c12a7

Please sign in to comment.