class JEnum extends AbstractJSONSchema2Pojo {

  private static final String VALUE = "value";

  private final String type;
  private final String underlyingType;
  private final Set<String> values; //Let's prevent duplicates

  public JEnum(String type, String underlyingType, List<JsonNode> values, Config config, String description,
      final boolean isNullable,
      JsonNode defaultValue) {
    super(config, description, isNullable, defaultValue, null);
    this.type = AbstractJSONSchema2Pojo.sanitizeString(
        type.substring(0, 1).toUpperCase() + type.substring(1));
    this.underlyingType = underlyingType;
    //Tests assume order so let's use LinkedHashSet instead of just using Collectors.toSet()
    this.values = values.stream().map(JsonNode::asText).collect(Collectors.toCollection(LinkedHashSet::new));
  }

  @Override
  public String getType() {
    return this.type;
  }

  private String sanitizeEnumEntry(final String str) {<FILL_FUNCTION_BODY>}

  @Override
  public GeneratorResult generateJava() {
    CompilationUnit cu = new CompilationUnit();
    EnumDeclaration en = cu.addEnum(this.type);

    en.addField(underlyingType, VALUE);
    ConstructorDeclaration cd = en.addConstructor();
    cd.addParameter(underlyingType, VALUE);
    cd.createBody();

    cd.setBody(
        new BlockStmt()
            .addStatement(
                new AssignExpr(
                    new NameExpr("this." + VALUE),
                    new NameExpr(VALUE),
                    AssignExpr.Operator.ASSIGN)));

    MethodDeclaration getValue = en
        .addMethod("getValue", Modifier.Keyword.PUBLIC);
    getValue.setType(underlyingType);
    getValue
        .setBody(new BlockStmt().addStatement(new ReturnStmt(VALUE)));
    getValue.addAnnotation("com.fasterxml.jackson.annotation.JsonValue");

    Set<String> constantNames = new HashSet<>(values.size());
    for (String k : values) {
      StringBuilder constantNameBuilder = new StringBuilder();
      try {
        // If the value can be parsed as an Integer
        Integer.valueOf(k);
        // Prepend
        constantNameBuilder.append("V_" + sanitizeEnumEntry(sanitizeString(k)));
      } catch (Exception e) {
        constantNameBuilder.append(sanitizeEnumEntry(sanitizeString(k)));
      }
      // enums with colliding names are bad practice, we should make sure that the resulting code compiles,
      // but we don't need fancy heuristics for the naming let's just prepend an underscore until it works
      while (constantNames.contains(constantNameBuilder.toString())) {
        String tmp = constantNameBuilder.toString();
        constantNameBuilder.setLength(0);
        constantNameBuilder.append("_" + tmp);
      }
      String constantName = constantNameBuilder.toString();
      constantNames.add(constantName);

      String originalName = AbstractJSONSchema2Pojo.escapeQuotes(k);
      Expression valueArgument = new StringLiteralExpr(originalName);
      if (!underlyingType.equals(JAVA_LANG_STRING)) {
        if (underlyingType.equals(JAVA_LANG_LONG) && !originalName.endsWith("L")) {
          valueArgument = new IntegerLiteralExpr(originalName + "L");
        } else {
          valueArgument = new IntegerLiteralExpr(originalName);
        }
      }

      EnumConstantDeclaration decl = new EnumConstantDeclaration();
      decl.addAnnotation(
          new SingleMemberAnnotationExpr(
              new Name("com.fasterxml.jackson.annotation.JsonProperty"),
              new StringLiteralExpr(originalName)));
      decl.setName(constantName);
      decl.addArgument(valueArgument);
      en.addEntry(decl);
    }

    return new GeneratorResult(
        new ArrayList<>(),
        Collections.singletonList(new GeneratorResult.ClassResult(this.type, cu)));
  }
}

    String ret = str;
    if (config.isUppercaseEnums()) {
      ret = ret.toUpperCase(Locale.ROOT);
    }
    if (ret.isEmpty()) {
      return "_EMPTY";
    } else {
      return ret.replaceAll("[\\s|\\./]", "_");
    }
  
<methods>public static java.lang.String escapeQuotes(java.lang.String) ,public static io.fabric8.java.generator.nodes.AbstractJSONSchema2Pojo fromJsonSchema(java.lang.String, JSONSchemaProps, java.lang.String, io.fabric8.java.generator.Config) ,public abstract io.fabric8.java.generator.nodes.GeneratorResult generateJava() ,public java.lang.String getDescription() ,public java.lang.Double getMaximum() ,public java.lang.Double getMinimum() ,public java.lang.String getPattern() ,public abstract java.lang.String getType() ,public static final AnnotationExpr newGeneratedAnnotation() ,public static java.lang.String packageName(java.lang.String) ,public static java.lang.String sanitizeString(java.lang.String) <variables>static final java.lang.String ARRAY_CRD_TYPE,static final java.lang.String BOOLEAN_CRD_TYPE,static final java.lang.String DATETIME_CRD_TYPE,static final java.lang.String DOUBLE_CRD_TYPE,static final java.lang.String FLOAT_CRD_TYPE,static final java.lang.String INT32_CRD_TYPE,static final java.lang.String INT64_CRD_TYPE,static final java.lang.String INTEGER_CRD_TYPE,static final java.lang.String NUMBER_CRD_TYPE,static final java.lang.String OBJECT_CRD_TYPE,static final java.lang.String STRING_CRD_TYPE,protected final non-sealed io.fabric8.java.generator.Config config,protected final non-sealed JsonNode defaultValue,protected final non-sealed java.lang.String description,protected final non-sealed boolean isNullable,protected java.lang.Double maximum,protected java.lang.Double minimum,protected java.lang.String pattern