net.nullschool.grains.generate.factory_enum.stg Maven / Gradle / Ivy
The newest version!
group FactoryEnum;
typePolicy_decl(grain, type) ::= <<
private static final $POLICY = ;
>>
typeToken_decl(typeToken, type) ::= <<
private static final \<\> =
new \<\>(){};
>>
transform_decl(typeToken, type) ::= <<
private static final \<\> =
$POLICY.newTransform();
>>
grain_prop(prop, type) ::= <<
new (<\\>
"", <\\>
.asType().class<\\>
}>)
>>
factory_enum(grain, type) ::= <<
/**
* Factory for constructing Grain instances of .
*/
@("")
public enum implements {
INSTANCE;
private static final $PROPERTIES = .asPropertyMap(
);
private static final [] $KEYS = $PROPERTIES.keySet().toArray(new []);
private static final $DEFAULT = newBuilder().build();
public static defaultValue() { return $DEFAULT; }
public static newBuilder() { return new (); }
public getBasisProperties() { return $PROPERTIES; }
public getDefaultValue() { return defaultValue(); }
public getNewBuilder() { return newBuilder(); }
public toString() { return getClass().getName(); }
}
>>