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

This code example shows how to use the following methods:equals
	} 
	 
	public final void testInexactSupertype(Type superType, Type subType) {
		if (superType instanceof ParameterizedType || superType instanceof Class) {
			// test if it's not exact 
			GenericTypeReflectorTest.assertFalse(superType.equals(getExactSuperType(subType, GenericTypeReflectorTest.getClassType(superType))));
		} 
	} 
	 
	protected abstract Type getExactSuperType(Type type, Class<?> searchClass);
} 
5
CodeRank
This code example shows how to use the following methods:equals
			type.equals( short.class ) ||
			type.equals( int.class );
	} 
	 
	public static final boolean isReferenceType( final Type type ) {
		if ( JavaTypes.isObjectType( type ) ) {
			return ! type.equals( Category1.class ) &&
				! type.equals( Category2.class );
		} else { 
			return false; 
		} 
	} 
	 
	public static final boolean isCategory1( final Type type ) {
		return ( ! type.equals( void.class ) ) &&
			! isCategory2( type );
	} 
	 
	public static final boolean isCategory2( final Type type ) {
		return type.equals( long.class ) ||
5
CodeRank
This code example shows how to use the following methods:hashCode
   * Unsafe. Constructs a type literal manually. 
   */ 
  @SuppressWarnings("unchecked") 
  TypeToken(Type type) {
    this.type = $Gson$Types.canonicalize($Gson$Preconditions.checkNotNull(type));
    this.rawType = (Class<? super T>) $Gson$Types.getRawType(this.type);
    this.hashCode = this.type.hashCode();
  } 
 
  /** 
   * Returns the type from super class's type parameter in {@link $Gson$Types#canonicalize 
   * canonical form}. 
   */ 
  static Type getSuperclassTypeParameter(Class<?> subclass) {
    Type superclass = subclass.getGenericSuperclass();
    if (superclass instanceof Class) {
      throw new RuntimeException("Missing type parameter.");
    } 
    ParameterizedType parameterized = (ParameterizedType) superclass;
    return $Gson$Types.canonicalize(parameterized.getActualTypeArguments()[0]);
5
CodeRank
This code example shows how to use the following methods:equals
 
	@Override 
	public boolean equals(Object obj) { 
		try{ 
			Generic<?> o = (Generic<?>)obj; 
			return genericType.equals(o.genericType()); 
		}catch(Exception e){ 
			return false; 
		} 
	} 
	 
	@Override 
	public int hashCode() { 
		return genericType.hashCode(); 
	} 
	 
	@Override 
	public String toString() { 
		return genericType.toString(); 
	} 
4
CodeRank

Related Java 8 Type Questions & Answers:

See Code Examples for Java 8 Type Methods: