Search in sources :

Example 1 with Naming

use of org.immutables.generator.Naming in project immutables by immutables.

the class Constitution method typeImmutableEnclosingSimpleName.

/**
   * Walks to the enclosing type's simple names and applies naming convention.
   * This shortcut/fix shows deficiency of model (it's probably more complicated than needed).
   * @return enclosing immutable name
   */
@Value.Lazy
String typeImmutableEnclosingSimpleName() {
    DeclaringType declaringType = protoclass().enclosingOf().get();
    String enclosingSimpleName = declaringType.element().getSimpleName().toString();
    String enclosingRawName = names().rawFromAbstract(enclosingSimpleName);
    // Here we checking for having both enclosing and value
    // if we had protoclass it would be kind().isEnclosing() && kind().isValue()
    Naming naming = declaringType.isImmutable() ? names().namings.typeImmutable : names().namings.typeImmutableEnclosing;
    return naming.apply(enclosingRawName);
}
Also used : DeclaringType(org.immutables.value.processor.meta.Proto.DeclaringType) PackageNaming(org.immutables.value.processor.meta.Styles.PackageNaming) Naming(org.immutables.generator.Naming)

Example 2 with Naming

use of org.immutables.generator.Naming in project immutables by immutables.

the class Constitution method typeBuilderSimpleName.

private String typeBuilderSimpleName() {
    boolean isOutside = isOutsideBuilder();
    Naming typeBuilderNaming = names().namings.typeBuilder;
    if (isOutside) {
        // For outer builder we can override with constant builder naming, but not the default.
        boolean isPlainDefault = isConstantNamingEquals(typeBuilderNaming, protoclass().environment().defaultStyles().typeBuilder());
        if (isPlainDefault) {
            typeBuilderNaming = typeBuilderNaming.requireNonConstant(Preference.SUFFIX);
        }
    }
    return Naming.Usage.CAPITALIZED.apply(typeBuilderNaming.apply(names().raw));
}
Also used : PackageNaming(org.immutables.value.processor.meta.Styles.PackageNaming) Naming(org.immutables.generator.Naming)

Example 3 with Naming

use of org.immutables.generator.Naming in project immutables by immutables.

the class Constitution method factoryImplementationBuilder.

private AppliedNameForms factoryImplementationBuilder() {
    boolean isOutside = isOutsideBuilder();
    Naming methodBuilderNaming = isOutside ? names().namings.newBuilder : names().namings.builder;
    boolean haveConstructorOnBuilder = isOutside || isConstantNamingEquals(methodBuilderNaming, NEW_KEYWORD);
    NameForms typeNameForms = haveConstructorOnBuilder ? typeBuilder() : typeImmutable();
    return typeNameForms.applied(methodBuilderNaming.apply(names().raw));
}
Also used : PackageNaming(org.immutables.value.processor.meta.Styles.PackageNaming) Naming(org.immutables.generator.Naming)

Aggregations

Naming (org.immutables.generator.Naming)3 PackageNaming (org.immutables.value.processor.meta.Styles.PackageNaming)3 DeclaringType (org.immutables.value.processor.meta.Proto.DeclaringType)1