public AdapterType getAdapterType() { return (this.rpcPart instanceof Adaptable) ? ((Adaptable) this.rpcPart).getAdapterType(): null; } }
public boolean isAdapted() { return this.rpcPart instanceof Adaptable && ((Adaptable) this.rpcPart).isAdapted(); }
public Accessor(MemberDeclaration delegate, TypeDefinition typeDef) { super(delegate); if ((!(delegate instanceof FieldDeclaration)) && (!(delegate instanceof PropertyDeclaration))) { throw new IllegalArgumentException("Only a field or a property can be a JAXB accessor."); } this.typeDefinition = typeDef; this.adapterType = AdapterUtil.findAdapterType(this); }
/** * Find the specified type of the given adaptable element, if it exists. * * @param adaptable The adaptable element for which to find the specified type. * @return The specified XML type, or null if it doesn't exist. */ public static XmlType findSpecifiedType(Adaptable adaptable) throws XmlTypeException { XmlType xmlType = null; if (adaptable.isAdapted()) { xmlType = getXmlType(adaptable.getAdapterType().getAdaptingType()); } else if (adaptable instanceof Accessor) { //The XML type of accessors can be explicitly defined... xmlType = findExplicitSchemaType((Accessor) adaptable); } return xmlType; }
public void visitInterfaceType(InterfaceType interfaceType) { AdapterType adapterType = AdapterUtil.findAdapterType(interfaceType.getDeclaration()); if (adapterType != null) { adapterType.getAdaptingType().accept(this); } else { MapType mapType = MapTypeUtil.findMapType(interfaceType); if (mapType != null) { setMapXmlType(mapType); } else { this.xmlType = null; this.errorMessage = "An interface type cannot be an xml type."; } } }
/** * Get the resolved accessor type for this accessor. * * @return the resolved accessor type for this accessor. */ public TypeMirror getResolvedAccessorType() { TypeMirror accessorType = getAccessorType(); if (isAdapted()) { accessorType = getAdapterType().getAdaptingType(accessorType); } return accessorType; }
@Override public String convert(ImplicitChildElement childElement) throws TemplateModelException { TypeMirror elementType = childElement.getType(); if ((childElement instanceof Adaptable) && (((Adaptable) childElement).isAdapted())) { elementType = (((Adaptable) childElement).getAdapterType().getAdaptingType(childElement.getType())); } return convert(elementType); }
/** * Narrows the existing declaration down to its adapting declaration, if it's being adapted. Otherwise, the original declaration will be returned. * * @param declaration The declaration to narrow. * @return The narrowed declaration. */ protected ClassDeclaration narrowToAdaptingType(ClassDeclaration declaration) { AdapterType adapterType = AdapterUtil.findAdapterType(declaration); if (adapterType != null) { TypeMirror adaptingType = adapterType.getAdaptingType(); if (!(adaptingType instanceof ClassType)) { return declaration; } else { ClassDeclaration adaptingDeclaration = ((ClassType) adaptingType).getDeclaration(); if (adaptingDeclaration == null) { throw new ValidationException(declaration.getPosition(), String.format("Class %s is being adapted by a type (%s) that doesn't seem to be on the classpath.", declaration.getQualifiedName(), adaptingType)); } return adaptingDeclaration; } } return declaration; }
@Override public String convert(Accessor accessor) throws TemplateModelException { if (accessor.isAdapted()) { //if the type is adapted, the adapting type is already unwrapped. return convert(accessor.getAdapterType().getAdaptingType()); } else { return convert(accessor.getAccessorType()); } }
public AdapterType getAdapterType() { return (this.rpcPart instanceof Adaptable) ? ((Adaptable) this.rpcPart).getAdapterType(): null; } }
public boolean isAdapted() { return this.rpcPart instanceof Adaptable && ((Adaptable) this.rpcPart).isAdapted(); }
protected WebParam(ParameterDeclaration delegate, WebMethod method) { super(delegate); this.method = method; if (this.method == null) { throw new IllegalArgumentException("A web method must be provided."); } annotation = delegate.getAnnotation(javax.jws.WebParam.class); this.adapterType = AdapterUtil.findAdapterType(this); }
@Override public String convert(ImplicitChildElement childElement) throws TemplateModelException { if ((childElement instanceof Adaptable) && (((Adaptable) childElement).isAdapted())) { //the adapting type is already unwrapped... return convert(((Adaptable) childElement).getAdapterType().getAdaptingType()); } else { return convert(childElement.getType()); } }
public void visitInterfaceType(InterfaceType interfaceType) { AdapterType adapterType = AdapterUtil.findAdapterType(interfaceType.getDeclaration()); if (adapterType != null) { adapterType.getAdaptingType().accept(this); } else { MapType mapType = MapTypeUtil.findMapType(interfaceType); if (mapType != null) { setMapXmlType(mapType); } else if (isInCollection) { this.xmlType = KnownXmlType.ANY_TYPE; } else { this.xmlType = null; this.errorMessage = "An interface type cannot be an xml type."; } } }
@Override public String convert(Accessor accessor) throws TemplateModelException { TypeMirror accessorType = accessor.getAccessorType(); if (accessor.isAdapted()) { accessorType = accessor.getAdapterType().getAdaptingType(accessor.getAccessorType()); } return convert(accessorType); }
public Accessor(MemberDeclaration delegate, TypeDefinition typeDef) { super(delegate); if ((!(delegate instanceof FieldDeclaration)) && (!(delegate instanceof PropertyDeclaration))) { throw new IllegalArgumentException("Only a field or a property can be a JAXB accessor."); } this.typeDefinition = typeDef; this.adapterType = AdapterUtil.findAdapterType(this); this.facets.addAll(Facet.gatherFacets(delegate)); this.facets.addAll(typeDef.getFacets()); }
@Override public String convert(ImplicitChildElement childElement) throws TemplateModelException { if ((childElement instanceof Adaptable) && (((Adaptable) childElement).isAdapted())) { //the adapting type might be already unwrapped... return convert(((Adaptable) childElement).getAdapterType().getAdaptingType(childElement.getType())); } else { return convert(childElement.getType()); } }
@Override public String convert(Accessor accessor) throws TemplateModelException { if (accessor.isAdapted()) { //if the type is adapted, the adapting type might be already unwrapped. return convert(accessor.getAdapterType().getAdaptingType(accessor.getAccessorType())); } else { return convert(accessor.getAccessorType()); } }
private FaultBeanChildElement(PropertyDeclaration property) { DecoratedTypeMirror propertyType = (DecoratedTypeMirror) property.getPropertyType(); this.adaperType = AdapterUtil.findAdapterType(property.getGetter()); int minOccurs = propertyType.isPrimitive() ? 1 : 0; String maxOccurs = propertyType.isArray() || propertyType.isCollection() ? "unbounded" : "1"; this.property = property; this.minOccurs = minOccurs; this.maxOccurs = maxOccurs; }
/** * Find the specified type of the given adaptable element, if it exists. * * @param adaptable The adaptable element for which to find the specified type. * @return The specified XML type, or null if it doesn't exist. */ public static XmlType findSpecifiedType(Adaptable adaptable) throws XmlTypeException { XmlType xmlType = null; if (adaptable instanceof Accessor) { XmlSchemaType specified = ((Accessor) adaptable).getAnnotation(XmlSchemaType.class); if (specified != null) { return new SpecifiedXmlType(specified); } } if (adaptable.isAdapted()) { xmlType = getXmlType(adaptable.getAdapterType().getAdaptingType()); } else if (adaptable instanceof Accessor) { //The XML type of accessors can be explicitly defined... xmlType = findExplicitSchemaType((Accessor) adaptable); } return xmlType; }