Rename Penalty to IPenalty.
This commit is contained in:
parent
7269a026eb
commit
37c12a7fdd
|
@ -22,7 +22,7 @@ package fr.neatmonster.nocheatplus.penalties;
|
|||
* @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;
|
||||
|
|
|
@ -21,7 +21,7 @@ package fr.neatmonster.nocheatplus.penalties;
|
|||
* @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;
|
||||
|
|
|
@ -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();
|
||||
|
@ -56,7 +56,7 @@ public class DefaultPenaltyList implements IPenaltyList {
|
|||
|
||||
@Override
|
||||
public <RI> void addPenalty(final Class<RI> registeredInput,
|
||||
final Penalty<RI> penalty) {
|
||||
final IPenalty<RI> penalty) {
|
||||
if (penalty == CancelPenalty.CANCEL) {
|
||||
willCancel = true;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package fr.neatmonster.nocheatplus.penalties;
|
|||
*
|
||||
* @param <RI>
|
||||
*/
|
||||
public interface Penalty<RI> {
|
||||
public interface IPenalty<RI> {
|
||||
|
||||
/**
|
||||
* Get the class that determines the accepted input type.
|
|
@ -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
|
||||
|
@ -60,7 +60,7 @@ public interface IPenaltyList {
|
|||
* @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);
|
||||
|
|
|
@ -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. */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class PenaltyNode {
|
|||
* @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);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class PenaltyNode {
|
|||
* @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;
|
||||
|
|
Loading…
Reference in New Issue