Java 8 WildcardType - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 WildcardType class.

This code example shows how to use the following methods:getLowerBounds, getUpperBounds
	private String nameFor(TypeVariable<?> variable) {
		return StringUtils.lowercaseFirst(variable.getName());
	} 
 
	private String nameFor(WildcardType wild) {
		if ((wild.getLowerBounds().length != 0)) {
			return nameFor(wild.getLowerBounds()[0]);
		} else { 
			return nameFor(wild.getUpperBounds()[0]);
		} 
	} 
 
	private String nameFor(ParameterizedType type) {
		Class<?> raw = (Class<?>) type.getRawType();
		if (Collection.class.isAssignableFrom(raw)) {
			return nameFor(type.getActualTypeArguments()[0]) + "List";
		} 
		return nameFor(raw);
	} 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds, getUpperBounds
	@Override 
	public boolean equals(Object obj) { 
		if (! (obj instanceof WildcardType))
			return false; 
		WildcardType other = (WildcardType)obj;
		return Arrays.equals(lowerBounds, other.getLowerBounds())
			&& Arrays.equals(upperBounds, other.getUpperBounds());
	} 
	 
	@Override 
	public int hashCode() { 
		return Arrays.hashCode(lowerBounds) ^ Arrays.hashCode(upperBounds);
	} 
	 
	@Override 
	public String toString() {
		if (lowerBounds.length > 0) {
			return "? super " + GenericTypeReflector.getTypeName(lowerBounds[0]);
		} else if (upperBounds[0] == Object.class) {
			return "?";			 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds, getUpperBounds
	public boolean equals(Object obj) 
	{ 
		if (!(obj instanceof WildcardType))
			return false; 
		WildcardType other = (WildcardType) obj;
		return Arrays.equals(lowerBounds, other.getLowerBounds())
				&& Arrays.equals(upperBounds, other.getUpperBounds());
	} 
 
	@Override 
	public int hashCode() 
	{ 
		return Arrays.hashCode(lowerBounds) ^ Arrays.hashCode(upperBounds);
	} 
 
	@Override 
	public String toString()
	{ 
		if (lowerBounds.length > 0)
		{ 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds, getUpperBounds
      GenericArrayType g = (GenericArrayType) type;
      return new GenericArrayTypeImpl(g.getGenericComponentType());
 
    } else if (type instanceof WildcardType) {
      WildcardType w = (WildcardType) type;
      return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());
 
    } else { 
      // type is either serializable as-is or unsupported 
      return type;
    } 
  } 
 
  public static Class<?> getRawType(Type type) {
    if (type instanceof Class<?>) {
      // type is a normal class. 
      return (Class<?>) type;
 
    } else if (type instanceof ParameterizedType) {
      ParameterizedType parameterizedType = (ParameterizedType) type;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds, getUpperBounds
            ? Types.newParameterizedTypeWithOwner(newOwnerType, original.getRawType(), args)
            : original;
 
      } else if (toResolve instanceof WildcardType) {
        WildcardType original = (WildcardType) toResolve;
        Type[] originalLowerBound = original.getLowerBounds();
        Type[] originalUpperBound = original.getUpperBounds();
 
        if (originalLowerBound.length == 1) {
          Type lowerBound = resolveType(originalLowerBound[0]);
          if (lowerBound != originalLowerBound[0]) {
            return Types.supertypeOf(lowerBound);
          } 
        } else if (originalUpperBound.length == 1) {
          Type upperBound = resolveType(originalUpperBound[0]);
          if (upperBound != originalUpperBound[0]) {
            return Types.subtypeOf(upperBound);
          } 
        } 
        return original;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds, getUpperBounds
    public boolean equals(Object o) {
        if(!(o instanceof WildcardType)) {
            return false; 
        } 
        WildcardType that = (WildcardType) o;
        return Arrays.equals(getLowerBounds(), that.getLowerBounds()) &&
                Arrays.equals(getUpperBounds(), that.getUpperBounds());
    } 
 
    @Override 
    public int hashCode() { 
        return 31 * Arrays.hashCode(getLowerBounds()) +
                Arrays.hashCode(getUpperBounds());
    } 
 
    @Override 
    public String toString() {
        StringBuilder sb = new StringBuilder("?");
        if (extendsBound.length() > 0) {
            sb.append(" extends ").append(extendsBound);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds
	 * @param variable The type variable where the wildcard is a parameter for. 
	 */ 
	public CaptureTypeImpl(WildcardType wildcard, TypeVariable<?> variable) {
		this.wildcard = wildcard;
		this.variable = variable;
		this.lowerBounds = wildcard.getLowerBounds();
	} 
	 
	/** 
	 * Initialize this CaptureTypeImpl. 
	 * This is needed for type variable bounds referring to each other: we need the capture of the argument. 
	 */ 
	void init(VarMap varMap) {
		ArrayList<Type> upperBoundsList = new ArrayList<Type>();
		upperBoundsList.addAll(Arrays.asList(varMap.map(variable.getBounds())));
		 
		List<Type> wildcardUpperBounds = Arrays.asList(wildcard.getUpperBounds());
		if (wildcardUpperBounds.size() > 0 && wildcardUpperBounds.get(0) == Object.class) {
			// skip the Object bound, we already have a first upper bound from 'variable' 
			upperBoundsList.addAll(wildcardUpperBounds.subList(1, wildcardUpperBounds.size()));
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds
	 */ 
	public CaptureTypeImpl(WildcardType wildcard, TypeVariable<?> variable)
	{ 
		this.wildcard = wildcard;
		this.variable = variable;
		this.lowerBounds = wildcard.getLowerBounds();
	} 
 
	/** 
	 * Initialize this CaptureTypeImpl. This is needed for type variable bounds 
	 * referring to each other: we need the capture of the argument. 
	 */ 
	void init(VarMap varMap)
	{ 
		ArrayList<Type> upperBoundsList = new ArrayList<Type>();
		upperBoundsList.addAll(Arrays.asList(varMap.map(variable.getBounds())));
		upperBoundsList.addAll(Arrays.asList(wildcard.getUpperBounds()));
		upperBounds = new Type[upperBoundsList.size()];
		upperBoundsList.toArray(upperBounds);
	} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds, getUpperBounds
    public boolean equals(Object o) {
        if(!(o instanceof WildcardType)) {
            return false; 
        } 
        WildcardType that = (WildcardType) o;
        return Arrays.equals(getLowerBounds(), that.getLowerBounds()) && 
                Arrays.equals(getUpperBounds(), that.getUpperBounds());
    } 
     
    @Override 
    public int hashCode() { 
        return 31 * Arrays.hashCode(getLowerBounds()) + 
                Arrays.hashCode(getUpperBounds());
    } 
     
    @Override 
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("?");
        if (extendsBound.length() > 0) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLowerBounds, getUpperBounds
        if (generic instanceof Class<?>)
            return (Class<?>) generic;
 
        if (generic instanceof WildcardType) {
            WildcardType wildcarded = (WildcardType) generic;
            if (wildcarded.getLowerBounds().length == 0 && Object.class.equals(wildcarded.getUpperBounds()[0]))
                return String.class;
        } 
 
        throw new UnsupportedValueTypeException(type);
    } 
 
    @Override public Object nilValue() {
        return new ArrayList<Object>(0);
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 WildcardType Methods: