Search in sources :

Example 1 with CPropertyInfo

use of com.sun.tools.xjc.model.CPropertyInfo in project midpoint by Evolveum.

the class SchemaProcessor method getReferencedField.

private JFieldVar getReferencedField(JFieldVar field, ClassOutline classOutline) {
    QName qname = getFieldReferenceUseAnnotationQName(field, classOutline);
    CPropertyInfo propertyInfo = classOutline.target.getProperty(qname.getLocalPart());
    if (propertyInfo == null) {
        throw new IllegalArgumentException("No property " + qname.getLocalPart() + " in " + classOutline.target);
    }
    return classOutline.implClass.fields().get(propertyInfo.getName(false));
}
Also used : QName(javax.xml.namespace.QName) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo)

Example 2 with CPropertyInfo

use of com.sun.tools.xjc.model.CPropertyInfo in project midpoint by Evolveum.

the class SchemaProcessor method createAnonListClass.

@NotNull
private JDefinedClass createAnonListClass(JFieldVar field, ClassOutline classOutline) {
    JDefinedClass anonymous;
    try {
        CPropertyInfo propertyInfo = classOutline.target.getProperty(field.name());
        anonymous = classOutline.implClass._class(JMod.PRIVATE | JMod.STATIC, "Anon" + propertyInfo.getName(true));
        JDocComment comment = anonymous.javadoc();
        comment.append("TODO Can't be anonymous because of NPE bug in CodeModel generator, will be fixed later.");
    } catch (JClassAlreadyExistsException ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
    return anonymous;
}
Also used : CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with CPropertyInfo

use of com.sun.tools.xjc.model.CPropertyInfo in project midpoint by Evolveum.

the class SchemaProcessor method isFieldReference.

private boolean isFieldReference(JFieldVar field, ClassOutline classOutline) {
    CPropertyInfo propertyInfo = classOutline.target.getProperty(field.name());
    Collection<? extends CTypeInfo> collection = propertyInfo.ref();
    if (collection == null || collection.isEmpty()) {
        return false;
    }
    CTypeInfo info = collection.iterator().next();
    if (info instanceof CClassInfo) {
        CClassInfo classInfo = (CClassInfo) info;
        if (OBJECT_REFERENCE_TYPE.equals(classInfo.getTypeName())) {
            return true;
        }
    }
    return false;
}
Also used : CClassInfo(com.sun.tools.xjc.model.CClassInfo) CTypeInfo(com.sun.tools.xjc.model.CTypeInfo) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo)

Example 4 with CPropertyInfo

use of com.sun.tools.xjc.model.CPropertyInfo in project midpoint by Evolveum.

the class ProcessorUtils method hasAnnotation.

public static BIDeclaration hasAnnotation(ClassOutline classOutline, JFieldVar field, QName qname) {
    CPropertyInfo propertyInfo = classOutline.target.getProperty(field.name());
    if (propertyInfo == null || !(propertyInfo.getSchemaComponent() instanceof XSParticle)) {
        return null;
    }
    XSParticle particle = (XSParticle) propertyInfo.getSchemaComponent();
    if (particle.getTerm() == null) {
        return null;
    }
    XSAnnotation annotation = particle.getTerm().getAnnotation(false);
    return hasAnnotation(annotation, qname);
}
Also used : XSAnnotation(com.sun.xml.xsom.XSAnnotation) XSParticle(com.sun.xml.xsom.XSParticle) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo)

Example 5 with CPropertyInfo

use of com.sun.tools.xjc.model.CPropertyInfo in project midpoint by Evolveum.

the class ProcessorUtils method getGetterMethodName.

public static String getGetterMethodName(ClassOutline classOutline, JFieldVar field) {
    CPropertyInfo prop = classOutline.target.getProperty(field.name());
    JType type = field.type();
    Options options = classOutline.parent().getModel().options;
    JCodeModel codeModel = classOutline.parent().getCodeModel();
    if (options.enableIntrospection) {
        return ((type.isPrimitive() && type.boxify().getPrimitiveType() == codeModel.BOOLEAN) ? "is" : "get") + prop.getName(true);
    } else {
        return (type.boxify().getPrimitiveType() == codeModel.BOOLEAN ? "is" : "get") + prop.getName(true);
    }
}
Also used : Options(com.sun.tools.xjc.Options) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo)

Aggregations

CPropertyInfo (com.sun.tools.xjc.model.CPropertyInfo)5 Options (com.sun.tools.xjc.Options)1 CClassInfo (com.sun.tools.xjc.model.CClassInfo)1 CTypeInfo (com.sun.tools.xjc.model.CTypeInfo)1 XSAnnotation (com.sun.xml.xsom.XSAnnotation)1 XSParticle (com.sun.xml.xsom.XSParticle)1 QName (javax.xml.namespace.QName)1 NotNull (org.jetbrains.annotations.NotNull)1