Java Code Examples for javax.lang.model.type.WildcardType#getSuperBound()

The following examples show how to use javax.lang.model.type.WildcardType#getSuperBound() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public StringBuilder visitWildcard(WildcardType t, Boolean p) {
    int len = DEFAULT_VALUE.length();
    DEFAULT_VALUE.append("?"); //NOI18N
    TypeMirror bound = t.getSuperBound();
    if (bound == null) {
        bound = t.getExtendsBound();
        if (bound != null) {
            DEFAULT_VALUE.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD)
                bound = ((WildcardType)bound).getSuperBound();
            visit(bound, p);
        } else if (len == 0) {
            bound = SourceUtils.getBound(t);
            if (bound != null && (bound.getKind() != TypeKind.DECLARED || !((TypeElement)((DeclaredType)bound).asElement()).getQualifiedName().contentEquals("java.lang.Object"))) { //NOI18N
                DEFAULT_VALUE.append(" extends "); //NOI18N
                visit(bound, p);
            }
        }
    } else {
        DEFAULT_VALUE.append(" super "); //NOI18N
        visit(bound, p);
    }
    return DEFAULT_VALUE;
}
 
Example 2
Source File: SpringXMLConfigCompletionItem.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public StringBuilder visitWildcard(WildcardType t, Boolean p) {
    DEFAULT_VALUE.append("?"); //NOI18N
    TypeMirror bound = t.getSuperBound();
    if (bound == null) {
        bound = t.getExtendsBound();
        if (bound != null) {
            DEFAULT_VALUE.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD)
                bound = ((WildcardType)bound).getSuperBound();
            visit(bound, p);
        } else {
            bound = SourceUtils.getBound(t);
            if (bound != null && (bound.getKind() != TypeKind.DECLARED || !((TypeElement)((DeclaredType)bound).asElement()).getQualifiedName().contentEquals("java.lang.Object"))) { //NOI18N
                DEFAULT_VALUE.append(" extends "); //NOI18N
                visit(bound, p);
            }
        }
    } else {
        DEFAULT_VALUE.append(" super "); //NOI18N
        visit(bound, p);
    }
    return DEFAULT_VALUE;
}
 
Example 3
Source File: JavaSymbolProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public StringBuilder visitWildcard(WildcardType t, Boolean p) {
    int len = DEFAULT_VALUE.length();
    DEFAULT_VALUE.append("?"); //NOI18N
    TypeMirror bound = t.getSuperBound();
    if (bound == null) {
        bound = t.getExtendsBound();
        if (bound != null) {
            DEFAULT_VALUE.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD) {
                bound = ((WildcardType)bound).getSuperBound();
            }
            visit(bound, p);
        } else if (len == 0) {
            bound = SourceUtils.getBound(t);
            if (bound != null && (bound.getKind() != TypeKind.DECLARED || !((TypeElement)((DeclaredType)bound).asElement()).getQualifiedName().contentEquals("java.lang.Object"))) { //NOI18N
                DEFAULT_VALUE.append(" extends "); //NOI18N
                visit(bound, p);
            }
        }
    } else {
        DEFAULT_VALUE.append(" super "); //NOI18N
        visit(bound, p);
    }
    return DEFAULT_VALUE;
}
 
Example 4
Source File: AutoImport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Void visitWildcard(WildcardType type, Void p) {
    builder.append("?"); //NOI18N
    TypeMirror bound = type.getSuperBound();
    if (bound == null) {
        bound = type.getExtendsBound();
        if (bound != null) {
            builder.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD)
                bound = ((WildcardType)bound).getSuperBound();
            visit(bound);
        }
    } else {
        builder.append(" super "); //NOI18N
        visit(bound);
    }
    return null;
}
 
Example 5
Source File: MethodModelSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public StringBuilder visitWildcard(WildcardType t, Boolean p) {
    int len = DEFAULT_VALUE.length();
    DEFAULT_VALUE.append("?"); //NOI18N
    TypeMirror bound = t.getSuperBound();
    if (bound == null) {
        bound = t.getExtendsBound();
        if (bound != null) {
            DEFAULT_VALUE.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD)
                bound = ((WildcardType)bound).getSuperBound();
            visit(bound, p);
        } else if (len == 0) {
            bound = SourceUtils.getBound(t);
            if (bound != null && (bound.getKind() != TypeKind.DECLARED || !((TypeElement)((DeclaredType)bound).asElement()).getQualifiedName().contentEquals("java.lang.Object"))) { //NOI18N
                DEFAULT_VALUE.append(" extends "); //NOI18N
                visit(bound, p);
            }
        }
    } else {
        DEFAULT_VALUE.append(" super "); //NOI18N
        visit(bound, p);
    }
    return DEFAULT_VALUE;
}
 
