Skip to content

Commit

Permalink
🚑️ Support lowercase and UPPERCASE for Enums
Browse files Browse the repository at this point in the history
The CodeTF JSON schema says that enums can use lowercase or uppercase.
This change makes the enums prefer lowercase (i.e. in serialization),
but they will accept uppercase (i.e. in deserialization). This is a good
transition towards removing support for UPPERCASE if we would like to
take that next step.

/towards ISS-617
  • Loading branch information
gilday committed Mar 15, 2024
1 parent 85097d8 commit 4d38d9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/main/java/io/codemodder/codetf/CodeTFPackageAction.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package io.codemodder.codetf;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;

public final class CodeTFPackageAction {

public enum CodeTFPackageActionType {
@JsonAlias("add")
ADD,
@JsonAlias("remove")
REMOVE
}

public enum CodeTFPackageActionResult {
@JsonAlias("completed")
COMPLETED,
@JsonAlias("failed")
FAILED,
@JsonAlias("skipped")
SKIPPED
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/basic.codetf.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"properties" : { },
"packageActions" : [
{
"action" : "ADD",
"result": "COMPLETED",
"action" : "add",
"result": "completed",
"package" : "pkg:maven/io.github.pixee/java-security-toolkit@1.0.2"
}
]
Expand All @@ -63,4 +63,4 @@
]
}
]
}
}

0 comments on commit 4d38d9d

Please sign in to comment.