< prev index next >

src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/GenericArrayTypeImpl.java

Print this page




  48      * @return a generic array type with the desired component type
  49      */
  50     public static GenericArrayTypeImpl make(Type ct) {
  51         return new GenericArrayTypeImpl(ct);
  52     }
  53 
  54 
  55     /**
  56      * Returns a {@code Type} object representing the component type
  57      * of this array.
  58      *
  59      * @return a {@code Type} object representing the component type
  60      *     of this array
  61      * @since 1.5
  62      */
  63     public Type getGenericComponentType() {
  64         return genericComponentType; // return cached component type
  65     }
  66 
  67     public String toString() {
  68         Type componentType = getGenericComponentType();
  69         StringBuilder sb = new StringBuilder();
  70 
  71         if (componentType instanceof Class)
  72             sb.append(((Class)componentType).getName() );
  73         else
  74             sb.append(componentType.toString());
  75         sb.append("[]");
  76         return sb.toString();
  77     }
  78 
  79     @Override
  80     public boolean equals(Object o) {
  81         if (o instanceof GenericArrayType) {
  82             GenericArrayType that = (GenericArrayType) o;
  83 
  84             return Objects.equals(genericComponentType, that.getGenericComponentType());
  85         } else
  86             return false;
  87     }
  88 
  89     @Override
  90     public int hashCode() {
  91         return Objects.hashCode(genericComponentType);
  92     }
  93 }


  48      * @return a generic array type with the desired component type
  49      */
  50     public static GenericArrayTypeImpl make(Type ct) {
  51         return new GenericArrayTypeImpl(ct);
  52     }
  53 
  54 
  55     /**
  56      * Returns a {@code Type} object representing the component type
  57      * of this array.
  58      *
  59      * @return a {@code Type} object representing the component type
  60      *     of this array
  61      * @since 1.5
  62      */
  63     public Type getGenericComponentType() {
  64         return genericComponentType; // return cached component type
  65     }
  66 
  67     public String toString() {
  68         return getGenericComponentType().getTypeName() + "[]";








  69     }
  70 
  71     @Override
  72     public boolean equals(Object o) {
  73         if (o instanceof GenericArrayType) {
  74             GenericArrayType that = (GenericArrayType) o;
  75 
  76             return Objects.equals(genericComponentType, that.getGenericComponentType());
  77         } else
  78             return false;
  79     }
  80 
  81     @Override
  82     public int hashCode() {
  83         return Objects.hashCode(genericComponentType);
  84     }
  85 }
< prev index next >