use of io.sundr.model.ClassRef in project sundrio by sundrio.
the class SimpleClassWithInheritanceTest method testEditable.
@Test
public void testEditable() {
TypeDef editable = ClazzAs.EDITABLE.apply(simpleClassWithDateDef);
System.out.println(editable);
assertEquals(Kind.CLASS, editable.getKind());
assertEquals("EditableSimpleClassWithDate", editable.getName());
assertEquals(1, editable.getExtendsList().size());
ClassRef superClass = editable.getExtendsList().iterator().next();
assertEquals(simpleClassWithDateDef.toInternalReference(), superClass);
}
use of io.sundr.model.ClassRef in project sundrio by sundrio.
the class SimpleClassWithParameterTest method testEditable.
@Test
public void testEditable() {
TypeDef editable = ClazzAs.EDITABLE.apply(simpleClassWithParameterDef);
System.out.println(editable);
assertEquals(Kind.CLASS, editable.getKind());
assertEquals("EditableSimpleClassWithParameter", editable.getName());
assertEquals(1, editable.getExtendsList().size());
ClassRef superClass = editable.getExtendsList().iterator().next();
assertEquals(simpleClassWithParameterDef.toInternalReference(), superClass);
}
use of io.sundr.model.ClassRef in project sundrio by sundrio.
the class SimpleClassWithParameterTest method testFluentImpl.
@Test
public void testFluentImpl() {
TypeDef fluentImpl = ClazzAs.FLUENT_IMPL.apply(simpleClassWithParameterDef);
System.out.println(fluentImpl);
assertEquals(Kind.CLASS, fluentImpl.getKind());
assertEquals("SimpleClassWithParameterFluentImpl", fluentImpl.getName());
assertEquals(1, fluentImpl.getExtendsList().size());
ClassRef superClass = fluentImpl.getExtendsList().iterator().next();
assertEquals("BaseFluent", superClass.getName());
assertEquals(1, superClass.getArguments().size());
assertEquals("A", superClass.getArguments().iterator().next().toString());
}
use of io.sundr.model.ClassRef in project sundrio by sundrio.
the class ApplyTypeParamMappingToMethod method visit.
@Override
public void visit(MethodFluent<?> method) {
TypeRef typeRef = method.buildReturnType();
if (typeRef instanceof TypeParamRef) {
TypeParamRef typeParamRef = (TypeParamRef) typeRef;
String key = typeParamRef.getName();
TypeRef paramRef = mappings.get(key);
if (paramRef != null) {
method.withReturnType(paramRef);
attributeKey.ifPresent(k -> method.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());
method.withReturnType(new ClassRefBuilder(classRef).withArguments(mappedArguments).build());
attributeKey.ifPresent(k -> method.addToAttributes(k, classRef));
}
}
}
use of io.sundr.model.ClassRef in project sundrio by sundrio.
the class ReplacePackage method visitPropertyBuilder.
private void visitPropertyBuilder(PropertyBuilder builder) {
if (builder.getTypeRef() instanceof ClassRef) {
ClassRefBuilder classRefBuilder = new ClassRefBuilder((ClassRef) builder.getTypeRef());
builder.withTypeRef(classRefBuilder.accept(visitor, this).build());
}
}
Aggregations