Search in sources :

Example 1 with Inline

use of io.sundr.builder.annotations.Inline in project sundrio by sundrio.

the class AbstractBuilderProcessor method generateBuildables.

public void generateBuildables(BuilderContext ctx, Set<TypeDef> buildables) {
    int total = ctx.getBuildableRepository().getBuildables().size();
    int count = 0;
    for (TypeDef typeDef : buildables) {
        RichTypeDef richTypeDef = TypeArguments.apply(typeDef);
        double percentage = 100d * (count++) / total;
        if (typeDef.isInterface() || typeDef.isAnnotation()) {
            continue;
        }
        System.err.printf("\033[2K%3d%% Generating: %s\r", Math.round(percentage), typeDef.getFullyQualifiedName());
        generate(ClazzAs.FLUENT_INTERFACE.apply(richTypeDef));
        generate(ClazzAs.FLUENT_IMPL.apply(richTypeDef));
        if (typeDef.isAbstract()) {
            continue;
        }
        if (!typeDef.isFinal() && typeDef.getAttributes().containsKey(EDITABLE_ENABLED) && (Boolean) typeDef.getAttributes().get(EDITABLE_ENABLED)) {
            generate(ClazzAs.EDITABLE_BUILDER.apply(richTypeDef));
            generate(ClazzAs.EDITABLE.apply(richTypeDef));
        } else {
            generate(ClazzAs.BUILDER.apply(richTypeDef));
        }
        Buildable buildable = typeDef.getAttribute(BUILDABLE);
        ExternalBuildables externalBuildables = typeDef.getAttribute(EXTERNAL_BUILDABLE);
        if (buildable != null) {
            for (final Inline inline : buildable.inline()) {
                generate(inlineableOf(ctx, typeDef, inline));
            }
        } else if (externalBuildables != null) {
            for (final Inline inline : externalBuildables.inline()) {
                generate(inlineableOf(ctx, typeDef, inline));
            }
        }
    }
}
Also used : RichTypeDef(io.sundr.model.RichTypeDef) TypeDef(io.sundr.model.TypeDef) ExternalBuildables(io.sundr.builder.annotations.ExternalBuildables) Inline(io.sundr.builder.annotations.Inline) Buildable(io.sundr.builder.annotations.Buildable) RichTypeDef(io.sundr.model.RichTypeDef)

Aggregations

Buildable (io.sundr.builder.annotations.Buildable)1 ExternalBuildables (io.sundr.builder.annotations.ExternalBuildables)1 Inline (io.sundr.builder.annotations.Inline)1 RichTypeDef (io.sundr.model.RichTypeDef)1 TypeDef (io.sundr.model.TypeDef)1