@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "MapKeyCompositeType", propOrder = { "attributes" }) @XmlElements({ @XmlElement(name = "key-property", type = JaxbHbmCompositeKeyBasicAttributeType.class), @XmlElement(name = "key-many-to-one", type = JaxbHbmCompositeKeyManyToOneType.class) }) protected List<JaxbHbmToolingHintContainer> attributes; @XmlAttribute(name = "class", required = true) protected String clazz;
@XmlRootElement(name = "RouterList") public class RouterList { @XmlElements(value = { @XmlElement(name="routerInfo") }) public List<RouterInfo> routerInfo = new ArrayList<RouterInfo>(); }
@XmlElements({ @XmlElement(name="foo", type=Foo.class), @XmlElement(name="bar", type=Bar.class) }) public List<Model> getElements() { return Arrays.asList(new Foo("name1"), new Bar("title1")); } }
private String findKeyForField(String key, Mappings.Getter getter, Class<?> componentType) { String k = null; final XmlElement xmlElt = getter.reader.getAnnotation(XmlElement.class); if (xmlElt != null && !Jaxbs.isDefault(xmlElt.name())) { k = xmlElt.name(); } final XmlElements xmlElts = getter.reader.getAnnotation(XmlElements.class); if (xmlElts != null) { for (final XmlElement xml : xmlElts.value()) { if (xml.type() == componentType && !Jaxbs.isDefault(xml.name())) { k = xml.name(); } } } if (k == null) { if (MethodAccessMode.MethodReader.class.isInstance(getter)) { k = Introspector.decapitalize(Method.class.cast(Reflections.get(MethodAccessMode.MethodReader.class.cast(getter), "method")).getName().replaceFirst("get", " ")); } else if (FieldAccessMode.FieldReader.class.isInstance(getter)) { k = Introspector.decapitalize(Field.class.cast(Reflections.get(FieldAccessMode.FieldReader.class.cast(getter), "field")).getName()); } else { k = key; } } return k; }
Messages.MUTUALLY_EXCLUSIVE_ANNOTATIONS.format( nav().getClassName(parent.getClazz())+'#'+seed.getName(), xe.annotationType().getName(), xes.annotationType().getName()), xe, xes )); else if(xes!=null) ann = xes.value(); if (nav().isSameType(type, nav().ref(XmlElement.DEFAULT.class))) type = getIndividualType(); if((!nav().isPrimitive(type) || isCollection()) && !item.required()) isRequired = false; types.add(createTypeRef(name, type, item.nillable(), getDefaultValue(item.defaultValue()) ));
XmlElement[] elements = ((XmlElements) helper.getAnnotation(javaHasAnnotations, XmlElements.class)).value(); for (XmlElement next : elements) { org.eclipse.persistence.jaxb.xmlmodel.XmlElement xmlElement = new org.eclipse.persistence.jaxb.xmlmodel.XmlElement(); xmlElement.setDefaultValue(next.defaultValue()); xmlElement.setName(next.name()); xmlElement.setNamespace(next.namespace()); xmlElement.setNillable(next.nillable()); xmlElement.setRequired(next.required());
if (elems != null) { result = new ArrayList<NamedType>(); for (XmlElement elem : elems.value()) { String name = elem.name(); if (MARKER_FOR_DEFAULT.equals(name)) name = null; result.add(new NamedType(elem.type(), name)); XmlRootElement rootElement = (XmlRootElement) refType.getAnnotation(XmlRootElement.class); if (rootElement != null) { name = rootElement.name();
}; taskCmdSubTypes.removeAll(Arrays.asList(exclTaskCmds)); for( XmlElement xmlElemAnno : xmlElemsAnno.value() ) { Class xmlElemAnnoType = xmlElemAnno.type(); assertTrue( xmlElemAnnoType.getName() + " does not extend the " + TaskCommand.class.getSimpleName() + " class!", taskCmdSubTypes.contains(xmlElemAnnoType)); for( XmlElement xmlElemAnno : xmlElemsAnno.value() ) { Class xmlElemAnnoType = xmlElemAnno.type(); taskCmdSubTypes.remove(xmlElemAnnoType);
XmlElements xmlElements = getAnnotation(XmlElements.class); if (xmlElements != null) { XmlElement[] elementChoices = xmlElements.value(); if (elementChoices.length == 0) { xmlElements = null; this.choices = new ArrayList<Element>(); if (xmlElements != null) { for (final XmlElement element : xmlElements.value()) { DecoratedTypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override
@XmlRootElement(name="AlertPatchSet") public class AlertPatchSet { @XmlElements({ @XmlElement(name = "AlertPatch", type = AlertPatch.class) }) public List<AlertPatch> alertPatches; }
XmlElements xmlElements = field.getAnnotation(XmlElements.class); assert xmlElements != null; for (XmlElement xe : xmlElements.value()) { if (xe.type().equals(child.getClass())) { return new QName(child.getOriginatingNamespaceURI(), xe.name()); } else if (XmlElement.DEFAULT.class.equals(xe.type())) {
Messages.MUTUALLY_EXCLUSIVE_ANNOTATIONS.format( nav().getClassName(parent.getClazz())+'#'+seed.getName(), xe.annotationType().getName(), xes.annotationType().getName()), xe, xes )); else if(xes!=null) ann = xes.value(); if (nav().isSameType(type, nav().ref(XmlElement.DEFAULT.class))) type = getIndividualType(); if((!nav().isPrimitive(type) || isCollection()) && !item.required()) isRequired = false; types.add(createTypeRef(name, type, item.nillable(), getDefaultValue(item.defaultValue()) ));
XmlElements xmlElements = getAnnotation(XmlElements.class); if (xmlElements != null) { XmlElement[] elementChoices = xmlElements.value(); if (elementChoices.length == 0) { xmlElements = null; this.choices = new ArrayList<Element>(); if (xmlElements != null) { for (final XmlElement element : xmlElements.value()) { DecoratedTypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "composite-index-type", propOrder = { "attributes" }) @XmlElements({ @XmlElement(name = "key-property", type = JaxbHbmCompositeKeyBasicAttributeType.class), @XmlElement(name = "key-many-to-one", type = JaxbHbmCompositeKeyManyToOneType.class) }) protected List<JaxbHbmToolingHintContainer> attributes; @XmlAttribute(name = "class", required = true) protected String clazz;
@XmlRootElement(name="BikeRentalStationList") public class BikeRentalStationList { @XmlElements(value = { @XmlElement(name="station") }) public List<BikeRentalStation> stations = new ArrayList<BikeRentalStation>(); }
/** * If you think this test is a mistake: beware, this test is smarter than * you. */ @Test public void acceptedCommandsCanBeSerializedTest() throws Exception { Field commandsField = JaxbCommandsRequest.class.getDeclaredField("commands"); XmlElements xmlElemsAnno = (XmlElements) commandsField.getAnnotations()[0]; XmlElement[] xmlElems = xmlElemsAnno.value(); Set<Class> cmdSet = getAcceptedCommandClassSet(); assertEquals(AcceptedServerCommands.class.getSimpleName() + " contains a different set of Commands than " + JaxbCommandsRequest.class.getSimpleName(), cmdSet.size(), xmlElems.length); Set<String> xmlElemNameSet = new HashSet<String>(); for( XmlElement xmlElemAnno : xmlElems ) { Class cmdClass = xmlElemAnno.type(); String name = xmlElemAnno.name(); assertTrue(name + " is used twice as a name.", xmlElemNameSet.add(name)); assertTrue(cmdClass.getSimpleName() + " is present in " + AcceptedServerCommands.class.getSimpleName() + " but not in " + JaxbCommandsRequest.class.getSimpleName(), cmdSet.remove(cmdClass)); } for( Class cmdClass : cmdSet ) { logger.error("Missing: " + cmdClass.getSimpleName()); } assertEquals("See output for classes in " + AcceptedServerCommands.class.getSimpleName() + " that are not in " + JaxbCommandsRequest.class.getSimpleName(), 0, cmdSet.size()); }
Messages.MUTUALLY_EXCLUSIVE_ANNOTATIONS.format( nav().getClassName(parent.getClazz())+'#'+seed.getName(), xe.annotationType().getName(), xes.annotationType().getName()), xe, xes )); else if(xes!=null) ann = xes.value(); if (nav().isSameType(type, nav().ref(XmlElement.DEFAULT.class))) type = getIndividualType(); if((!nav().isPrimitive(type) || isCollection()) && !item.required()) isRequired = false; types.add(createTypeRef(name, type, item.nillable(), getDefaultValue(item.defaultValue()) ));
private boolean checkIfParentChildRelationIsPossible(Class srcClass, Class targetClass) { XmlElements targetClassAnnotation = (XmlElements) getFieldAnnotation(targetClass, XmlElements.class); if (targetClassAnnotation == null) { return false; } for (XmlElement xe : targetClassAnnotation.value()) { if (srcClass.isAssignableFrom(xe.type())) { return true; } } return false; } }