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);
}
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));
}
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));
}
Aggregations