Java 8 ParameterizedType - 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 ParameterizedType class.

This code example shows how to use the following methods:getActualTypeArguments, getOwnerType, getRawType
    public boolean equals(Object obj) { 
        if (this == obj) {
            return true; 
        } else if (obj instanceof ParameterizedType) {
            ParameterizedType that = (ParameterizedType) obj;
            Type thatOwnerType = that.getOwnerType();
            Type thatRawType = that.getRawType();
            return (ownerType == null ? thatOwnerType == null : ownerType.equals(thatOwnerType)) && (rawType == null ? thatRawType == null : rawType.equals(thatRawType)) && Arrays.equals(actualTypeArguments, that.getActualTypeArguments());
        } else { 
            return false; 
        } 
 
    } 
 
    @Override 
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(rawType);
        if (actualTypeArguments.length > 0) {
            sb.append("<");
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActualTypeArguments, getRawType
			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);
	} 
 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActualTypeArguments, getOwnerType, getRawType
    public boolean equals(Object obj) { 
        if (this == obj) {
            return true; 
        } else if (obj instanceof ParameterizedType) {
            ParameterizedType that = (ParameterizedType) obj;
            Type thatOwnerType = that.getOwnerType();
            Type thatRawType = that.getRawType();
            return (ownerType == null ? thatOwnerType == null : ownerType.equals(thatOwnerType)) && (rawType == null ? thatRawType == null : rawType.equals(thatRawType)) && Arrays.equals(actualTypeArguments, that.getActualTypeArguments());
        } else { 
            return false; 
        } 
 
    } 
 
    @Override 
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(rawType);
        if (actualTypeArguments.length > 0) {
            sb.append("<");
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActualTypeArguments
    private final Type type;
    private Locale locale;
 
    public Transformer() { 
        ParameterizedType ptype = (ParameterizedType) getClass().getGenericSuperclass();
        this.type = ptype.getActualTypeArguments()[0];
    } 
 
    @Override 
    public String toString(Object o) {
        return o.toString(); 
    } 
 
    @Override 
    public final Object fromString(String s) {
        return transform(s);
    } 
 
    @Override 
    public boolean canConvert(Class type) {
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getOwnerType, getRawType
    } else if (type instanceof CompositeType) {
      return type;
 
    } else if (type instanceof ParameterizedType) {
      ParameterizedType p = (ParameterizedType) type;
      return new ParameterizedTypeImpl(p.getOwnerType(),
          p.getRawType(), p.getActualTypeArguments());
 
    } else if (type instanceof GenericArrayType) {
      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;
    } 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActualTypeArguments, getRawType
		if (!(t instanceof ParameterizedType))
		{ 
			throw new RuntimeException("Invalid TypeToken; must specify type parameters");
		} 
		ParameterizedType pt = (ParameterizedType) t;
		if (pt.getRawType() != TypeToken.class)
		{ 
			throw new RuntimeException("Invalid TypeToken; must directly extend TypeToken");
		} 
		return pt.getActualTypeArguments()[0];
	} 
 
	/** 
	 * Gets type token for the given {@code Class} instance. 
	 */ 
	public static <T> TypeToken<T> get(Class<T> type)
	{ 
		return new SimpleTypeToken<T>(type);
	} 
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActualTypeArguments
 
    public SetColumnMapper(Field field) {
        super(field);
         
        ParameterizedType stringListType = (ParameterizedType) field.getGenericType();
        this.clazz = (Class<?>) stringListType.getActualTypeArguments()[0];
        this.serializer       = SerializerTypeInferer.getSerializer(this.clazz);
    } 
 
    @Override 
    public String getColumnName() {
        return this.columnName;
    } 
 
    @Override 
    public boolean fillMutationBatch(Object entity, ColumnListMutation<String> clm, String prefix) throws Exception {
        Set<?> set = (Set<?>) field.get(entity);
        if(set == null) {
            if(columnAnnotation.nullable()) 
                return false; // skip 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActualTypeArguments, getOwnerType, getRawType
    public boolean equals(Object obj) { 
        if (this == obj) {
            return true; 
        } else if (obj instanceof ParameterizedType) {
            ParameterizedType that = (ParameterizedType) obj;
            Type thatOwnerType = that.getOwnerType();
            Type thatRawType = that.getRawType();
            return (ownerType == null ? thatOwnerType == null : ownerType.equals(thatOwnerType)) && (rawType == null ? thatRawType == null : rawType.equals(thatRawType)) && Arrays.equals(actualTypeArguments, that.getActualTypeArguments());
        } else { 
            return false; 
        } 
 
    } 
 
    @Override 
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(rawType);
        if (actualTypeArguments.length > 0) {
            sb.append("<");
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getRawType
     * 
     * @param type the parameterized type 
     * @return value 
     */ 
    protected Object getPtValue(ParameterizedType type) {
        return getValue(type.getRawType());
    } 
 
    /** 
     * Get value, use type to narrow down exact value. 
     * 
     * @param type the injection point type 
     * @return value 
     */ 
    protected abstract Object getClassValue(Class<?> type);
 
    public String getType() {
        return type;
    } 
 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActualTypeArguments
     * @param type the type 
     * @param index the component index 
     * @return component's class or null if cannot be determined 
     */ 
    static Type getComponentType(ParameterizedType type, int index) {
        Type[] tp = type.getActualTypeArguments();
        if (index + 1 > tp.length)
            return null; 
 
        return tp[index];
    } 
 
    @Override 
    public Class<?> getType(ConfigVisitor visitor, ConfigVisitorNode previous) {
        Deque<ConfigVisitorNode> nodes = visitor.getCurrentNodes();
        if (nodes.isEmpty())
            throw new IllegalArgumentException("Cannot determine type - insufficient info on configuration!");
 
        ConfigVisitorNode current = nodes.pop();
        try { 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 ParameterizedType Questions & Answers:

See Code Examples for Java 8 ParameterizedType Methods: