Skip to content

Commit

Permalink
Revert "[fix] Conjure Enum values support numeric characters (#197)"
Browse files Browse the repository at this point in the history
This reverts commit 2acf798.
  • Loading branch information
iamdanfox committed Feb 15, 2019
1 parent e2de139 commit b23ea7c
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
public final class SimpleEnum {
public static final SimpleEnum VALUE = new SimpleEnum(Value.VALUE, "VALUE");

public static final SimpleEnum VALUE2 = new SimpleEnum(Value.VALUE2, "VALUE2");

private final Value value;

private final String string;
Expand Down Expand Up @@ -59,8 +57,6 @@ public static SimpleEnum valueOf(String value) {
switch (value) {
case "VALUE":
return VALUE;
case "VALUE2":
return VALUE2;
default:
ConjureEnums.validate(value);
return new SimpleEnum(Value.UNKNOWN, value);
Expand All @@ -71,8 +67,6 @@ public <T> T accept(Visitor<T> visitor) {
switch (value) {
case VALUE:
return visitor.visitValue();
case VALUE2:
return visitor.visitValue2();
default:
return visitor.visitUnknown(string);
}
Expand All @@ -82,17 +76,13 @@ public <T> T accept(Visitor<T> visitor) {
public enum Value {
VALUE,

VALUE2,

UNKNOWN
}

@Generated("com.palantir.conjure.java.types.EnumGenerator")
public interface Visitor<T> {
T visitValue();

T visitValue2();

T visitUnknown(String unknownValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ public void testEnumCasingDeserializationInvariantToInputCase() throws Exception
.isInstanceOf(SafeIllegalArgumentException.class)
.hasLogMessage("Enum values must use UPPER_SNAKE_CASE")
.hasExactlyArgs(UnsafeArg.of("value", "oNE"));
assertThat(mapper.readValue("\"100\"", EnumExample.class)).isEqualTo(EnumExample.valueOf("100"));
}

private <T extends Throwable & SafeLoggable> LoggableExceptionAssert<T> assertThatExceptionThrownRootCause(
Expand Down
1 change: 0 additions & 1 deletion conjure-java-core/src/test/resources/ete-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ types:
SimpleEnum:
values:
- VALUE
- VALUE2

services:
EmptyPathService:
Expand Down
1 change: 0 additions & 1 deletion conjure-java-core/src/test/resources/example-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,3 @@ types:
SimpleEnum:
values:
- VALUE
- VALUE2
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public static void validate(String value) {
}

private static boolean isAllowedCharacter(char character) {
return (character >= 'A' && character <= 'Z') || (character >= '0' && character <= '9') || character == '_';
return (character >= 'A' && character <= 'Z') || character == '_';
}
}

0 comments on commit b23ea7c

Please sign in to comment.