summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-12-03 19:24:23 -0500
committerBen Culkin <scorpress@gmail.com>2020-12-03 19:24:23 -0500
commit38f1e562bf1e1d9d2c837317fced7467f2e81adc (patch)
treec26d3e0075f7bc027a491ab005f72d9907c51201
parent28895cad07c7aec1b324a2c75e5da5ce728cad91 (diff)
Rename interfaces to match Java style
Renames several interfaces named in the IWhatever style, which Java doesn't use
-rw-r--r--dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java2
-rw-r--r--dice/src/example/java/bjc/dicelang/neodice/statements/DiePoolStatementValue.java4
-rw-r--r--dice/src/example/java/bjc/dicelang/neodice/statements/DieStatementValue.java4
-rw-r--r--dice/src/main/java/bjc/dicelang/neodice/Die.java (renamed from dice/src/main/java/bjc/dicelang/neodice/IDie.java)12
-rw-r--r--dice/src/main/java/bjc/dicelang/neodice/DiePool.java (renamed from dice/src/main/java/bjc/dicelang/neodice/IDiePool.java)26
-rw-r--r--dice/src/main/java/bjc/dicelang/neodice/die/PolyhedralDie.java2
-rw-r--r--dice/src/main/java/bjc/dicelang/neodice/die/RerollDie.java24
-rw-r--r--dice/src/main/java/bjc/dicelang/neodice/diepool/ExpandDiePool.java10
-rw-r--r--dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java14
-rw-r--r--dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java10
-rw-r--r--dice/src/main/java/bjc/dicelang/neodice/diepool/TransformDiePool.java8
11 files changed, 58 insertions, 58 deletions
diff --git a/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java b/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java
index 6af495e..aad2a24 100644
--- a/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java
+++ b/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java
@@ -20,7 +20,7 @@ public class PolyhedralDieCommand implements Command {
if (numSides < 0) throw new DieBoxException("Number of sides to polyhedral-die was not valid (must be less than 0, was %d)", numSides);
- IDie<StatementValue> die = IDie
+ Die<StatementValue> die = Die
.polyhedral(numSides)
.transform(IntegerStatementValue::new);
diff --git a/dice/src/example/java/bjc/dicelang/neodice/statements/DiePoolStatementValue.java b/dice/src/example/java/bjc/dicelang/neodice/statements/DiePoolStatementValue.java
index 551c0e9..8d7c1f4 100644
--- a/dice/src/example/java/bjc/dicelang/neodice/statements/DiePoolStatementValue.java
+++ b/dice/src/example/java/bjc/dicelang/neodice/statements/DiePoolStatementValue.java
@@ -8,9 +8,9 @@ import bjc.dicelang.neodice.*;
public class DiePoolStatementValue extends StatementValue {
public final Type elementType;
- public final IDiePool<StatementValue> value;
+ public final DiePool<StatementValue> value;
- public DiePoolStatementValue(Type elementType, IDiePool<StatementValue> value) {
+ public DiePoolStatementValue(Type elementType, DiePool<StatementValue> value) {
super(DIEPOOL);
this.elementType = elementType;
diff --git a/dice/src/example/java/bjc/dicelang/neodice/statements/DieStatementValue.java b/dice/src/example/java/bjc/dicelang/neodice/statements/DieStatementValue.java
index e1dbde8..f9a8d1e 100644
--- a/dice/src/example/java/bjc/dicelang/neodice/statements/DieStatementValue.java
+++ b/dice/src/example/java/bjc/dicelang/neodice/statements/DieStatementValue.java
@@ -8,9 +8,9 @@ import bjc.dicelang.neodice.*;
public class DieStatementValue extends StatementValue {
public final Type sideType;
- public final IDie<StatementValue> value;
+ public final Die<StatementValue> value;
- public DieStatementValue(Type sideType, IDie<StatementValue> value) {
+ public DieStatementValue(Type sideType, Die<StatementValue> value) {
super(DIE);
this.sideType = sideType;
diff --git a/dice/src/main/java/bjc/dicelang/neodice/IDie.java b/dice/src/main/java/bjc/dicelang/neodice/Die.java
index 274af66..910d173 100644
--- a/dice/src/main/java/bjc/dicelang/neodice/IDie.java
+++ b/dice/src/main/java/bjc/dicelang/neodice/Die.java
@@ -13,7 +13,7 @@ import bjc.dicelang.neodice.diepool.*;
*
*/
@FunctionalInterface
-public interface IDie<SideType> {
+public interface Die<SideType> {
/**
* Rolls this die.
*
@@ -30,7 +30,7 @@ public interface IDie<SideType> {
*
* @return A die pool that rolls this die the specified number of times.
*/
- default IDiePool<SideType> times(int numTimes) {
+ default DiePool<SideType> times(int numTimes) {
return new ExpandDiePool<>(this, (die, rng) -> {
return Stream.generate(() -> die.roll(rng))
.limit(numTimes);
@@ -44,7 +44,7 @@ public interface IDie<SideType> {
*
* @return A die that rerolls when the given condition is met.
*/
- default IDie<SideType> reroll(
+ default Die<SideType> reroll(
Comparator<SideType> comparer,
Predicate<SideType> condition) {
return RerollDie.create(comparer, this, condition,
@@ -60,7 +60,7 @@ public interface IDie<SideType> {
*
* @return A die that rerolls when the given condition is met.
*/
- default IDie<SideType> reroll(
+ default Die<SideType> reroll(
Comparator<SideType> comparer,
Predicate<SideType> condition,
int limit) {
@@ -79,7 +79,7 @@ public interface IDie<SideType> {
return Stream.generate(() -> this.roll(rng));
}
- default <NewType> IDie<NewType> transform(Function<SideType, NewType> mapper) {
+ default <NewType> Die<NewType> transform(Function<SideType, NewType> mapper) {
return (rng) -> mapper.apply(this.roll(rng));
}
@@ -90,7 +90,7 @@ public interface IDie<SideType> {
*
* @return A die which returns a result from 1 to sides.
*/
- static IDie<Integer> polyhedral(int sides) {
+ static Die<Integer> polyhedral(int sides) {
return new PolyhedralDie(sides);
}
} \ No newline at end of file
diff --git a/dice/src/main/java/bjc/dicelang/neodice/IDiePool.java b/dice/src/main/java/bjc/dicelang/neodice/DiePool.java
index b887784..e3a5782 100644
--- a/dice/src/main/java/bjc/dicelang/neodice/IDiePool.java
+++ b/dice/src/main/java/bjc/dicelang/neodice/DiePool.java
@@ -13,7 +13,7 @@ import bjc.dicelang.neodice.diepool.*;
*
*/
@FunctionalInterface
-public interface IDiePool<SideType> {
+public interface DiePool<SideType> {
/**
* Roll each die in the pool, and return the results.
*
@@ -45,7 +45,7 @@ public interface IDiePool<SideType> {
*
* @throws UnsupportedOperationException If the composite dice can't be retrieved.
*/
- default List<IDie<SideType>> contained() {
+ default List<Die<SideType>> contained() {
throw new UnsupportedOperationException("Can't get composite dice");
}
@@ -61,7 +61,7 @@ public interface IDiePool<SideType> {
*
* @return The die pool, which returns its results in sorted order.
*/
- default IDiePool<SideType> sorted(
+ default DiePool<SideType> sorted(
Comparator<SideType> comparer,
boolean isDescending) {
return new TransformDiePool<>(this,
@@ -79,7 +79,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which contains only entries that pass the predicate.
*/
- default IDiePool<SideType> filtered(Predicate<SideType> matcher) {
+ default DiePool<SideType> filtered(Predicate<SideType> matcher) {
return new TransformDiePool<>(this,
(pool) -> pool.filter(matcher));
}
@@ -91,7 +91,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which has the first entries dropped.
*/
- default IDiePool<SideType> dropFirst(int number) {
+ default DiePool<SideType> dropFirst(int number) {
return new TransformDiePool<>(this,
(pool) -> pool.skip(number));
}
@@ -103,7 +103,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which has the last entries dropped.
*/
- default IDiePool<SideType> dropLast(int number) {
+ default DiePool<SideType> dropLast(int number) {
return new TransformDiePool<>(this, (pool) -> {
Deque<SideType> temp = new ArrayDeque<>();
@@ -122,7 +122,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which has the first entries kept.
*/
- default IDiePool<SideType> keepFirst(int number) {
+ default DiePool<SideType> keepFirst(int number) {
return new TransformDiePool<>(this,
(pool) -> pool.limit(number));
}
@@ -134,7 +134,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which has the last entries kept.
*/
- default IDiePool<SideType> keepLast(int number) {
+ default DiePool<SideType> keepLast(int number) {
return new TransformDiePool<>(this, (pool) -> {
Deque<SideType> temp = new ArrayDeque<>();
@@ -158,7 +158,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which has the lowest entries dropped.
*/
- default IDiePool<SideType> dropLowest(Comparator<SideType> comparer, int number) {
+ default DiePool<SideType> dropLowest(Comparator<SideType> comparer, int number) {
return this.sorted(comparer, false).dropFirst(number);
}
@@ -169,7 +169,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which has the lowest entries dropped.
*/
- default IDiePool<SideType> dropHighest(Comparator<SideType> comparer,int number) {
+ default DiePool<SideType> dropHighest(Comparator<SideType> comparer,int number) {
return this.sorted(comparer, false).dropLast(number);
}
@@ -180,7 +180,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which has the lowest entries kept.
*/
- default IDiePool<SideType> keepLowest(Comparator<SideType> comparer,int number) {
+ default DiePool<SideType> keepLowest(Comparator<SideType> comparer,int number) {
return this.sorted(comparer, false).keepFirst(number);
}
@@ -191,7 +191,7 @@ public interface IDiePool<SideType> {
*
* @return A die pool which has the highest entries kept.
*/
- default IDiePool<SideType> keepHighest(Comparator<SideType> comparer,int number) {
+ default DiePool<SideType> keepHighest(Comparator<SideType> comparer,int number) {
return this.sorted(comparer, false).keepLast(number);
}
@@ -216,7 +216,7 @@ public interface IDiePool<SideType> {
* @return A pool which contains the provided dice.
*/
@SafeVarargs
- static <Side> IDiePool<Side> containing(IDie<Side>... dice) {
+ static <Side> DiePool<Side> containing(Die<Side>... dice) {
return new FixedDiePool<>(dice);
}
} \ No newline at end of file
diff --git a/dice/src/main/java/bjc/dicelang/neodice/die/PolyhedralDie.java b/dice/src/main/java/bjc/dicelang/neodice/die/PolyhedralDie.java
index 2909724..07ab183 100644
--- a/dice/src/main/java/bjc/dicelang/neodice/die/PolyhedralDie.java
+++ b/dice/src/main/java/bjc/dicelang/neodice/die/PolyhedralDie.java
@@ -4,7 +4,7 @@ import java.util.*;
import bjc.dicelang.neodice.*;
-public class PolyhedralDie implements IDie<Integer> {
+public class PolyhedralDie implements Die<Integer> {
private final int sides;
public PolyhedralDie(int sides) {
diff --git a/dice/src/main/java/bjc/dicelang/neodice/die/RerollDie.java b/dice/src/main/java/bjc/dicelang/neodice/die/RerollDie.java
index f8cb0fa..7925c9d 100644
--- a/dice/src/main/java/bjc/dicelang/neodice/die/RerollDie.java
+++ b/dice/src/main/java/bjc/dicelang/neodice/die/RerollDie.java
@@ -6,8 +6,8 @@ import java.util.function.*;
import bjc.dicelang.neodice.*;
import bjc.esodata.*;
-public class RerollDie<SideType> implements IDie<SideType> {
- private final IDie<SideType> contained;
+public class RerollDie<SideType> implements Die<SideType> {
+ private final Die<SideType> contained;
private final Predicate<SideType> condition;
private final Function<MinMaxList<SideType>, SideType> chooser;
@@ -18,7 +18,7 @@ public class RerollDie<SideType> implements IDie<SideType> {
private RerollDie(
Comparator<SideType> comparer,
- IDie<SideType> contained,
+ Die<SideType> contained,
Predicate<SideType> condition,
Function<MinMaxList<SideType>, SideType> chooser) {
this.comparer = comparer;
@@ -31,7 +31,7 @@ public class RerollDie<SideType> implements IDie<SideType> {
private RerollDie(
Comparator<SideType> comparer,
- IDie<SideType> contained,
+ Die<SideType> contained,
Predicate<SideType> condition,
Function<MinMaxList<SideType>, SideType> chooser,
int limit) {
@@ -57,15 +57,15 @@ public class RerollDie<SideType> implements IDie<SideType> {
return chooser.apply(newRolls);
}
- public static <Side extends Comparable<Side>> IDie<Side> create(
- IDie<Side> contained,
+ public static <Side extends Comparable<Side>> Die<Side> create(
+ Die<Side> contained,
Predicate<Side> condition,
Function<MinMaxList<Side>, Side> chooser) {
return new RerollDie<>(Comparator.naturalOrder(), contained, condition, chooser);
}
- public static <Side extends Comparable<Side>> IDie<Side> create(
- IDie<Side> contained,
+ public static <Side extends Comparable<Side>> Die<Side> create(
+ Die<Side> contained,
Predicate<Side> condition,
Function<MinMaxList<Side>, Side> chooser,
int limit) {
@@ -73,17 +73,17 @@ public class RerollDie<SideType> implements IDie<SideType> {
}
- public static <Side> IDie<Side> create(
+ public static <Side> Die<Side> create(
Comparator<Side> comparer,
- IDie<Side> contained,
+ Die<Side> contained,
Predicate<Side> condition,
Function<MinMaxList<Side>, Side> chooser) {
return new RerollDie<Side>(comparer, contained, condition, chooser);
}
- public static <Side> IDie<Side> create(
+ public static <Side> Die<Side> create(
Comparator<Side> comparer,
- IDie<Side> contained,
+ Die<Side> contained,
Predicate<Side> condition,
Function<MinMaxList<Side>, Side> chooser,
int limit) {
diff --git a/dice/src/main/java/bjc/dicelang/neodice/diepool/ExpandDiePool.java b/dice/src/main/java/bjc/dicelang/neodice/diepool/ExpandDiePool.java
index 7c58e72..97acc79 100644
--- a/dice/src/main/java/bjc/dicelang/neodice/diepool/ExpandDiePool.java
+++ b/dice/src/main/java/bjc/dicelang/neodice/diepool/ExpandDiePool.java
@@ -6,13 +6,13 @@ import java.util.stream.*;
import bjc.dicelang.neodice.*;
-public class ExpandDiePool<SideType> implements IDiePool<SideType> {
- private final IDie<SideType> contained;
+public class ExpandDiePool<SideType> implements DiePool<SideType> {
+ private final Die<SideType> contained;
- private final BiFunction<IDie<SideType>, Random, Stream<SideType>> expander;
+ private final BiFunction<Die<SideType>, Random, Stream<SideType>> expander;
- public ExpandDiePool(IDie<SideType> contained,
- BiFunction<IDie<SideType>, Random, Stream<SideType>> expander) {
+ public ExpandDiePool(Die<SideType> contained,
+ BiFunction<Die<SideType>, Random, Stream<SideType>> expander) {
this.contained = contained;
this.expander = expander;
}
diff --git a/dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java b/dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java
index a536f62..4950407 100644
--- a/dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java
+++ b/dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java
@@ -5,17 +5,17 @@ import java.util.stream.*;
import bjc.dicelang.neodice.*;
-public class FixedDiePool<SideType> implements IDiePool<SideType> {
- private final List<IDie<SideType>> dice;
+public class FixedDiePool<SideType> implements DiePool<SideType> {
+ private final List<Die<SideType>> dice;
- public FixedDiePool(List<IDie<SideType>> dice) {
+ public FixedDiePool(List<Die<SideType>> dice) {
this.dice = dice;
}
@SafeVarargs
- public FixedDiePool(IDie<SideType>...dice) {
+ public FixedDiePool(Die<SideType>...dice) {
this.dice = new ArrayList<>(dice.length);
- for (IDie<SideType> die : dice) {
+ for (Die<SideType> die : dice) {
this.dice.add(die);
}
}
@@ -26,7 +26,7 @@ public class FixedDiePool<SideType> implements IDiePool<SideType> {
}
@Override
- public List<IDie<SideType>> contained() {
+ public List<Die<SideType>> contained() {
return dice;
}
@@ -34,7 +34,7 @@ public class FixedDiePool<SideType> implements IDiePool<SideType> {
@Override
public String toString() {
return dice.stream()
- .map(IDie<SideType>::toString)
+ .map(Die<SideType>::toString)
.collect(Collectors.joining(", "));
}
diff --git a/dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java b/dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java
index 56fe0e5..e039e47 100644
--- a/dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java
+++ b/dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java
@@ -5,11 +5,11 @@ import java.util.stream.*;
import bjc.dicelang.neodice.*;
-public class TimesDiePool<SideType> implements IDiePool<SideType> {
- private final IDie<SideType> contained;
+public class TimesDiePool<SideType> implements DiePool<SideType> {
+ private final Die<SideType> contained;
private final int numDice;
- public TimesDiePool(IDie<SideType> contained, int numDice) {
+ public TimesDiePool(Die<SideType> contained, int numDice) {
this.contained = contained;
this.numDice = numDice;
}
@@ -21,8 +21,8 @@ public class TimesDiePool<SideType> implements IDiePool<SideType> {
}
@Override
- public List<IDie<SideType>> contained() {
- List<IDie<SideType>> results = new ArrayList<>(numDice);
+ public List<Die<SideType>> contained() {
+ List<Die<SideType>> results = new ArrayList<>(numDice);
for (int index = 0; index < numDice; index++) {
results.add(contained);
diff --git a/dice/src/main/java/bjc/dicelang/neodice/diepool/TransformDiePool.java b/dice/src/main/java/bjc/dicelang/neodice/diepool/TransformDiePool.java
index f590e91..80b563f 100644
--- a/dice/src/main/java/bjc/dicelang/neodice/diepool/TransformDiePool.java
+++ b/dice/src/main/java/bjc/dicelang/neodice/diepool/TransformDiePool.java
@@ -6,12 +6,12 @@ import java.util.stream.*;
import bjc.dicelang.neodice.*;
-public class TransformDiePool<SideType> implements IDiePool<SideType> {
- private final IDiePool<SideType> contained;
+public class TransformDiePool<SideType> implements DiePool<SideType> {
+ private final DiePool<SideType> contained;
private UnaryOperator<Stream<SideType>> transform;
- public TransformDiePool(IDiePool<SideType> contained,
+ public TransformDiePool(DiePool<SideType> contained,
UnaryOperator<Stream<SideType>> transform) {
super();
this.contained = contained;
@@ -24,7 +24,7 @@ public class TransformDiePool<SideType> implements IDiePool<SideType> {
}
@Override
- public List<IDie<SideType>> contained() {
+ public List<Die<SideType>> contained() {
return contained.contained();
}