use of io.sundr.model.PropertyFluent in project sundrio by sundrio.
the class ApplyTypeParamMappingToProperty method visit.
@Override
public void visit(PropertyFluent<?> property) {
TypeRef typeRef = property.buildTypeRef();
if (typeRef instanceof TypeParamRef) {
TypeParamRef typeParamRef = (TypeParamRef) typeRef;
String key = typeParamRef.getName();
TypeRef paramRef = mappings.get(key);
if (paramRef != null) {
property.withTypeRef(paramRef);
attributeKey.ifPresent(k -> property.addToAttributes(k, typeParamRef));
}
} else if (typeRef instanceof ClassRef) {
ClassRef classRef = (ClassRef) typeRef;
if (classRef.getArguments().stream().anyMatch(a -> a instanceof TypeParamRef)) {
List<TypeRef> mappedArguments = classRef.getArguments().stream().map(a -> a instanceof TypeParamRef ? mappings.getOrDefault(((TypeParamRef) a).getName(), a) : a).collect(Collectors.toList());
property.withTypeRef(new ClassRefBuilder(classRef).withArguments(mappedArguments).build());
attributeKey.ifPresent(k -> property.addToAttributes(k, classRef));
}
}
}
Aggregations