@Override public void accept(Class aClass) { aClass.add(Constructor.newPublic() .call(constr -> aClass.getFields().stream() .filter(f -> f.getModifiers().contains(FINAL)) .map(Field::copy) .peek(f -> f.getModifiers().clear()) .forEachOrdered(f -> { constr.add(f).imports(Objects.class, "requireNonNull"); if (isPrimitive(f.getType())) { constr.add(format("this.%1$s = %1$s;", f.getName())); } else { constr.add(format("this.%1$s = requireNonNull(%1$s);", f.getName())); } }) ) ); } }
@Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getClassOrInterfaceName()) .forEveryProject((clazz, project) -> { clazz.public_() .setSupertype(AbstractSpeedment.class) .add(generatedType()); }).build(); }
@Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getClassOrInterfaceName()) .forEveryProject((clazz, project) -> clazz.public_().final_() .setSupertype(generatedImplType()) .add(applicationType()) ).build(); }
getSupport().entityType() )) .add(getSupport().generatedManagerType()) .add(Field.of("tableIdentifier", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType())).private_().final_()) .add(Constructor.of().protected_() .add("this.tableIdentifier = " + TableIdentifier.class.getSimpleName() + ".of(" + Stream.of(getSupport().dbmsOrThrow().getId(), getSupport().schemaOrThrow().getId(), getSupport().tableOrThrow().getId()) + ");") .add(Method.of("getTableIdentifier", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType())) .public_().add(OVERRIDE) .add("return tableIdentifier;") .add( Method.of(FIELDS_METHOD, DefaultType.stream( .add("return " + getSupport().managerName() + ".FIELDS.stream();") .add(generateFields(getSupport(), file, PRIMARY_KEYS_FIELDS_METHOD, () -> table.primaryKeyColumns() .sorted(comparing(PrimaryKeyColumn::getOrdinalPosition))
.add( SimpleParameterizedType.create( SqlAdapter.class, .add(Constructor.of().protected_() .add("this.tableIdentifier = " + TableIdentifier.class.getSimpleName() + ".of(" .add(Field.of("tableIdentifier", tableIdentifierType).private_().final_()) .add(generateApplyResultSet(getSupport(), file, table::columns)) .add(generateCreateEntity(file)) .add( Method.of("identifier", tableIdentifierType) .public_() .add( Method.of("entityMapper", SimpleParameterizedType.create(SqlFunction.class, ResultSet.class, getSupport().entityType())) .public_() .add( Method.of("entityMapper", SimpleParameterizedType.create(SqlFunction.class, ResultSet.class, getSupport().entityType())) .public_() .noneMatch(CREATE_HELPERS_METHOD_NAME::equals)) { file.add(Import.of(Project.class)); clazz.add(createHelpers); clazz.add(Field.of(tmsName, tmsType).private_());
@Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getSupport().entityImplName()).build() .public_().final_() .add(getSupport().entityType()) .setSupertype(getSupport().generatedEntityImplType()); }
@Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getSupport().managerImplName()) .forEveryTable((clazz, table) -> clazz.public_().final_() .setSupertype(getSupport().generatedManagerImplType()) .add(getSupport().managerType()) ).build(); }
clazz.public_() .abstract_() .add(getSupport().entityType()) .add(Constructor.of().protected_()) .add(fieldFor(col).private_()) .add(Method.of(GETTER_METHOD_PREFIX + getSupport().typeName(col), retType) .public_().add(OVERRIDE) .add("return " + getter + ";")); .add(Method.of(SETTER_METHOD_PREFIX + getSupport().typeName(col), getSupport().entityType()) .public_() .add(OVERRIDE) final String getterName = optionalGetterName(typeMappers, col).orElse(""); clazz.add(Method.of(FINDER_METHOD_PREFIX + getSupport().typeName(col), col.isNullable() ? DefaultType.optional(fuSupport.entityType()) .add(toStringMethod(file)) .add(equalsMethod()) .add(hashCodeMethod(file))
@Override public void accept(Class aClass) { aClass.add(Constructor.newPublic() .call(constr -> aClass.getFields().stream() .filter(f -> f.getModifiers().contains(FINAL)) .map(Field::copy) .peek(f -> f.getModifiers().clear()) .forEachOrdered(f -> { constr.add(f).imports(Objects.class, "requireNonNull"); if (isPrimitive(f.getType())) { constr.add(format("this.%1$s = %1$s;", f.getName())); } else { constr.add(format("this.%1$s = requireNonNull(%1$s);", f.getName())); } }) ) ); } }
@Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getClassOrInterfaceName()) .forEveryProject((clazz, project) -> { clazz.public_() .setSupertype(AbstractSpeedment.class) .add(generatedType()); }).build(); }
@Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getClassOrInterfaceName()) .forEveryProject((clazz, project) -> clazz.public_().final_() .setSupertype(generatedImplType()) .add(applicationType()) ).build(); }
getSupport().entityType() )) .add(getSupport().generatedManagerType()) .add(Field.of("tableIdentifier", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType())).private_().final_()) .add(Constructor.of().protected_() .add("this.tableIdentifier = " + TableIdentifier.class.getSimpleName() + ".of(" + Stream.of(getSupport().dbmsOrThrow().getId(), getSupport().schemaOrThrow().getId(), getSupport().tableOrThrow().getId()) + ");") .add(Method.of("getTableIdentifier", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType())) .public_().add(OVERRIDE) .add("return tableIdentifier;") .add( Method.of(FIELDS_METHOD, DefaultType.stream( .add("return " + getSupport().managerName() + ".FIELDS.stream();") .add(generateFields(getSupport(), file, PRIMARY_KEYS_FIELDS_METHOD, () -> table.primaryKeyColumns() .sorted(comparing(PrimaryKeyColumn::getOrdinalPosition))
@Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getSupport().entityImplName()).build() .public_().final_() .add(getSupport().entityType()) .setSupertype(getSupport().generatedEntityImplType()); }
@Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getSupport().managerImplName()) .forEveryTable((clazz, table) -> clazz.public_().final_() .setSupertype(getSupport().generatedManagerImplType()) .add(getSupport().managerType()) ).build(); }