|
|
@@ -14,9 +14,10 @@ import java.util.Random;
|
|
|
import java.util.TreeMap;
|
|
|
import net.ranides.assira.collection.HashComparator;
|
|
|
import net.ranides.assira.collection.lookups.Lookup;
|
|
|
-import static net.ranides.assira.collection.mockup.TPointEnum.B1;
|
|
|
+import static net.ranides.assira.collection.mockup.TValueEnum.B1;
|
|
|
import net.ranides.assira.generic.CompareUtils;
|
|
|
import static org.junit.Assert.fail;
|
|
|
+import static org.junit.Assert.fail;
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
@@ -28,7 +29,7 @@ public final class TPointUtils {
|
|
|
// utility class
|
|
|
}
|
|
|
|
|
|
- public static final ObjectGenerator<TPoint, TPointEnum> KEYS = new ObjectGenerator<TPoint, TPointEnum>(TPoint.class) {
|
|
|
+ public static final ObjectGenerator<TPoint, TValueEnum> KEYS = new ObjectGenerator<TPoint, TValueEnum>(TPoint.class) {
|
|
|
|
|
|
@Override
|
|
|
public HashComparator<TPoint> comparator() {
|
|
|
@@ -36,7 +37,7 @@ public final class TPointUtils {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public TPoint object(TPointEnum key) {
|
|
|
+ public TPoint object(TValueEnum key) {
|
|
|
return $key(key);
|
|
|
}
|
|
|
|
|
|
@@ -46,7 +47,7 @@ public final class TPointUtils {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- public static final ObjectGenerator<Entry<TPoint, Integer>, TPointEnum> ENTRIES = new ObjectGenerator<Entry<TPoint, Integer>, TPointEnum>(Entry.class) {
|
|
|
+ public static final ObjectGenerator<Entry<TPoint, Integer>, TValueEnum> ENTRIES = new ObjectGenerator<Entry<TPoint, Integer>, TValueEnum>(Entry.class) {
|
|
|
|
|
|
@Override
|
|
|
public HashComparator<Entry<TPoint, Integer>> comparator() {
|
|
|
@@ -54,7 +55,7 @@ public final class TPointUtils {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Entry<TPoint, Integer> object(TPointEnum key) {
|
|
|
+ public Entry<TPoint, Integer> object(TValueEnum key) {
|
|
|
return $entry(key);
|
|
|
}
|
|
|
|
|
|
@@ -83,47 +84,47 @@ public final class TPointUtils {
|
|
|
// punkty suma < 100
|
|
|
// wartości mniejsze < 100
|
|
|
|
|
|
- private static final EnumMap<TPointEnum, TPoint> M_KEYS = new EnumMap<>(TPointEnum.class);
|
|
|
+ private static final EnumMap<TValueEnum, TPoint> M_KEYS = new EnumMap<>(TValueEnum.class);
|
|
|
|
|
|
static {
|
|
|
- M_KEYS.put(TPointEnum.A1, new TPoint(7, 4, 6)); // 17
|
|
|
- M_KEYS.put(TPointEnum.A1_EQ, new TPoint(7, 1, 9)); // 17
|
|
|
- M_KEYS.put(TPointEnum.A1_NE, new TPoint(7, 1, 2)); // 9
|
|
|
- M_KEYS.put(TPointEnum.B1, new TPoint(8, 4, 12)); // 24
|
|
|
- M_KEYS.put(TPointEnum.C1, new TPoint(9, 4, 13)); // 26
|
|
|
- M_KEYS.put(TPointEnum.D1, new TPoint(20, 40, 3)); // 63
|
|
|
- M_KEYS.put(TPointEnum.D2, new TPoint(20, 40, 4)); // 64
|
|
|
- M_KEYS.put(TPointEnum.D3, new TPoint(20, 40, 5)); // 65
|
|
|
- M_KEYS.put(TPointEnum.D4, new TPoint(20, 40, 6)); // 66
|
|
|
- M_KEYS.put(TPointEnum.E1, new TPoint(33, 42, 6)); // 81
|
|
|
- M_KEYS.put(TPointEnum.E1_EQ, new TPoint(33, 42, 6+0x10000)); // 81
|
|
|
- M_KEYS.put(TPointEnum.E1_NE, new TPoint(33, 42, 17)); // 92
|
|
|
+ M_KEYS.put(TValueEnum.A1, new TPoint(7, 4, 6)); // 17
|
|
|
+ M_KEYS.put(TValueEnum.A1_EQ, new TPoint(7, 1, 9)); // 17
|
|
|
+ M_KEYS.put(TValueEnum.A1_NE, new TPoint(7, 1, 2)); // 9
|
|
|
+ M_KEYS.put(TValueEnum.B1, new TPoint(8, 4, 12)); // 24
|
|
|
+ M_KEYS.put(TValueEnum.C1, new TPoint(9, 4, 13)); // 26
|
|
|
+ M_KEYS.put(TValueEnum.D1, new TPoint(20, 40, 3)); // 63
|
|
|
+ M_KEYS.put(TValueEnum.D2, new TPoint(20, 40, 4)); // 64
|
|
|
+ M_KEYS.put(TValueEnum.D3, new TPoint(20, 40, 5)); // 65
|
|
|
+ M_KEYS.put(TValueEnum.D4, new TPoint(20, 40, 6)); // 66
|
|
|
+ M_KEYS.put(TValueEnum.E1, new TPoint(33, 42, 6)); // 81
|
|
|
+ M_KEYS.put(TValueEnum.E1_EQ, new TPoint(33, 42, 6+0x10000)); // 81
|
|
|
+ M_KEYS.put(TValueEnum.E1_NE, new TPoint(33, 42, 17)); // 92
|
|
|
|
|
|
- M_KEYS.put(TPointEnum.SUB_MIN, new TPoint(3, 2, 1)); // 6
|
|
|
- M_KEYS.put(TPointEnum.SUB_MAX, new TPoint(44, 43, 12)); // 99
|
|
|
+ M_KEYS.put(TValueEnum.SUB_MIN, new TPoint(3, 2, 1)); // 6
|
|
|
+ M_KEYS.put(TValueEnum.SUB_MAX, new TPoint(44, 43, 12)); // 99
|
|
|
}
|
|
|
|
|
|
- private static final EnumMap<TPointEnum, Integer> M_VALS = new EnumMap<>(TPointEnum.class);
|
|
|
+ private static final EnumMap<TValueEnum, Integer> M_VALS = new EnumMap<>(TValueEnum.class);
|
|
|
|
|
|
static {
|
|
|
- M_VALS.put(TPointEnum.A1, 17);
|
|
|
- M_VALS.put(TPointEnum.A1_EQ, 19);
|
|
|
- M_VALS.put(TPointEnum.A1_NE, 20);
|
|
|
- M_VALS.put(TPointEnum.B1, 21);
|
|
|
- M_VALS.put(TPointEnum.C1, 22);
|
|
|
- M_VALS.put(TPointEnum.D1, 31);
|
|
|
- M_VALS.put(TPointEnum.D2, 32);
|
|
|
- M_VALS.put(TPointEnum.D3, 33);
|
|
|
- M_VALS.put(TPointEnum.D4, 34);
|
|
|
- M_VALS.put(TPointEnum.E1, 81);
|
|
|
- M_VALS.put(TPointEnum.E1_EQ, 81);
|
|
|
- M_VALS.put(TPointEnum.E1_NE, 81);
|
|
|
- M_VALS.put(TPointEnum.SUB_MIN, 91);
|
|
|
- M_VALS.put(TPointEnum.SUB_MAX, 92);
|
|
|
+ M_VALS.put(TValueEnum.A1, 17);
|
|
|
+ M_VALS.put(TValueEnum.A1_EQ, 19);
|
|
|
+ M_VALS.put(TValueEnum.A1_NE, 20);
|
|
|
+ M_VALS.put(TValueEnum.B1, 21);
|
|
|
+ M_VALS.put(TValueEnum.C1, 22);
|
|
|
+ M_VALS.put(TValueEnum.D1, 31);
|
|
|
+ M_VALS.put(TValueEnum.D2, 32);
|
|
|
+ M_VALS.put(TValueEnum.D3, 33);
|
|
|
+ M_VALS.put(TValueEnum.D4, 34);
|
|
|
+ M_VALS.put(TValueEnum.E1, 81);
|
|
|
+ M_VALS.put(TValueEnum.E1_EQ, 81);
|
|
|
+ M_VALS.put(TValueEnum.E1_NE, 81);
|
|
|
+ M_VALS.put(TValueEnum.SUB_MIN, 91);
|
|
|
+ M_VALS.put(TValueEnum.SUB_MAX, 92);
|
|
|
}
|
|
|
|
|
|
- public static void $put(Map<TPoint, Integer> target, TPointEnum... items) {
|
|
|
- for(TPointEnum item : items) {
|
|
|
+ public static void $put(Map<TPoint, Integer> target, TValueEnum... items) {
|
|
|
+ for(TValueEnum item : items) {
|
|
|
target.put($key(item), $value(item));
|
|
|
}
|
|
|
}
|
|
|
@@ -134,7 +135,7 @@ public final class TPointUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static Entry<TPoint, Integer> $find(Map<TPoint, Integer> target, TPointEnum key) {
|
|
|
+ public static Entry<TPoint, Integer> $find(Map<TPoint, Integer> target, TValueEnum key) {
|
|
|
for(Entry<TPoint, Integer> entry : target.entrySet()) {
|
|
|
if($equals(entry.getKey(), key)) {
|
|
|
return entry;
|
|
|
@@ -183,11 +184,11 @@ public final class TPointUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static TPoint $key(TPointEnum type) {
|
|
|
+ public static TPoint $key(TValueEnum type) {
|
|
|
return M_KEYS.get(type);
|
|
|
}
|
|
|
|
|
|
- public static TPoint[] $keys(TPointEnum... values) {
|
|
|
+ public static TPoint[] $keys(TValueEnum... values) {
|
|
|
TPoint[] array = new TPoint[values.length];
|
|
|
for(int i=0; i<values.length; i++) {
|
|
|
array[i] = $key(values[i]);
|
|
|
@@ -233,7 +234,7 @@ public final class TPointUtils {
|
|
|
return array;
|
|
|
}
|
|
|
|
|
|
- public static int $value(TPointEnum type) {
|
|
|
+ public static int $value(TValueEnum type) {
|
|
|
return M_VALS.get(type);
|
|
|
}
|
|
|
|
|
|
@@ -246,7 +247,7 @@ public final class TPointUtils {
|
|
|
return array;
|
|
|
}
|
|
|
|
|
|
- public static int[] $values(TPointEnum... values) {
|
|
|
+ public static int[] $values(TValueEnum... values) {
|
|
|
int[] array = new int[values.length];
|
|
|
for(int i=0; i<values.length; i++) {
|
|
|
array[i] = $value(values[i]);
|
|
|
@@ -254,7 +255,7 @@ public final class TPointUtils {
|
|
|
return array;
|
|
|
}
|
|
|
|
|
|
- public static Integer $object(TPointEnum type) {
|
|
|
+ public static Integer $object(TValueEnum type) {
|
|
|
return M_VALS.get(type);
|
|
|
}
|
|
|
|
|
|
@@ -267,7 +268,7 @@ public final class TPointUtils {
|
|
|
return array;
|
|
|
}
|
|
|
|
|
|
- public static Integer[] $objects(TPointEnum... values) {
|
|
|
+ public static Integer[] $objects(TValueEnum... values) {
|
|
|
Integer[] array = new Integer[values.length];
|
|
|
for(int i=0; i<values.length; i++) {
|
|
|
array[i] = $object(values[i]);
|
|
|
@@ -304,7 +305,7 @@ public final class TPointUtils {
|
|
|
return TPoint.SUM.equals(point1, point2);
|
|
|
}
|
|
|
|
|
|
- public static boolean $equals(TPoint point1, TPointEnum point2) {
|
|
|
+ public static boolean $equals(TPoint point1, TValueEnum point2) {
|
|
|
return TPoint.SUM.equals(point1, $key(point2));
|
|
|
}
|
|
|
|
|
|
@@ -312,7 +313,7 @@ public final class TPointUtils {
|
|
|
return TPoint.SUM.hashCode(point);
|
|
|
}
|
|
|
|
|
|
- public static int $hashcode(TPointEnum point) {
|
|
|
+ public static int $hashcode(TValueEnum point) {
|
|
|
return TPoint.SUM.hashCode($key(point));
|
|
|
}
|
|
|
|
|
|
@@ -320,12 +321,12 @@ public final class TPointUtils {
|
|
|
return new AbstractMap.SimpleEntry<>(key, value);
|
|
|
}
|
|
|
|
|
|
- public static Entry<TPoint, Integer> $entry(TPointEnum point){
|
|
|
+ public static Entry<TPoint, Integer> $entry(TValueEnum point){
|
|
|
return new Lookup.BasicEntry<>($key(point), $value(point));
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- public static Entry<TPoint, Integer>[] $entries(TPointEnum... values) {
|
|
|
+ public static Entry<TPoint, Integer>[] $entries(TValueEnum... values) {
|
|
|
Entry<TPoint, Integer>[] array = new Entry[values.length];
|
|
|
for(int i=0; i<values.length; i++) {
|
|
|
array[i] = $entry(values[i]);
|