Examples of DecoratedTypeMirror


Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

        TypeDeclaration type = env.getTypeDeclaration(entityType.getName());
        return new ResourceEntityParameter(type, env.getTypeUtils().getDeclaredType(type));
      }
    }
    catch (MirroredTypeException e) {
      DecoratedTypeMirror typeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(e.getTypeMirror());
      if (typeMirror.isDeclared()) {
        if (typeMirror.isInstanceOf(ResourceMethodSignature.class.getName() + ".NONE")) {
          return null;
        }
        else {
          return new ResourceEntityParameter(((DeclaredType) typeMirror).getDeclaration(), typeMirror);
        }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

    this.originalType = originalType;
  }

  @Override
  public boolean isInstanceOf(String className) {
    DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(this.originalType);
    return decorated.isInstanceOf(className);
  }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   *
   * @param typeMirror The type to unwrap if necessary.
   * @return The component type, or the type itself.
   */
  public static TypeMirror unwrapComponentType(TypeMirror typeMirror) {
    DecoratedTypeMirror decoratedType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror);

    if (decoratedType.isArray()) {
      typeMirror = ((ArrayType) decoratedType).getComponentType();
    }
    else if (decoratedType.isCollection()) {
      //if it's a collection type, the xml type is its component type.
      Iterator<TypeMirror> actualTypeArguments = ((DeclaredType) decoratedType).getActualTypeArguments().iterator();
      if (!actualTypeArguments.hasNext()) {
        //no type arguments, java.lang.Object type.
        AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment();
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   *
   * @param type The type.
   * @return Whether this adapter can adapt the specified type.
   */
  public boolean canAdapt(ReferenceType type) {
    DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(type);
    ReferenceType adaptedType = getAdaptedType();
    if (adaptedType instanceof DeclaredType) {
      return ((DeclaredType)adaptedType).getDeclaration() != null && decorated.isInstanceOf(((DeclaredType)adaptedType).getDeclaration().getQualifiedName());
    }
    else if (adaptedType instanceof ArrayType) {
      if (decorated instanceof ArrayType) {
        TypeMirror adaptedComponentType = ((ArrayType) adaptedType).getComponentType();
        while (adaptedComponentType instanceof DecoratedTypeMirror) {
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   *
   * @param adaptedType The type.
   * @return The adapting type, or null if not adaptable.
   */
  public TypeMirror getAdaptingType(TypeMirror adaptedType) {
    DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(adaptedType);
    TypeMirror componentType = null;
    if (decorated.isCollection()) {
      Iterator<TypeMirror> itemTypes = ((DeclaredType) decorated).getActualTypeArguments().iterator();
      if (!itemTypes.hasNext()) {
        AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
        Types typeUtils = env.getTypeUtils();
        componentType = TypeMirrorDecorator.decorate(typeUtils.getDeclaredType(env.getTypeDeclaration(java.lang.Object.class.getName())));
      }
      else {
        componentType = itemTypes.next();
      }
    }
    else if (decorated.isArray()) {
      componentType = ((ArrayType) decorated).getComponentType();
    }

    if (componentType instanceof ReferenceType && canAdapt((ReferenceType) componentType)) {
      //if we can adapt the component type, then the adapting type is the collection of the declared adapting type.
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   * The min occurs of a web result.
   *
   * @return 1 if primitive.  0 otherwise.
   */
  public int getMinOccurs() {
    DecoratedTypeMirror typeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(this.delegate);
    return typeMirror.isPrimitive() ? 1 : 0;
  }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   * The max occurs of the web result.
   *
   * @return The max occurs.
   */
  public String getMaxOccurs() {
    DecoratedTypeMirror typeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(this.delegate);
    boolean unbounded = typeMirror.isCollection() || typeMirror.isArray();
    if (typeMirror.isArray()) {
      TypeMirror componentType = ((ArrayType) typeMirror).getComponentType();
      //special case for byte[]
      if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) {
        unbounded = false;
      }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   * Whether the any element is a collection.
   *
   * @return Whether the any element is a collection.
   */
  public boolean isCollectionType() {
    DecoratedTypeMirror accessorType;
    Declaration delegate = getDelegate();
    if (delegate instanceof FieldDeclaration) {
      accessorType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(((FieldDeclaration) delegate).getType());
    }
    else {
      accessorType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(((PropertyDeclaration) delegate).getPropertyType());
    }

    return accessorType.isInstanceOf(Collection.class.getName());
  }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   * The min occurs of this parameter as a child element.
   *
   * @return 1 if primitive.  0 otherwise.
   */
  public int getMinOccurs() {
    DecoratedTypeMirror paramType = (DecoratedTypeMirror) getType();
    return paramType.isPrimitive() ? 1 : 0;
  }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   * The max occurs of this parameter as a child element.
   *
   * @return The max occurs of this parameter as a child element.
   */
  public String getMaxOccurs() {
    DecoratedTypeMirror paramType = (DecoratedTypeMirror) getType();
    boolean unbounded = paramType.isCollection() || paramType.isArray();
    if (paramType.isArray()) {
      TypeMirror componentType = ((ArrayType) paramType).getComponentType();
      //special case for byte[]
      if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) {
        unbounded = false;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.