< prev index next >

src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/model/nav/GenericArrayTypeImpl.java

Print this page




  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.bind.v2.model.nav;
  27 
  28 import java.lang.reflect.GenericArrayType;
  29 import java.lang.reflect.Type;
  30 
  31 /**
  32  * Implementation of GenericArrayType interface for core reflection.
  33  */
  34 final class GenericArrayTypeImpl implements GenericArrayType {
  35     private Type genericComponentType;
  36 
  37     GenericArrayTypeImpl(Type ct) {
  38         assert ct!=null;
  39         genericComponentType = ct;
  40     }
  41 
  42     /**
  43      * Returns  a <tt>Type</tt> object representing the component type
  44      * of this array.
  45      *
  46      * @return a <tt>Type</tt> object representing the component type
  47      *         of this array
  48      * @since 1.5
  49      */
  50     public Type getGenericComponentType() {
  51         return genericComponentType; // return cached component type
  52     }
  53 
  54     public String toString() {
  55         Type componentType = getGenericComponentType();
  56         StringBuilder sb = new StringBuilder();
  57 
  58         if (componentType instanceof Class)
  59             sb.append(((Class) componentType).getName());
  60         else
  61             sb.append(componentType.toString());
  62         sb.append("[]");
  63         return sb.toString();
  64     }
  65 
  66     @Override


  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.bind.v2.model.nav;
  27 
  28 import java.lang.reflect.GenericArrayType;
  29 import java.lang.reflect.Type;
  30 
  31 /**
  32  * Implementation of GenericArrayType interface for core reflection.
  33  */
  34 final class GenericArrayTypeImpl implements GenericArrayType {
  35     private Type genericComponentType;
  36 
  37     GenericArrayTypeImpl(Type ct) {
  38         assert ct!=null;
  39         genericComponentType = ct;
  40     }
  41 
  42     /**
  43      * Returns  a {@code Type} object representing the component type
  44      * of this array.
  45      *
  46      * @return a {@code Type} object representing the component type
  47      *         of this array
  48      * @since 1.5
  49      */
  50     public Type getGenericComponentType() {
  51         return genericComponentType; // return cached component type
  52     }
  53 
  54     public String toString() {
  55         Type componentType = getGenericComponentType();
  56         StringBuilder sb = new StringBuilder();
  57 
  58         if (componentType instanceof Class)
  59             sb.append(((Class) componentType).getName());
  60         else
  61             sb.append(componentType.toString());
  62         sb.append("[]");
  63         return sb.toString();
  64     }
  65 
  66     @Override
< prev index next >