/** * Copy constructor. * * @param prototype the prototype */ protected EnumImpl(Enum prototype) { super (prototype); constants = Copier.copy(prototype.getConstants()); constructors = Copier.copy(prototype.getConstructors()); }
final Enum colEnum = Enum.of(shortName(colEnumName)) .add(Field.of(DATABASE_NAME, String.class) .private_().final_() ).add(Field.of(DATABASE_ORDINAL, int.class) .private_().final_() ); )); colEnum.add(enumConstant); colEnum.add(Constructor.of() .add(Field.of(DATABASE_NAME, String.class)) .add(Field.of(DATABASE_ORDINAL, int.class)) .add("}"); colEnum.add(fromDatabase); colEnum.add(fromDatabaseOrdinal); colEnum.add(Method.of(TO_DATABASE_METHOD, String.class) .public_().add("return " + DATABASE_NAME + ";") ); colEnum.add(Method.of(TO_DATABASE_ORDINAL_METHOD, int.class) .public_().add("return " + DATABASE_ORDINAL + ";") );
/** * Adds the specified constant to this enum. The constant must not be null. * * @param constant the constant * @return a reference to this model */ default Enum add(EnumConstant constant) { getConstants().add(requireNonNull(constant)); return this; }
@Override protected String renderConstructors(Generator gen, Enum model) { requireNonNulls(gen, model); return gen.onEach(model.getConstructors()) .collect(joining(dnl())); } }
final Enum identifierEnum = Enum.of(IDENTIFIER_NAME) .add(Field.of("columnId", String.class).private_().final_()) .add(Field.of("tableIdentifier", tableIdentifierType).private_().final_()) .add(SimpleParameterizedType.create(ColumnIdentifier.class, getSupport().entityType())) .add(Constructor.of() .add(Field.of("columnId", String.class)) .add("this.columnId\t = columnId;") .add(Method.of("getDbmsId", String.class).public_() .add(OVERRIDE) .add(returnString(getSupport().dbmsOrThrow().getId())) .add(Method.of("getSchemaId", String.class).public_() .add(OVERRIDE) .add(returnString(getSupport().schemaOrThrow().getId())) .add(Method.of("getTableId", String.class).public_() .add(OVERRIDE) .add(returnString(getSupport().tableOrThrow().getId())) .add(Method.of("getColumnId", String.class).public_() .add(OVERRIDE) .add("return this.columnId;") .add(Method.of("asTableIdentifier", tableIdentifierType).public_() .add(OVERRIDE) .add("return this.tableIdentifier;") identifierEnum.add(EnumConstant.of(constant).add(Value.ofText(col.getId())));
@Override protected String onBeforeFields(Generator gen, Enum model) { requireNonNulls(gen, model); final List<String> constants = model.getConstants().stream() .map(c -> gen.on(c).get()).collect(toList()); Formatting.alignTabs(constants); return constants.stream().collect( joinIfNotEmpty( (!model.getConstants().isEmpty() && (!model.getConstants().get(0).getValues().isEmpty() || !model.getConstants().get(0).getAnnotations().isEmpty())) ? "," + nl() : ", ", "", ";" ) ); }
@Override protected String renderConstructors(Generator gen, Enum model) { requireNonNulls(gen, model); return gen.onEach(model.getConstructors()) .collect(joining(dnl())); } }
/** * Copy constructor. * * @param prototype the prototype */ protected EnumImpl(Enum prototype) { super (prototype); constants = Copier.copy(prototype.getConstants()); constructors = Copier.copy(prototype.getConstructors()); }
final Enum identifierEnum = Enum.of(IDENTIFIER_NAME) .add(Field.of("columnId", String.class).private_().final_()) .add(Field.of("tableIdentifier", tableIdentifierType).private_().final_()) .add(SimpleParameterizedType.create(ColumnIdentifier.class, getSupport().entityType())) .add(Constructor.of() .add(Field.of("columnId", String.class)) .add("this.columnId\t = columnId;") .add(Method.of("getDbmsId", String.class).public_() .add(OVERRIDE) .add(returnString(getSupport().dbmsOrThrow().getId())) .add(Method.of("getSchemaId", String.class).public_() .add(OVERRIDE) .add(returnString(getSupport().schemaOrThrow().getId())) .add(Method.of("getTableId", String.class).public_() .add(OVERRIDE) .add(returnString(getSupport().tableOrThrow().getId())) .add(Method.of("getColumnId", String.class).public_() .add(OVERRIDE) .add("return this.columnId;") .add(Method.of("asTableIdentifier", tableIdentifierType).public_() .add(OVERRIDE) .add("return this.tableIdentifier;") identifierEnum.add(EnumConstant.of(constant).add(Value.ofText(col.getId())));
((Enum) model).getConstants() .forEach(ec -> findTypesIn(ec, types));
@Override protected String renderConstructors(Generator gen, Enum model) { requireNonNulls(gen, model); return gen.onEach(model.getConstructors()) .collect(joining(dnl())); } }
/** * Copy constructor. * * @param prototype the prototype */ protected EnumImpl(Enum prototype) { super (prototype); constants = Copier.copy(prototype.getConstants()); constructors = Copier.copy(prototype.getConstructors()); }
/** * Adds the specified constant to this enum. The constant must not be null. * * @param constant the constant * @return a reference to this model */ default Enum add(EnumConstant constant) { getConstants().add(requireNonNull(constant)); return this; }
/** * Adds the specified constant to this enum. The constant must not be null. * * @param constant the constant * @return a reference to this model */ default Enum add(EnumConstant constant) { getConstants().add(requireNonNull(constant)); return this; }
@Override protected String onBeforeFields(Generator gen, Enum model) { requireNonNulls(gen, model); final List<String> constants = model.getConstants().stream() .map(c -> gen.on(c).get()).collect(toList()); Formatting.alignTabs(constants); return constants.stream().collect( joinIfNotEmpty( (!model.getConstants().isEmpty() && (!model.getConstants().get(0).getValues().isEmpty() || !model.getConstants().get(0).getAnnotations().isEmpty())) ? "," + nl() : ", ", "", ";" ) ); }
@Override protected String onBeforeFields(Generator gen, Enum model) { requireNonNulls(gen, model); final List<String> constants = model.getConstants().stream() .map(c -> gen.on(c).get()).collect(toList()); Formatting.alignTabs(constants); return constants.stream().collect( joinIfNotEmpty( (!model.getConstants().isEmpty() && !model.getConstants().get(0).getValues().isEmpty()) ? "," + nl() : ", ", "", ";" ) ); }
((Enum) model).getConstants() .forEach(ec -> findTypesIn(ec, types));