Package java.lang.reflect

Examples of java.lang.reflect.Type


        bound = fromType(lowerBounds[0]);
      }
      return new BoundedReferenceType((ReferenceType) bound, isExtends, getWorld());
    } else if (aType instanceof GenericArrayType) {
      GenericArrayType gt = (GenericArrayType) aType;
      Type componentType = gt.getGenericComponentType();
      return UnresolvedType.makeArray(fromType(componentType), 1).resolve(getWorld());
    }
    return ResolvedType.MISSING;
  }
View Full Code Here


    */
  }

  private void introspectTypes()
  {
    Type retType;

    if (_field instanceof Field)
      retType = ((Field) _field).getGenericType();
    else
      retType = ((Method) _field).getGenericReturnType();
View Full Code Here

      setJoinTable(new JoinTableConfig(joinTableAnn));
  }

  private void introspectTypes()
  {
    Type retType;

    if (_field instanceof Field)
      retType = ((Field) _field).getGenericType();
    else
      retType = ((Method) _field).getGenericReturnType();
View Full Code Here

      _orderBy = orderByAnn.value();
  }

  private void introspectTypes()
  {
    Type retType;

    if (_field instanceof Field)
      retType = ((Field) _field).getGenericType();
    else
      retType = ((Method) _field).getGenericReturnType();
View Full Code Here

      else
        return null;
    }
    else if (type instanceof ParameterizedType) {
      ParameterizedType ptype = (ParameterizedType) type;
      Type rawType = ptype.getRawType();

      if (rawType instanceof Class) {
        Class rawClass = (Class) rawType;

        if (Map.class.isAssignableFrom(rawClass)) {
          Type[] args = ptype.getActualTypeArguments();

          if (args.length != 2)
            throw new JAXBException(L.l("unexpected number of generic arguments for Map<>: {0}", args.length));

          Property keyProperty = createProperty(args[0], anyType);
          Property valueProperty = createProperty(args[1], anyType);

          return new MapProperty(rawClass, keyProperty, valueProperty);
        }

        if (Collection.class.isAssignableFrom(rawClass)) {
          Type[] args = ptype.getActualTypeArguments();

          if (args.length != 1)
            throw new JAXBException(L.l("unexpected number of generic arguments for List<>: {0}", args.length));

          Property componentProperty = createProperty(args[0], anyType);

          if (xmlList) {
            if (! (componentProperty instanceof CDataProperty))
              throw new JAXBException(L.l("Elements annotated with @XmlList or @XmlValue must be simple XML types"));

            CDataProperty cdataProperty = (CDataProperty) componentProperty;

            return new XmlListCollectionProperty(cdataProperty, rawClass);
          }
          else if (List.class.isAssignableFrom(rawClass))
            return new ListProperty(componentProperty);
          else
            return new CollectionProperty(componentProperty);
        }
      }
    }
    else if (type instanceof GenericArrayType) {
      Type component = ((GenericArrayType) type).getGenericComponentType();

      if (byte.class.equals(component))
        return ByteArrayProperty.PROPERTY;

      // XXX other component types?
View Full Code Here

      for (Type argument : arguments)
        introspectType(argument, jaxbClasses);
    }
    else if (type instanceof GenericArrayType) {
      Type component = ((GenericArrayType) type).getGenericComponentType();
      introspectType(component, jaxbClasses);
    }
    else if (type != null) {
      // Type variables must be instantiated
      throw new UnsupportedOperationException(L.l("Method arguments cannot have uninstantiated type variables or wildcards ({0} of type {1})", type, type.getClass().getName()));
View Full Code Here

  }


  private ResultWrapper putWithEncoding(String encoding, int n)
          throws Exception{
    Type listType = new TypeToken<List<JSONEvent>>() {
    }.getType();
    List<JSONEvent> events = Lists.newArrayList();
    Random rand = new Random();
    for (int i = 0; i < n; i++) {
      Map<String, String> input = Maps.newHashMap();
View Full Code Here

  }

  @Override
  protected Schema createSchema(Type type, Map<String,Schema> names) {
    if (type instanceof GenericArrayType) {                  // generic array
      Type component = ((GenericArrayType)type).getGenericComponentType();
      if (component == Byte.TYPE)                            // byte array
        return Schema.create(Schema.Type.BYTES);          
      Schema result = Schema.createArray(createSchema(component, names));
      setElement(result, component);
      return result;
View Full Code Here

    static JAXBBeanInfo findFromTypeAdapter(JAXBContextProxy context,
                                            @SuppressWarnings("rawtypes")
                                             Class<? extends XmlAdapter> aclass) {
        Class<?> c2 = aclass;
        Type sp = c2.getGenericSuperclass();
        while (!XmlAdapter.class.equals(c2) && c2 != null) {
            sp = c2.getGenericSuperclass();
            c2 = c2.getSuperclass();
        }
        if (sp instanceof ParameterizedType) {
            Type tp = ((ParameterizedType)sp).getActualTypeArguments()[0];
            if (tp instanceof Class) {
                return getBeanInfo(context, (Class<?>)tp);
            }
        }
        return null;
View Full Code Here

        String namespace = part.getElementQName().getNamespaceURI();
        XmlAccessType accessType = Utils.getXmlAccessType(cls);
//
        for (Field f : Utils.getFields(cls, accessType)) {
            //map field
            Type type = Utils.getFieldType(f);
            //we want to return the right type for collections so if we get null
            //from the return type we check if it's ParameterizedType and get the
            //generic return type.
            if ((type == null) && (f.getGenericType() instanceof ParameterizedType)) {
                type = f.getGenericType();
            }
            if (generateGenericType(type)) {
                buildGenericElements(schema, seq, f);
            } else {
                JAXBBeanInfo beanInfo = getBeanInfo(type);
                if (beanInfo != null) {
                    XmlElement xmlElementAnno = f.getAnnotation(XmlElement.class);
                    addElement(schema, seq, beanInfo, new QName(namespace, f.getName()), isArray(type), xmlElementAnno);
                }
            }
        }
        for (Method m : Utils.getGetters(cls, accessType)) {
            //map method
            Type type = Utils.getMethodReturnType(m);
            // we want to return the right type for collections so if we get null
            // from the return type we check if it's ParameterizedType and get the
            // generic return type.
            if ((type == null) && (m.getGenericReturnType() instanceof ParameterizedType)) {
                type = m.getGenericReturnType();
View Full Code Here

TOP

Related Classes of java.lang.reflect.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.