当前位置: 首页>>代码示例>>Java>>正文


Java JType.isArray方法代码示例

本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.JType.isArray方法的典型用法代码示例。如果您正苦于以下问题:Java JType.isArray方法的具体用法?Java JType.isArray怎么用?Java JType.isArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.core.ext.typeinfo.JType的用法示例。


在下文中一共展示了JType.isArray方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: accept

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
public void accept(JType type, TypeVisitor tv){
	if (type.isAnnotation() != null){
		tv.visitAnnotationType(type.isAnnotation());
	} else if (type.isArray() != null){
		tv.visitArrayType(type.isArray());
	}else if (type.isEnum() != null){
		tv.visitEnumType(type.isEnum());
	}else if (type.isGenericType() != null){
		tv.visitGenericType(type.isGenericType());
	}else if (type.isParameterized() != null){
		tv.visitParameterizedType(type.isParameterized());
	}else if (type.isPrimitive() != null){
		tv.visitPrimitiveType(type.isPrimitive());
	}else if (type.isRawType() != null){
		tv.visitRawType(type.isRawType());
	}else if (type.isTypeParameter() != null){
		tv.visitTypeParameter(type.isTypeParameter());
	}else if (type.isWildcard() != null){
		tv.visitWildcardType(type.isWildcard());
	}
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:22,代码来源:TypeOracleVisitable.java

示例2: getAssociationType

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * get association type.
 *
 * @param ppropertyDescriptor property description
 * @param puseField use field
 * @return JClassType
 */
public JClassType getAssociationType(final PropertyDescriptor ppropertyDescriptor,
    final boolean puseField) {
  final JType type = this.getElementType(ppropertyDescriptor, puseField);
  if (type == null) {
    return null;
  }
  final JArrayType jarray = type.isArray();
  if (jarray != null) {
    return jarray.getComponentType().isClassOrInterface();
  }
  final JParameterizedType jptype = type.isParameterized();
  JClassType[] typeArgs;
  if (jptype == null) {
    final JRawType jrtype = type.isRawType();
    typeArgs = jrtype.getGenericType().getTypeParameters();
  } else {
    typeArgs = jptype.getTypeArgs();
  }
  // it is either a Iterable or a Map use the last type arg.
  return typeArgs[typeArgs.length - 1].isClassOrInterface();
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:29,代码来源:BeanHelper.java

示例3: getLoadableTypeName

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * @param returnType
 * @return
 */
private String getLoadableTypeName(JType returnType) {
  if (returnType.isArray() != null) {
    final StringBuilder b = new StringBuilder();
    while(returnType.isArray() != null) {
      b.append("[");
      returnType = returnType.isArray().getComponentType();
    }
    return b
          .append("L")
          .append(returnType.getQualifiedSourceName())
          .append(";")
          .toString();
  }
  return returnType.getQualifiedSourceName();
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:20,代码来源:ModelArtifact.java

示例4: typeName

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * @param boxed true if the primitive should be boxed. Useful when use in a parameterized type.
 * @param type the type
 *
 * @return the {@link TypeName}
 */
public TypeName typeName( boolean boxed, JType type ) {
    if ( null != type.isPrimitive() ) {
        return primitiveName( type.isPrimitive(), boxed );
    } else if ( null != type.isParameterized() ) {
        return parameterizedName( type.isParameterized() );
    } else if ( null != type.isGenericType() ) {
        return genericName( type.isGenericType() );
    } else if ( null != type.isArray() ) {
        return arrayName( type.isArray() );
    } else if ( null != type.isTypeParameter() ) {
        return typeVariableName( type.isTypeParameter() );
    } else if ( null != type.isWildcard() ) {
        return wildcardName( type.isWildcard() );
    } else {
        return className( type.isClassOrInterface() );
    }
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:24,代码来源:JTypeName.java

示例5: rawName

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * @param boxed true if the primitive should be boxed. Useful when use in a parameterized type.
 * @param type type to convert
 *
 * @return the raw {@link TypeName} without parameter
 */
public TypeName rawName( boolean boxed, JType type ) {
    if ( null != type.isPrimitive() ) {
        return primitiveName( type.isPrimitive(), boxed );
    } else if ( null != type.isParameterized() ) {
        return className( type.isParameterized().getRawType() );
    } else if ( null != type.isGenericType() ) {
        return className( type.isGenericType().getRawType() );
    } else if ( null != type.isArray() ) {
        return arrayName( type.isArray() );
    } else if ( null != type.isTypeParameter() ) {
        return typeVariableName( type.isTypeParameter() );
    } else {
        return className( type.isClassOrInterface() );
    }
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:22,代码来源:JTypeName.java

示例6: isPrimitive

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private boolean isPrimitive(JType clazz){
  if(clazz == null){
    return false;
  }else if(clazz.isPrimitive() != null || String.class.getName().equalsIgnoreCase(clazz.getQualifiedSourceName())){
    return true;
  }else if(clazz.isArray() != null){ //Array should be considered as primitive type
    return true;
  }else{
      String qualifiedSourceName = clazz.getQualifiedSourceName();
      for (JPrimitiveType primitiveType : JPrimitiveType.values()) {
        if(primitiveType.getQualifiedBoxedSourceName().equalsIgnoreCase(qualifiedSourceName) ||
            primitiveType.getQualifiedSourceName().equalsIgnoreCase(qualifiedSourceName)){
          return true;
        }
      }
      return false;
  }
}
 
开发者ID:seanchenxi,项目名称:gwt-storage,代码行数:19,代码来源:StorageKeyProviderMethod.java

示例7: isValideType

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private boolean isValideType(JType type){
  if(type == null)
    return false;

  if(type.isInterface() != null)
    return false;

  if(type.isPrimitive() != null)
    return true;

  JClassType aClass = type.isClass();
  if(aClass != null && (aClass.isAssignableTo(serializableIntf) || aClass.isAssignableTo(isSerializableIntf))){
    return true;
  }

  JArrayType array = type.isArray();
  if(array == null) return false;
  return isValideType(array.getComponentType());
}
 
开发者ID:seanchenxi,项目名称:gwt-storage,代码行数:20,代码来源:StorageKeyProviderModel.java

示例8: isInteresting

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * @param returnType
 * @param modelInterface
 * @return
 */
private boolean isInteresting(final JType returnType, final JClassType modelInterface) {
  if (returnType.isArray() != null) {
    // All arrays are interesting, as we must prime java.lang.reflect.Array for runtime support
    return true;
  }
  final JClassType asClass = returnType.isClassOrInterface();
  if (asClass == null) {
    return false;
  }
  // All model classes are interesting.
  return asClass.isAssignableTo(modelInterface);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:18,代码来源:ModelArtifact.java

示例9: implementInterestingTypes

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * Print magic method initialization for all interesting types;
 * <p>
 * Currently, this will call Array.newInstance(Component.class, 0) for all array types,
 * thus initializing the model Class's ability to instantiate the arrays it requires,
 * plus calls X_Model.register(DependentModel.class) on all model types used as fields of
 * the current model type; thus ensuring all children will be fully de/serializable.
 *
 */
private void implementInterestingTypes(final JClassType type, final ClassBuffer out, final JClassType modelInterface,
    final Set<JType> interestingTypes) {
  interestingTypes.remove(type);
  if (interestingTypes.isEmpty()) {
    return;
  }
  out
    .outdent()
    .println("// Initialize our referenced array / model types")
    .println("static {")
    .indent();
  for (JType interestingType : interestingTypes) {
    if (interestingType.isArray() != null) {
      // Print a primer for runtime array reflection.
      final JType componentType = interestingType.isArray().getComponentType();
      final String array = out.addImport(Array.class);
      String component = out.addImport(componentType.getQualifiedSourceName());
      interestingType = componentType;
      while (interestingType.isArray() != null) {
        interestingType = interestingType.isArray().getComponentType();
        component += "[]";
      }

      out.println(array+".newInstance("+component+".class, 0);");
    }
    final JClassType asClass = interestingType.isClassOrInterface();
    if (asClass != null) {
      if (asClass.isAssignableTo(modelInterface)) {
        // We have a model type; so long as it is not the same type that we are currently generating,
        // we want to print X_Model.register() for the given type, so we can inherit all model types
        // that are referenced as fields of the current model type.
        if (!type.getName().equals(asClass.getName())) {
          final String referencedModel = out.addImport(asClass.getQualifiedSourceName());
          final String X_Model = out.addImport(X_Model.class);
          out.println(X_Model+".register("+referencedModel+".class);");
        }
      }
    }
  }
  out.outdent().println("}");
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:51,代码来源:ModelArtifact.java

示例10: extractBeanType

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * Extract the bean type from the type given in parameter. For {@link java.util.Collection}, it gives the bounded type. For {@link
 * java.util.Map}, it gives the second bounded type. Otherwise, it gives the type given in parameter.
 *
 * @param type type to extract the bean type
 * @param propertyName name of the property
 *
 * @return the extracted type
 */
private static Optional<JClassType> extractBeanType( TreeLogger logger, JacksonTypeOracle typeOracle, JType type, String propertyName
) {
    if ( null != type.isWildcard() ) {
        // we use the base type to find the serializer to use
        type = type.isWildcard().getBaseType();
    }

    if ( null != type.isRawType() ) {
        type = type.isRawType().getBaseType();
    }

    JArrayType arrayType = type.isArray();
    if ( null != arrayType ) {
        return extractBeanType( logger, typeOracle, arrayType.getComponentType(), propertyName );
    }

    JClassType classType = type.isClassOrInterface();
    if ( null == classType ) {
        return Optional.absent();
    } else if ( typeOracle.isIterable( classType ) ) {
        if ( (null == classType.isParameterized() || classType.isParameterized().getTypeArgs().length != 1) && (null == classType
                .isGenericType() || classType.isGenericType().getTypeParameters().length != 1) ) {
            logger.log( Type.INFO, "Expected one argument for the java.lang.Iterable '" + propertyName + "'. Applying annotations to " +
                    "type " + classType.getParameterizedQualifiedSourceName() );
            return Optional.of( classType );
        }
        if ( null != classType.isParameterized() ) {
            return extractBeanType( logger, typeOracle, classType.isParameterized().getTypeArgs()[0], propertyName );
        } else {
            return extractBeanType( logger, typeOracle, classType.isGenericType().getTypeParameters()[0].getBaseType(), propertyName );
        }
    } else if ( typeOracle.isMap( classType ) ) {
        if ( (null == classType.isParameterized() || classType.isParameterized().getTypeArgs().length != 2) && (null == classType
                .isGenericType() || classType.isGenericType().getTypeParameters().length != 2) ) {
            logger.log( Type.INFO, "Expected two arguments for the java.util.Map '" + propertyName + "'. Applying annotations to " +
                    "type " + classType.getParameterizedQualifiedSourceName() );
            return Optional.of( classType );
        }
        if ( null != classType.isParameterized() ) {
            return extractBeanType( logger, typeOracle, classType.isParameterized().getTypeArgs()[1], propertyName );
        } else {
            return extractBeanType( logger, typeOracle, classType.isGenericType().getTypeParameters()[1].getBaseType(), propertyName );
        }
    } else {
        return Optional.of( classType );
    }
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:57,代码来源:PropertyProcessor.java

示例11: replaceType

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * <p>replaceType</p>
 *
 * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object.
 * @param type a {@link com.google.gwt.core.ext.typeinfo.JType} object.
 * @param deserializeAs a {@link java.lang.annotation.Annotation} object.
 * @return a {@link com.google.gwt.core.ext.typeinfo.JType} object.
 * @throws com.google.gwt.core.ext.UnableToCompleteException if any.
 */
public JType replaceType( TreeLogger logger, JType type, Annotation deserializeAs ) throws UnableToCompleteException {
    JClassType classType = type.isClassOrInterface();
    if ( null == classType ) {
        return type;
    }

    Optional<JClassType> typeAs = getClassFromJsonDeserializeAnnotation( logger, deserializeAs, "as" );
    Optional<JClassType> keyAs = getClassFromJsonDeserializeAnnotation( logger, deserializeAs, "keyAs" );
    Optional<JClassType> contentAs = getClassFromJsonDeserializeAnnotation( logger, deserializeAs, "contentAs" );

    if ( !typeAs.isPresent() && !keyAs.isPresent() && !contentAs.isPresent() ) {
        return type;
    }

    JArrayType arrayType = type.isArray();
    if ( null != arrayType ) {
        if ( contentAs.isPresent() ) {
            return typeOracle.getArrayType( contentAs.get() );
        } else if ( typeAs.isPresent() ) {
            return typeOracle.getArrayType( typeAs.get() );
        } else {
            return classType;
        }
    }

    JParameterizedType parameterizedType = type.isParameterized();
    if ( null != parameterizedType ) {
        JGenericType genericType;
        if ( typeAs.isPresent() ) {
            genericType = typeAs.get().isGenericType();
        } else {
            genericType = parameterizedType.getBaseType();
        }

        if ( !keyAs.isPresent() && !contentAs.isPresent() ) {
            return typeOracle.getParameterizedType( genericType, parameterizedType.getTypeArgs() );
        } else if ( contentAs.isPresent() && isIterable( parameterizedType ) ) {
            return typeOracle.getParameterizedType( genericType, new JClassType[]{contentAs.get()} );
        } else if ( isMap( parameterizedType ) ) {
            JClassType key;
            if ( keyAs.isPresent() ) {
                key = keyAs.get();
            } else {
                key = parameterizedType.getTypeArgs()[0];
            }

            JClassType content;
            if ( contentAs.isPresent() ) {
                content = contentAs.get();
            } else {
                content = parameterizedType.getTypeArgs()[1];
            }

            return typeOracle.getParameterizedType( genericType, new JClassType[]{key, content} );
        }
    }

    if ( typeAs.isPresent() ) {
        return typeAs.get();
    }

    return type;
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:73,代码来源:JacksonTypeOracle.java


注:本文中的com.google.gwt.core.ext.typeinfo.JType.isArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。