| 1 | package edu.ucsb.cs.scaffold.enums; | |
| 2 | ||
| 3 | import com.fasterxml.jackson.annotation.JsonCreator; | |
| 4 | import com.fasterxml.jackson.annotation.JsonFormat; | |
| 5 | import com.fasterxml.jackson.databind.JsonNode; | |
| 6 | import java.util.List; | |
| 7 | import lombok.Getter; | |
| 8 | ||
| 9 | @Getter | |
| 10 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) | |
| 11 | public enum School { | |
| 12 | UCSB( | |
| 13 | "UCSB", | |
| 14 | List.of("UC Santa Barbara", "University of California, Santa Barbara", "SB"), | |
| 15 | "https://ucsb.instructure.com/api/graphql"), | |
| 16 | OTHER("Other", List.of("Other"), ""); | |
| 17 | ||
| 18 | private School(String displayName, List<String> alternateNames, String canvasImplementation) { | |
| 19 | this.displayName = displayName; | |
| 20 | this.alternateNames = alternateNames; | |
| 21 | this.canvasImplementation = canvasImplementation; | |
| 22 | } | |
| 23 | ||
| 24 | private final List<String> alternateNames; | |
| 25 | private final String canvasImplementation; | |
| 26 | private final String displayName; | |
| 27 | private final String key = this.name(); | |
| 28 | ||
| 29 | /* | |
| 30 | * This is mostly to allow tests to serialize back in objects with school properties. | |
| 31 | */ | |
| 32 | @JsonCreator | |
| 33 | public static School fromKey(JsonNode node) { | |
| 34 |
1
1. fromKey : negated conditional → KILLED |
if (node == null) { |
| 35 | return null; | |
| 36 | } | |
| 37 |
1
1. fromKey : negated conditional → KILLED |
if (node.isTextual()) { |
| 38 |
1
1. fromKey : replaced return value with null for edu/ucsb/cs/scaffold/enums/School::fromKey → KILLED |
return School.valueOf(node.asText().toUpperCase()); |
| 39 | } | |
| 40 |
1
1. fromKey : negated conditional → KILLED |
if (node.has("key")) { |
| 41 |
1
1. fromKey : replaced return value with null for edu/ucsb/cs/scaffold/enums/School::fromKey → KILLED |
return School.valueOf(node.get("key").asText().toUpperCase()); |
| 42 | } | |
| 43 | ||
| 44 | throw new IllegalArgumentException("Invalid JSON node for School enum"); | |
| 45 | } | |
| 46 | } | |
Mutations | ||
| 34 |
1.1 |
|
| 37 |
1.1 |
|
| 38 |
1.1 |
|
| 40 |
1.1 |
|
| 41 |
1.1 |