Example 6
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public StringBuilder visitWildcard(WildcardType t, Boolean p) {
    int len = DEFAULT_VALUE.length();
    DEFAULT_VALUE.append("?"); //NOI18N
    TypeMirror bound = t.getSuperBound();
    if (bound == null) {
        bound = t.getExtendsBound();
        if (bound != null) {
            DEFAULT_VALUE.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD)
                bound = ((WildcardType)bound).getSuperBound();
            visit(bound, p);
        } else if (len == 0) {
            bound = SourceUtils.getBound(t);
            if (bound != null && (bound.getKind() != TypeKind.DECLARED || !((TypeElement)((DeclaredType)bound).asElement()).getQualifiedName().contentEquals("java.lang.Object"))) { //NOI18N
                DEFAULT_VALUE.append(" extends "); //NOI18N
                visit(bound, p);
            }
        }
    } else {
        DEFAULT_VALUE.append(" super "); //NOI18N
        visit(bound, p);
    }
    return DEFAULT_VALUE;
}
 
Example 7
Source File: AbstractAssignabilityChecker.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected boolean handleWildCard( TypeMirror argType, WildcardType varTypeArg,
        Types types )
{
    TypeMirror upperBound = varTypeArg.getExtendsBound();
    TypeMirror lowerBound = varTypeArg.getSuperBound();

    if ( argType instanceof ReferenceType && 
            argType.getKind()!=TypeKind.TYPEVAR)
    {
        return handleWildCardActualType(argType, types, upperBound,
                lowerBound);
    }            
    
    if ( argType.getKind() == TypeKind.TYPEVAR ){
        return handleWildCardTypeVar(argType, types, upperBound, lowerBound);
    }
    
    return false;
}
 
Example 8
Source File: BeanModelBuilder.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void addDependency(TypeMirror tm) {
    if (tm.getKind() == TypeKind.ARRAY) {
        addDependency(((ArrayType)tm).getComponentType());
    } else if (tm.getKind() == TypeKind.WILDCARD) {
        WildcardType wt = (WildcardType)tm;
        TypeMirror bound = wt.getSuperBound();
        if (bound == null) {
            bound = wt.getExtendsBound();
        }
        addDependency(bound);
    } else if (tm.getKind() == TypeKind.DECLARED) {
        addDependency(
            ((TypeElement)compilationInfo.getTypes().asElement(tm)).getQualifiedName().toString()
        );
    }
}
 
Example 9
Source File: TypeSimplifier.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
@Override public boolean apply(TypeMirror arg) {
  if (arg.getKind() == TypeKind.WILDCARD) {
    WildcardType wildcard = (WildcardType) arg;
    if (wildcard.getExtendsBound() == null || isJavaLangObject(wildcard.getExtendsBound())) {
      // This is <?>, unless there's a super bound, in which case it is <? super Foo> and
      // is erased.
      return (wildcard.getSuperBound() != null);
    }
  }
  return true;
}
 
Example 10
Source File: TypeSimplifier.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
@Override public Void visitWildcard(WildcardType t, Void p) {
  for (TypeMirror bound : new TypeMirror[] {t.getSuperBound(), t.getExtendsBound()}) {
    if (bound != null) {
      visit(bound, p);
    }
  }
  return null;
}
 
Example 11
Source File: TypeMirrorAppender.java    From FreeBuilder with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitWildcard(WildcardType t, QualifiedNameAppendable a) {
  a.append("?");
  if (t.getSuperBound() != null) {
    a.append(" super ");
    t.getSuperBound().accept(this, a);
  }
  if (t.getExtendsBound() != null) {
    a.append(" extends ");
    t.getExtendsBound().accept(this, a);
  }
  return null;
}
 
Example 12
Source File: TypeSimplifier.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
@Override public boolean apply(TypeMirror arg) {
  if (arg.getKind() == TypeKind.WILDCARD) {
    WildcardType wildcard = (WildcardType) arg;
    if (wildcard.getExtendsBound() == null || isJavaLangObject(wildcard.getExtendsBound())) {
      // This is <?>, unless there's a super bound, in which case it is <? super Foo> and
      // is erased.
      return (wildcard.getSuperBound() != null);
    }
  }
  return true;
}
 
Example 13
Source File: TypeSimplifier.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
@Override public Void visitWildcard(WildcardType t, Void p) {
  for (TypeMirror bound : new TypeMirror[] {t.getSuperBound(), t.getExtendsBound()}) {
    if (bound != null) {
      visit(bound, p);
    }
  }
  return null;
}
 
