use of com.sun.tools.xjc.outline.Outline in project midpoint by Evolveum.
the class CloneProcessor method createCloneMethod.
private void createCloneMethod(ClassOutline classOutline) {
JDefinedClass impl = classOutline.implClass;
JMethod cloneMethod = impl.method(JMod.PUBLIC, impl, METHOD_CLONE);
JBlock body = cloneMethod.body();
if (impl.isAbstract()) {
body._return(JExpr._this());
//don't create clone() method body on abstract prism objects
return;
}
Outline outline = classOutline.parent();
JVar object = body.decl(impl, "object", JExpr._new(impl));
if (ProcessorUtils.hasParentAnnotation(classOutline, SchemaProcessor.A_PRISM_OBJECT)) {
JClass type = (JClass) outline.getModel().codeModel._ref(PrismObject.class);
JVar prism = body.decl(type, "value", JExpr.invoke(SchemaProcessor.METHOD_AS_PRISM_OBJECT).invoke(METHOD_CLONE));
JInvocation invocation = object.invoke(SchemaProcessor.METHOD_SETUP_CONTAINER);
invocation.arg(prism);
body.add(invocation);
} else if (ProcessorUtils.hasParentAnnotation(classOutline, SchemaProcessor.A_PRISM_CONTAINER)) {
JClass type = (JClass) outline.getModel().codeModel._ref(PrismContainerValue.class);
JVar prism = body.decl(type, "value", JExpr.invoke(SchemaProcessor.METHOD_AS_PRISM_CONTAINER_VALUE).invoke(METHOD_CLONE));
JInvocation invocation = object.invoke(SchemaProcessor.METHOD_SETUP_CONTAINER_VALUE);
invocation.arg(prism);
body.add(invocation);
} else if (ProcessorUtils.hasParentAnnotation(classOutline, SchemaProcessor.A_OBJECT_REFERENCE)) {
JClass type = (JClass) outline.getModel().codeModel._ref(PrismReferenceValue.class);
JVar prism = body.decl(type, "value", JExpr.invoke(SchemaProcessor.METHOD_AS_REFERENCE_VALUE).invoke(METHOD_CLONE));
JInvocation invocation = object.invoke(SchemaProcessor.METHOD_SETUP_REFERENCE_VALUE);
invocation.arg(prism);
body.add(invocation);
}
body._return(object);
}
Aggregations