|
| 1 | +package edu.cuny.hunter.hybridize.core.analysis; |
| 2 | + |
| 3 | +import java.util.Arrays; |
| 4 | + |
| 5 | +public enum PreconditionFailure { |
| 6 | + CURRENTLY_NOT_HANDLED(14); |
| 7 | +// HAS_SIDE_EFFECTS(8), |
| 8 | +// HAS_SIDE_EFFECTS2(9), |
| 9 | +// INCONSISTENT_POSSIBLE_EXECUTION_MODES(6), |
| 10 | +// INCONSISTENT_POSSIBLE_ORDERINGS(7), |
| 11 | +// INCONSISTENT_POSSIBLE_STREAM_SOURCE_ORDERING(1), |
| 12 | +// NO_APPLICATION_CODE_IN_CALL_STRINGS(17), |
| 13 | + // entry points are misconfigured. |
| 14 | +// NO_ENTRY_POINT(16), // P1. |
| 15 | +// NO_STATEFUL_INTERMEDIATE_OPERATIONS(11), // P2. |
| 16 | +// NO_TERMINAL_OPERATIONS(13), // P3. |
| 17 | +// NON_DETERMINABLE_REDUCTION_ORDERING(5), // P4 or P5. |
| 18 | +// NON_DETERMINABLE_STREAM_SOURCE_ORDERING(4), // P4 or P4. |
| 19 | +// NON_INSTANTIABLE_POSSIBLE_STREAM_SOURCE(3), |
| 20 | +// NON_ITERABLE_POSSIBLE_STREAM_SOURCE(2), // should just be #97 currently. |
| 21 | +// REDUCE_ORDERING_MATTERS(10), // either pivotal code isn't reachable or |
| 22 | +// STREAM_CODE_NOT_REACHABLE(15), // user didn't specify entry points. |
| 23 | +// UNORDERED(11); // N may be too small. |
| 24 | + |
| 25 | + static { |
| 26 | + // check that the codes are unique. |
| 27 | + if (Arrays.stream(PreconditionFailure.values()).map(PreconditionFailure::getCode).distinct() |
| 28 | + .count() != PreconditionFailure.values().length) |
| 29 | + throw new IllegalStateException("Codes aren't unique."); |
| 30 | + } |
| 31 | + |
| 32 | + public static void main(String[] args) { |
| 33 | + System.out.println("code,name"); |
| 34 | + for (PreconditionFailure failure : PreconditionFailure.values()) |
| 35 | + System.out.println(failure.getCode() + "," + failure); |
| 36 | + } |
| 37 | + |
| 38 | + private int code; |
| 39 | + |
| 40 | + private PreconditionFailure(int code) { |
| 41 | + this.code = code; |
| 42 | + } |
| 43 | + |
| 44 | + public int getCode() { |
| 45 | + return this.code; |
| 46 | + } |
| 47 | +} |
0 commit comments