use of com.sun.tools.xjc.model.nav.NClass in project midpoint by Evolveum.
the class SchemaProcessor method removeCustomGeneratedMethod.
/**
* remove generated equals methods from classes which extends from prism containers/objects
*/
private void removeCustomGeneratedMethod(Outline outline) {
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
ClassOutline classOutline = outline.getClazz(entry.getValue());
QName qname = getCClassInfoQName(entry.getValue());
if (qname == null || (!hasParentAnnotation(classOutline, A_PRISM_OBJECT) && !hasParentAnnotation(classOutline, A_PRISM_CONTAINER))) {
continue;
}
JDefinedClass definedClass = classOutline.implClass;
Iterator<JClass> iterator = definedClass._implements();
while (iterator.hasNext()) {
JClass clazz = iterator.next();
if (clazz.equals(CLASS_MAP.get(Equals.class)) || clazz.equals(CLASS_MAP.get(HashCode.class))) {
iterator.remove();
}
}
boolean isMidpointContainer = hasParentAnnotation(classOutline, A_PRISM_OBJECT);
removeOldCustomGeneratedEquals(classOutline, isMidpointContainer);
removeOldCustomGenerated(classOutline, isMidpointContainer, METHOD_HASH_CODE);
removeOldCustomGenerated(classOutline, isMidpointContainer, METHOD_TO_STRING);
}
}
use of com.sun.tools.xjc.model.nav.NClass in project midpoint by Evolveum.
the class SchemaProcessor method addContainerName.
private void addContainerName(Outline outline, Map<String, JFieldVar> namespaceFields) {
Map<QName, List<QName>> complexTypeToElementName = null;
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
CClassInfo classInfo = entry.getValue();
ClassOutline classOutline = outline.getClazz(classInfo);
if (complexTypeToElementName == null) {
complexTypeToElementName = getComplexTypeToElementName(classOutline);
}
QName qname = getCClassInfoQName(classInfo);
if (qname == null || !hasParentAnnotation(classOutline, A_PRISM_OBJECT)) {
continue;
}
//element name
List<QName> qnames = complexTypeToElementName.get(qname);
if (qnames == null || qnames.size() != 1) {
printWarning("Found zero or more than one element names for type '" + qname + "', " + qnames + ".");
continue;
}
qname = qnames.get(0);
JDefinedClass definedClass = classOutline.implClass;
JMethod getContainerName = definedClass.method(JMod.NONE, QName.class, METHOD_GET_CONTAINER_NAME);
// getContainerName.annotate(CLASS_MAP.get(XmlTransient.class));
JBlock body = getContainerName.body();
JFieldVar var = namespaceFields.get(qname.getNamespaceURI());
JInvocation invocation = JExpr._new(CLASS_MAP.get(QName.class));
if (var != null) {
JClass schemaClass = outline.getModel().codeModel._getClass(StepSchemaConstants.CLASS_NAME);
invocation.arg(schemaClass.staticRef(var));
invocation.arg(qname.getLocalPart());
} else {
invocation.arg(qname.getNamespaceURI());
invocation.arg(qname.getLocalPart());
}
body._return(invocation);
//get container type
JMethod getContainerType = definedClass.method(JMod.NONE, QName.class, METHOD_GET_CONTAINER_TYPE);
// getContainerType.annotate(CLASS_MAP.get(XmlTransient.class));
body = getContainerType.body();
body._return(definedClass.staticRef(COMPLEX_TYPE_FIELD_NAME));
}
}
use of com.sun.tools.xjc.model.nav.NClass in project midpoint by Evolveum.
the class CloneProcessor method run.
@Override
public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) throws Exception {
PluginImpl clonePlugin = new PluginImpl();
clonePlugin.run(outline, opt, errorHandler);
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
ClassOutline classOutline = outline.getClazz(entry.getValue());
if (isPrism(classOutline)) {
removeConstructors(classOutline);
removeCloneableMethod(classOutline);
removePrivateStaticCopyMethods(classOutline);
createCloneMethod(classOutline);
}
}
return true;
}
use of com.sun.tools.xjc.model.nav.NClass in project midpoint by Evolveum.
the class SchemaProcessor method addComplextType.
private void addComplextType(Outline outline, Map<String, JFieldVar> namespaceFields) {
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
ClassOutline classOutline = outline.getClazz(entry.getValue());
QName qname = entry.getValue().getTypeName();
if (qname == null) {
continue;
}
JFieldVar var = namespaceFields.get(qname.getNamespaceURI());
if (var != null) {
createQNameDefinition(outline, classOutline.implClass, COMPLEX_TYPE_FIELD_NAME, var, qname);
} else {
createPSFField(outline, classOutline.implClass, COMPLEX_TYPE_FIELD_NAME, qname);
}
}
}
use of com.sun.tools.xjc.model.nav.NClass in project midpoint by Evolveum.
the class ProcessorUtils method findClassOutline.
public static ClassOutline findClassOutline(Outline outline, QName type) {
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
ClassOutline classOutline = outline.getClazz(entry.getValue());
QName qname = entry.getValue().getTypeName();
if (!type.equals(qname)) {
continue;
}
return classOutline;
}
throw new IllegalStateException("Object type class defined by qname '" + type + "' outline was not found.");
}
Aggregations