use of com.github.sviperll.adt4j.Caching in project adt4j by sviperll.
the class ValueClassConfiguration method createInstance.
public static GenerationResult<ValueClassConfiguration> createInstance(VisitorDefinition visitorDefinition, JAnnotationUse annotation, JDefinedClass valueClass) {
GenerationProcess generation = new GenerationProcess();
String acceptMethodName = annotation.getParam("acceptMethodName", String.class);
MemberAccess acceptMethodAccess = annotation.getParam("acceptMethodAccess", MemberAccess.class);
boolean isPublic = annotation.getParam("isPublic", Boolean.class);
Caching hashCodeCaching = annotation.getParam("hashCodeCaching", Caching.class);
int hashCodeBase = annotation.getParam("hashCodeBase", Integer.class);
boolean isComparable = annotation.getParam("isComparable", Boolean.class);
float floatEpsilon = annotation.getParam("floatEpsilon", Float.class);
double doubleEpsilon = annotation.getParam("doubleEpsilon", Double.class);
FloatCustomization floatCustomization = new FloatCustomization(floatEpsilon, doubleEpsilon);
Serialization serialization = serialization(annotation);
ClassCustomization classCustomization = generation.processGenerationResult(classCustomization(annotation, visitorDefinition, valueClass));
AbstractJClass[] interfaces = annotation.getParam("implementsInterfaces", AbstractJClass[].class);
AcceptMethodCustomization acceptMethodCustomization = new AcceptMethodCustomization(acceptMethodName, acceptMethodAccess);
InterfacesCustomization interfaceCustomization = new InterfacesCustomization(isComparable, serialization, interfaces);
APICustomization apiCustomization = new APICustomization(isPublic, acceptMethodCustomization, interfaceCustomization);
ImplementationCustomization implementationCustomization = new ImplementationCustomization(hashCodeCaching, hashCodeBase, floatCustomization);
Customization customiztion = new Customization(classCustomization, apiCustomization, implementationCustomization);
return generation.createGenerationResult(new ValueClassConfiguration(visitorDefinition, customiztion));
}
use of com.github.sviperll.adt4j.Caching in project adt4j by sviperll.
the class FinalValueClassModel method createMethodBuilder.
MethodBuilder createMethodBuilder(Serialization serialization) {
if (isError)
return new MethodBuilder(null, null);
else {
JFieldVar acceptorField = buildAcceptorField();
Map<String, JDefinedClass> caseClasses;
try {
caseClasses = buildCaseClasses(serialization);
} catch (JClassAlreadyExistsException ex) {
throw new RuntimeException("Unexpected exception :)", ex);
}
Caching hashCode = environment.hashCodeCaching();
if (!hashCode.enabled())
return new MethodBuilder(caseClasses, acceptorField);
else {
JFieldVar hashCodeField = buildHashCodeCachedValueField(serialization);
return new MethodBuilder(caseClasses, acceptorField, hashCodeField);
}
}
}
Aggregations