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