public class TestPropertiesEnum_References {
public static final String APP_NAME = "dk.greentape.library.spring.totype.test.TestPropertiesEnum#APP_NAME";
public static final String APP_VERSION = "dk.greentape.library.spring.totype.test.TestPropertiesEnum#APP_VERSION";
public static final String APP_DEBUG = "dk.greentape.library.spring.totype.test.TestPropertiesEnum#APP_DEBUG";
}
@Getter
@Configuration
public class TestConfiguration {
// Test @ValueToTypeClass - simplest pattern
@ValueToTypeClass(
value = "${test.server.port}",
toTypeClass = IntegerToType.class
)
private Integer serverPort;
@ValueToTypeClass(
value = "${test.server.hostname}",
toTypeClass = StringToType.class
)
private String serverHostname;
@ValueToTypeClass(
value = "${test.server.timeout}",
toTypeClass = IntegerToType.class,
defaultValue = "60"
)
private Integer serverTimeout;
// Test @ValueToType - enum-based pattern
@ValueToType(
value = "${test.database.maxConnections}",
enumEntryReference = TestToTypesEnum_References.MAX_CONNECTIONS
)
private Integer maxConnections;
@ValueToType(
value = "${test.database.schema}",
enumEntryReference = TestToTypesEnum_References.SCHEMA_NAME
)
private String schemaName;
// Test @ValueToTypeProperty - most sophisticated pattern
@ValueToTypeProperty(
enumEntryReference = TestPropertiesEnum_References.APP_NAME
)
private String appName;
@ValueToTypeProperty(
enumEntryReference = TestPropertiesEnum_References.APP_VERSION
)
private String appVersion;
@ValueToTypeProperty(
enumEntryReference = TestPropertiesEnum_References.APP_DEBUG
)
private Boolean appDebug;
}
What I would like
@Getter
@RequiredArgsConstructor
@GenerateEnumReferences
public enum TestToTypesEnum implements ToTypeDefinitionEnum {
MAX_CONNECTIONS(new ToTypeDefinition(
IntegerToType.class,
new IntegerToType(1, 1000),
ToTypeReturn.simple(Integer.class),
null,
List.of(Integer.class)
)),
SCHEMA_NAME(new ToTypeDefinition(
StringToType.class,
new StringToType(1, 100),
ToTypeReturn.simple(String.class),
null,
List.of(String.class)
));
private final ToTypeDefinition definition;
@Override
public String getEnumEntryName() {
return name();
}
}
Would genererate
@Getter
@RequiredArgsConstructor
@GenerateEnumReferences
public enum TestToTypesEnum implements ToTypeDefinitionEnum {
MAX_CONNECTIONS(new ToTypeDefinition(
IntegerToType.class,
new IntegerToType(1, 1000),
ToTypeReturn.simple(Integer.class),
null,
List.of(Integer.class)
)),
SCHEMA_NAME(new ToTypeDefinition(
StringToType.class,
new StringToType(1, 100),
ToTypeReturn.simple(String.class),
null,
List.of(String.class)
));
private final ToTypeDefinition definition;
@Override
public String getEnumEntryName() {
return name();
}
public static class References {