Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public record ResolvedType(
boolean isMap,
boolean isList,
boolean isOptional,
boolean isSecret,
boolean isDeclared,
boolean isInterface,
boolean isClass,
Expand All @@ -36,14 +37,14 @@ public final String toString() {

public static ResolvedType ofPrimitive(TypeMirror unwrappedType, String typeName) {
return new ResolvedType(unwrappedType, unwrappedType, typeName, typeName, typeName, true, false, false,
false, false, false, false, false, false, false);
false, false, false, false, false, false, false, false);
}

public static ResolvedType ofDeclaredType(TypeMirror type, String binaryName,
String qualifiedName, String simpleName,
boolean isInterface, boolean isClass, boolean isEnum, boolean isDuration, boolean isConfigGroup) {
return new ResolvedType(type, type, binaryName, qualifiedName, simpleName, false, false, false, false, true,
isInterface, isClass, isEnum, isDuration, isConfigGroup);
return new ResolvedType(type, type, binaryName, qualifiedName, simpleName, false, false, false, false, false,
true, isInterface, isClass, isEnum, isDuration, isConfigGroup);
}

public static ResolvedType makeList(TypeMirror type, ResolvedType unwrappedResolvedType) {
Expand All @@ -52,6 +53,7 @@ public static ResolvedType makeList(TypeMirror type, ResolvedType unwrappedResol
unwrappedResolvedType.isPrimitive,
unwrappedResolvedType.isMap, true,
unwrappedResolvedType.isOptional,
unwrappedResolvedType.isSecret,
unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass,
unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup);
}
Expand All @@ -62,6 +64,18 @@ public static ResolvedType makeOptional(ResolvedType unwrappedResolvedType) {
unwrappedResolvedType.isPrimitive,
unwrappedResolvedType.isMap, unwrappedResolvedType.isList,
true,
unwrappedResolvedType.isSecret,
unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass,
unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup);
}

public static ResolvedType makeSecret(ResolvedType unwrappedResolvedType) {
return new ResolvedType(unwrappedResolvedType.wrapperType, unwrappedResolvedType.unwrappedType,
unwrappedResolvedType.binaryName, unwrappedResolvedType.qualifiedName, unwrappedResolvedType.simplifiedName,
unwrappedResolvedType.isPrimitive,
unwrappedResolvedType.isMap, unwrappedResolvedType.isList,
unwrappedResolvedType.isOptional,
true,
unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass,
unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup);
}
Expand All @@ -72,6 +86,7 @@ public static ResolvedType makeMap(TypeMirror type, ResolvedType unwrappedResolv
unwrappedResolvedType.isPrimitive,
true, false,
unwrappedResolvedType.isOptional,
unwrappedResolvedType.isSecret,
unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass,
unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public final class ConfigProperty extends AbstractConfigItem {
private final boolean map;
private final boolean list;
private final boolean optional;
private final boolean secret;
private final String mapKey;
private final boolean unnamedMapKey;
private final boolean withinMap;
Expand All @@ -31,7 +32,7 @@ public final class ConfigProperty extends AbstractConfigItem {

public ConfigProperty(ConfigPhase phase, String sourceType, String sourceElementName, SourceElementType sourceElementType,
PropertyPath path, List<PropertyPath> additionalPaths, String type, String typeDescription, boolean map,
boolean list, boolean optional,
boolean list, boolean optional, boolean secret,
String mapKey, boolean unnamedMapKey, boolean withinMap, boolean converted, @JsonProperty("enum") boolean isEnum,
EnumAcceptedValues enumAcceptedValues,
String defaultValue, String javadocSiteLink,
Expand All @@ -43,6 +44,7 @@ public ConfigProperty(ConfigPhase phase, String sourceType, String sourceElement
this.map = map;
this.list = list;
this.optional = optional;
this.secret = secret;
this.mapKey = mapKey;
this.unnamedMapKey = unnamedMapKey;
this.withinMap = withinMap;
Expand Down Expand Up @@ -87,6 +89,10 @@ public boolean isOptional() {
return optional;
}

public boolean isSecret() {
return secret;
}

public String getMapKey() {
return mapKey;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ private void resolveProperty(ConfigRoot configRoot, Map<String, ConfigSection> e

String potentiallyMappedPath = path;
boolean optional = discoveryConfigProperty.getType().isOptional();
boolean secret = discoveryConfigProperty.getType().isSecret();

if (discoveryConfigProperty.getType().isMap()) {
// it is a leaf pass through map, it is always optional
Expand Down Expand Up @@ -208,7 +209,7 @@ private void resolveProperty(ConfigRoot configRoot, Map<String, ConfigSection> e
propertyPath, additionalPropertyPaths,
typeQualifiedName, typeSimplifiedName,
discoveryConfigProperty.getType().isMap(), discoveryConfigProperty.getType().isList(),
optional, discoveryConfigProperty.getMapKey(),
optional, secret, discoveryConfigProperty.getMapKey(),
discoveryConfigProperty.isUnnamedMapKey(), context.isWithinMap(),
discoveryConfigProperty.isConverted(),
discoveryConfigProperty.getType().isEnum(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ private ResolvedType resolveType(TypeMirror typeMirror) {
String qualifiedName = typeElement.getQualifiedName().toString();

boolean optional = qualifiedName.startsWith(Optional.class.getName());
boolean secret = qualifiedName.startsWith("io.smallrye.config.Secret");
boolean map = qualifiedName.equals(Map.class.getName());
boolean list = qualifiedName.equals(List.class.getName())
|| qualifiedName.equals(Set.class.getName());
Expand All @@ -327,6 +328,8 @@ private ResolvedType resolveType(TypeMirror typeMirror) {
// let's resolve the type
if (typeArguments.size() == 1 && optional) {
return ResolvedType.makeOptional(resolveType(typeArguments.get(0)));
} else if (typeArguments.size() == 1 && secret) {
return ResolvedType.makeSecret(resolveType(typeArguments.get(0)));
} else if (typeArguments.size() == 1 && list) {
return ResolvedType.makeList(typeMirror, resolveType(typeArguments.get(0)));
} else if (typeArguments.size() == 2 && map) {
Expand Down
Loading