| 237 | private static final List<Status> STATUS_LIST = buildStatusList(); |
| 238 | |
| 239 | private static List<Status> buildStatusList() { |
| 240 | TreeMap<Integer, Status> canonicalizer = new TreeMap<>(); |
| 241 | for (Code code : Code.values()) { |
| 242 | Status replaced = canonicalizer.put(code.value(), new Status(code)); |
| 243 | if (replaced != null) { |
| 244 | throw new IllegalStateException("Code value duplication between " |
| 245 | + replaced.getCode().name() + " & " + code.name()); |
| 246 | } |
| 247 | } |
| 248 | return Collections.unmodifiableList(new ArrayList<>(canonicalizer.values())); |
| 249 | } |
| 250 | |
| 251 | // A pseudo-enum of Status instances mapped 1:1 with values in Code. This simplifies construction |
| 252 | // patterns for derived instances of Status. |