public TypeDef getInlineableInterface(Inline inline) { return new TypeDefBuilder(inlineableBase) .withKind(Kind.INTERFACE) .withPackageName(builderPackage) .withName(inline.prefix() + (!inline.name().isEmpty() ? inline.name() : INLINEABLE.getName()) + inline.suffix()) .withParameters(INLINEABLE.getParameters()) .addNewMethod() .withReturnType(TypeUtils.newTypeParamRef("T")) .withName(inline.value()) .and() .build(); }
JavaClazz inlineableOf(BuilderContext ctx, JavaClazz clazz, Inline inline) { JavaClazz base = ClazzAs.INLINEABLE.apply(clazz); JavaType baseInterface = typeGenericOf(BuilderUtils.getInlineType(ctx, inline), clazz.getType()); JavaMethod method = new JavaMethodBuilder(base.getMethods().iterator().next()).withName(inline.value()).build(); JavaType fluent = TypeAs.SHALLOW_FLUENT.apply(clazz.getType()); JavaType shallowInlineType = new JavaTypeBuilder(base.getType()) .withClassName(inline.prefix() + base.getType().getClassName() + inline.suffix()) .addToInterfaces(baseInterface) .build(); JavaType inlineType = new JavaTypeBuilder(shallowInlineType) .withSuperClass(typeGenericOf(fluent, shallowInlineType)) .build(); Set<JavaMethod> constructors = new LinkedHashSet<JavaMethod>(); for (JavaMethod constructor : base.getConstructors()) { constructors.add(new JavaMethodBuilder(constructor).withReturnType(inlineType).build()); } return new JavaClazzBuilder(base) .withType(inlineType) .withConstructors(constructors) .withMethods(new HashSet<JavaMethod>(Arrays.asList(method))) .build(); } }
public JavaClazz getInlineableInterface(Inline inline) { return new JavaClazzBuilder() .withNewType() .withKind(JavaKind.INTERFACE) .withPackageName(builderPackage) .withClassName(inline.prefix() + INLINEABLE.getClassName() + inline.suffix()) .withGenericTypes(INLINEABLE.getGenericTypes()) .and() .addNewMethod() .withReturnType(T) .withName(inline.value()) .and() .build(); }
.withName(inline.value()) .withNewBlock() .addNewStringStatementStatement(BUILD_AND_APPLY_FUNCTION)