Example 14
Source File: TypeSimplifier.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
@Override public StringBuilder visitWildcard(WildcardType type, StringBuilder sb) {
  sb.append("?");
  TypeMirror extendsBound = type.getExtendsBound();
  TypeMirror superBound = type.getSuperBound();
  if (superBound != null) {
    sb.append(" super ");
    visit(superBound, sb);
  } else if (extendsBound != null) {
    sb.append(" extends ");
    visit(extendsBound, sb);
  }
  return sb;
}
 
Example 15
Source File: MoreTypes.java    From auto-parcel with Apache License 2.0 5 votes vote down vote up
@Override
public Integer visitWildcard(WildcardType t, Set<Element> visiting) {
    int result = hashKind(HASH_SEED, t);
    result *= HASH_MULTIPLIER;
    result +=
            (t.getExtendsBound() == null) ? 0 : t.getExtendsBound().accept(this, visiting);
    result *= HASH_MULTIPLIER;
    result += (t.getSuperBound() == null) ? 0 : t.getSuperBound().accept(this, visiting);
    return result;
}
 
Example 16
Source File: TypeSimplifier.java    From SimpleWeibo with Apache License 2.0 5 votes vote down vote up
@Override public Void visitWildcard(WildcardType t, Void p) {
  for (TypeMirror bound : new TypeMirror[] {t.getSuperBound(), t.getExtendsBound()}) {
    if (bound != null) {
      visit(bound, p);
    }
  }
  return null;
}
 
Example 17
Source File: TypeSimplifier.java    From SimpleWeibo with Apache License 2.0 5 votes vote down vote up
@Override public StringBuilder visitWildcard(WildcardType type, StringBuilder sb) {
  sb.append("?");
  TypeMirror extendsBound = type.getExtendsBound();
  TypeMirror superBound = type.getSuperBound();
  if (superBound != null) {
    sb.append(" super ");
    visit(superBound, sb);
  } else if (extendsBound != null) {
    sb.append(" extends ");
    visit(extendsBound, sb);
  }
  return sb;
}
 
Example 18
Source File: DeclaredTypeCollector.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitWildcard(WildcardType t, Collection<DeclaredType> p) {
    if (t.getExtendsBound() != null) {
        visit(t.getExtendsBound(), p);
    }
    if (t.getSuperBound() != null) {
        visit(t.getSuperBound(), p);
    }
    return DEFAULT_VALUE;
}
 
Example 19
Source File: ElementNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static String print( TypeMirror tm ) {
    StringBuilder sb;
    switch (tm.getKind()) {
        case DECLARED:
            DeclaredType dt = (DeclaredType)tm;
            sb = new StringBuilder(dt.asElement().getSimpleName().toString());
            List<? extends TypeMirror> typeArgs = dt.getTypeArguments();
            if (!typeArgs.isEmpty()) {
                sb.append("<"); // NOI18N
                for (Iterator<? extends TypeMirror> it = typeArgs.iterator(); it.hasNext();) {
                    TypeMirror ta = it.next();
                    sb.append(print(ta));
                    if (it.hasNext()) {
                        sb.append(", "); // NOI18N
                    }
                }
                sb.append(">"); // NOI18N
            }                    
            return sb.toString();
        case TYPEVAR:
            TypeVariable tv = (TypeVariable)tm;
            sb = new StringBuilder(tv.asElement().getSimpleName().toString());
            return sb.toString();
        case ARRAY:
            ArrayType at = (ArrayType)tm;
            sb = new StringBuilder(print(at.getComponentType()));
            sb.append("[]"); // NOI18N
            return sb.toString();
        case WILDCARD:
            WildcardType wt = (WildcardType)tm;
            sb = new StringBuilder("?"); // NOI18N
            if (wt.getExtendsBound() != null) {
                sb.append(" extends "); // NOI18N
                sb.append(print(wt.getExtendsBound()));
            }
            if (wt.getSuperBound() != null) {
                sb.append(" super "); // NOI18N
                sb.append(print(wt.getSuperBound()));
            }
            return sb.toString();
        default:
            return tm.toString();
    }
}
 
Example 20
Source File: ExportNonAccessibleElement.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Boolean visitWildcard(WildcardType wild, Void arg1) {
    TypeMirror eb = wild.getExtendsBound();
    TypeMirror sb = wild.getSuperBound();
    return (eb != null && eb.accept(this, arg1)) ||
           (sb != null && sb.accept(this, arg1));
}