public AdaptingWrappingField(ClassOutlineImpl context, CPropertyInfo prop, CPropertyInfo core) { this(context, prop, core, prop.getAdapter()); }
public AdaptingWrappingField(ClassOutlineImpl context, CPropertyInfo prop, CPropertyInfo core) { this(context, prop, core, prop.getAdapter()); }
public TypeUse getTypeUse(C context, CPropertyInfo propertyInfo) { if (propertyInfo instanceof CValuePropertyInfo) { return ((CValuePropertyInfo) propertyInfo).getTarget(); } else if (propertyInfo instanceof CAttributePropertyInfo) { return ((CAttributePropertyInfo) propertyInfo).getTarget(); } else { final CTypeInfo type = propertyInfo.ref().iterator().next(); if (type instanceof CBuiltinLeafInfo) { if (propertyInfo.getAdapter() != null) { return TypeUseFactory.adapt((CBuiltinLeafInfo) type, propertyInfo.getAdapter()); } else { return (CBuiltinLeafInfo) type; } } else if (type instanceof CElementInfo) { final CElementInfo elementInfo = (CElementInfo) type; return getTypeUse(context, elementInfo.getProperty()); } else { throw new AssertionError("Unexpected type."); } } } }
public static TypeUse getTypeUse(ProcessModel processModel, CPropertyInfo propertyInfo) { if (propertyInfo instanceof CValuePropertyInfo) { return ((CValuePropertyInfo) propertyInfo).getTarget(); } else if (propertyInfo instanceof CAttributePropertyInfo) { return ((CAttributePropertyInfo) propertyInfo).getTarget(); } else { final CTypeInfo type = propertyInfo.ref().iterator().next(); if (type instanceof CBuiltinLeafInfo) { if (propertyInfo.getAdapter() != null) { return TypeUseFactory.adapt((CBuiltinLeafInfo) type, propertyInfo.getAdapter()); } else { return (CBuiltinLeafInfo) type; } } else if (type instanceof CElementInfo) { final CElementInfo elementInfo = (CElementInfo) type; return getTypeUse(processModel, elementInfo.getProperty()); } else { throw new AssertionError("Unexpected type."); } } }
public TypeUse getTypeUse(C context, CPropertyInfo propertyInfo) { if (propertyInfo instanceof CValuePropertyInfo) { return ((CValuePropertyInfo) propertyInfo).getTarget(); } else if (propertyInfo instanceof CAttributePropertyInfo) { return ((CAttributePropertyInfo) propertyInfo).getTarget(); } else { final CTypeInfo type = propertyInfo.ref().iterator().next(); if (type instanceof CBuiltinLeafInfo) { if (propertyInfo.getAdapter() != null) { return TypeUseFactory.adapt((CBuiltinLeafInfo) type, propertyInfo.getAdapter()); } else { return (CBuiltinLeafInfo) type; } } else if (type instanceof CElementInfo) { final CElementInfo elementInfo = (CElementInfo) type; return getTypeUse(context, elementInfo.getProperty()); } else { throw new AssertionError("Unexpected type."); } } } }
public static TypeUse getTypeUse(ProcessModel processModel, CPropertyInfo propertyInfo) { if (propertyInfo instanceof CValuePropertyInfo) { return ((CValuePropertyInfo) propertyInfo).getTarget(); } else if (propertyInfo instanceof CAttributePropertyInfo) { return ((CAttributePropertyInfo) propertyInfo).getTarget(); } else { final CTypeInfo type = propertyInfo.ref().iterator().next(); if (type instanceof CBuiltinLeafInfo) { if (propertyInfo.getAdapter() != null) { return TypeUseFactory.adapt((CBuiltinLeafInfo) type, propertyInfo.getAdapter()); } else { return (CBuiltinLeafInfo) type; } } else if (type instanceof CElementInfo) { final CElementInfo elementInfo = (CElementInfo) type; return getTypeUse(processModel, elementInfo.getProperty()); } else { throw new AssertionError("Unexpected type."); } } }
public static Set<JType> getPossibleTypes(FieldOutline fieldOutline, Aspect aspect) { Validate.notNull(fieldOutline); final ClassOutline classOutline = fieldOutline.parent(); final Outline outline = classOutline.parent(); final CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo(); final Set<JType> types = new HashSet<JType>(); if (propertyInfo.getAdapter() != null) { types.add(propertyInfo.getAdapter().customType.toType(fieldOutline .parent().parent(), aspect)); } else if (propertyInfo.baseType != null) { types.add(propertyInfo.baseType); } else { Collection<? extends CTypeInfo> typeInfos = propertyInfo.ref(); for (CTypeInfo typeInfo : typeInfos) { types.addAll(getPossibleTypes(outline, aspect, typeInfo)); } } return types; }
protected JType getType(CPropertyInfo prop, final Aspect aspect) { if(prop.getAdapter()!=null) return prop.getAdapter().customType.toType(outline.parent(),aspect);
protected JType getType(CPropertyInfo prop, final Aspect aspect) { if(prop.getAdapter()!=null) return prop.getAdapter().customType.toType(outline.parent(),aspect);
if (propertyInfo.getAdapter() != null) { logger.debug("Adapter property info is not wrapped"); return Collections.emptyList();
if(prop.getAdapter()!=null) return prop.getAdapter().customType.toType(outline.parent(),aspect);
if(prop.getAdapter()!=null) return prop.getAdapter().customType.toType(outline.parent(),aspect);
if(prop.getAdapter()!=null) return prop.getAdapter().customType.toType(outline.parent(),aspect);
/** * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary. * Also generates other per-property annotations * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary. */ public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) { CAdapter adapter = prop.getAdapter(); if (adapter != null ) { if(adapter.getAdapterIfKnown()==SwaRefAdapter.class) { field.annotate(XmlAttachmentRef.class); } else { // [RESULT] // @XmlJavaTypeAdapter( Foo.class ) XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class); xjtw.value(adapter.adapterType.toType(this, EXPOSED)); } } switch(prop.id()) { case ID: field.annotate(XmlID.class); break; case IDREF: field.annotate(XmlIDREF.class); break; } if(prop.getExpectedMimeType()!=null) field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString()); }
/** * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary. * Also generates other per-property annotations * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary. */ public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) { CAdapter adapter = prop.getAdapter(); if (adapter != null ) { if(adapter.getAdapterIfKnown()==SwaRefAdapter.class) { field.annotate(XmlAttachmentRef.class); } else { // [RESULT] // @XmlJavaTypeAdapter( Foo.class ) XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class); xjtw.value(adapter.adapterType.toType(this, EXPOSED)); } } switch(prop.id()) { case ID: field.annotate(XmlID.class); break; case IDREF: field.annotate(XmlIDREF.class); break; } if(prop.getExpectedMimeType()!=null) field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString()); }
/** * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary. * Also generates other per-property annotations * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary. */ public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) { CAdapter adapter = prop.getAdapter(); if (adapter != null) { if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) { field.annotate(XmlAttachmentRef.class); } else { // [RESULT] // @XmlJavaTypeAdapter( Foo.class ) XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class); xjtw.value(adapter.adapterType.toType(this, EXPOSED)); } } switch (prop.id()) { case ID: field.annotate(XmlID.class); break; case IDREF: field.annotate(XmlIDREF.class); break; } if (prop.getExpectedMimeType() != null) { field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString()); } }
/** * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary. * Also generates other per-property annotations * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary. */ public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) { CAdapter adapter = prop.getAdapter(); if (adapter != null) { if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) { field.annotate(XmlAttachmentRef.class); } else { // [RESULT] // @XmlJavaTypeAdapter( Foo.class ) XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class); xjtw.value(adapter.adapterType.toType(this, EXPOSED)); } } switch (prop.id()) { case ID: field.annotate(XmlID.class); break; case IDREF: field.annotate(XmlIDREF.class); break; } if (prop.getExpectedMimeType() != null) { field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString()); } }
/** * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary. * Also generates other per-property annotations * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary. */ public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) { CAdapter adapter = prop.getAdapter(); if (adapter != null) { if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) { field.annotate(XmlAttachmentRef.class); } else { // [RESULT] // @XmlJavaTypeAdapter( Foo.class ) XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class); xjtw.value(adapter.adapterType.toType(this, EXPOSED)); } } switch (prop.id()) { case ID: field.annotate(XmlID.class); break; case IDREF: field.annotate(XmlIDREF.class); break; } if (prop.getExpectedMimeType() != null) { field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString()); } }
@Override protected void fix(JBlock body) { body._if(wrappingPropertyField.eq(JExpr._null())) ._then() .assign(wrappingPropertyField, JExpr._new(codeModel.ref(ArrayList.class).narrow( wrappingPropertyExposedType.boxify()))); final JClass utilsClass = codeModel.ref(TransformUtils.class); // // (wrappedProperty instanceof CReferencePropertyInfo && // ((CReferencePropertyInfo) wrappedProperty) // .isMixed()) ? codeModel.ref(MixedItemUtils.class) : codeModel // .ref(ItemUtils.class); body._if( utilsClass.staticInvoke("shouldBeWrapped").arg( wrappedPropertyField)) ._then() .assign(wrappedPropertyField, utilsClass .staticInvoke("wrap") .arg(wrappedPropertyField) .arg(wrappingPropertyField) .arg(wrappingProperty.getAdapter() .getAdapterClass(outline.parent()) .dotclass())); }
@Override protected void fix(JBlock body) { body._if(wrappingPropertyField.eq(JExpr._null())) ._then() .assign(wrappingPropertyField, JExpr._new(codeModel.ref(ArrayList.class).narrow( wrappingPropertyExposedType.boxify()))); final JClass utilsClass = codeModel.ref(TransformUtils.class); // // (wrappedProperty instanceof CReferencePropertyInfo && // ((CReferencePropertyInfo) wrappedProperty) // .isMixed()) ? codeModel.ref(MixedItemUtils.class) : codeModel // .ref(ItemUtils.class); body._if( utilsClass.staticInvoke("shouldBeWrapped").arg( wrappedPropertyField)) ._then() .assign(wrappedPropertyField, utilsClass .staticInvoke("wrap") .arg(wrappedPropertyField) .arg(wrappingPropertyField) .arg(wrappingProperty.getAdapter() .getAdapterClass(outline.parent()) .dotclass())); }