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


Java JType.isTypeParameter方法代码示例

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


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

示例3: 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

示例4: resolveType

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private JType resolveType(final JType type) {
    JType ret = type;
    JParameterizedType pt = type.isParameterized();

    if (pt != null) {
        ret = pt.getRawType();
    }

    JTypeParameter tp = ret.isTypeParameter();

    if (tp != null) {
        ret = tp.getBaseType();
    }

    return ret;
}
 
开发者ID:kebernet,项目名称:gwittir,代码行数:17,代码来源:IntrospectorGenerator.java

示例5: printMockMethodBody

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private void printMockMethodBody(SourceWriter sourceWriter, JMethod method, 
                                   int methodNo, String newClassName) {
  
  JParameter[] args = method.getParameters();
  
  String callVar = freeVariableName("call", args);
  sourceWriter.print("Call %s = new Call(this, %s.methods[%d]", callVar, newClassName, methodNo);
  
  int argsCount = method.isVarArgs() ? args.length - 1 : args.length;

  for (int i = 0; i < argsCount; i++) {
    sourceWriter.print(", %s", args[i].getName());
  }
  sourceWriter.println(");");
  
  if (method.isVarArgs()) {
    sourceWriter.println("%s.addVarArgument(%s);", callVar, args[args.length - 1].getName());
  }
  
  sourceWriter.println("try {");
  sourceWriter.indent();
  
  if (!isVoid(method)) {
    sourceWriter.print("return (");
    
    JType returnType = method.getReturnType();
    JPrimitiveType primitiveType = returnType.isPrimitive();
    if (primitiveType != null) {
      sourceWriter.print(primitiveType.getQualifiedBoxedSourceName());
    } else if (returnType.isTypeParameter() != null) {
      sourceWriter.print(returnType.isTypeParameter().getName());
    } else {
      sourceWriter.print(returnType.getQualifiedSourceName());
    }
    
    sourceWriter.print(") ");
  }
  
  sourceWriter.println("this.mocksControl.invoke(%s).answer(%s.getArguments().toArray());", 
      callVar, callVar);
  sourceWriter.outdent();
  
  String exceptionVar = freeVariableName("exception", args);
  sourceWriter.println("} catch (Throwable %s) {", exceptionVar);
  sourceWriter.indent();
  
  String assertionError = AssertionErrorWrapper.class.getCanonicalName();
  sourceWriter.println("if (%s instanceof %s) throw (AssertionError) " +
      "((%s) %s).getAssertionError().fillInStackTrace();", 
      exceptionVar, assertionError, assertionError, exceptionVar);
  
  for (JClassType exception : method.getThrows()) {
    printRethrowException(sourceWriter, exceptionVar, exception.getQualifiedSourceName());
  }
  printRethrowException(sourceWriter, exceptionVar, "RuntimeException");
  printRethrowException(sourceWriter, exceptionVar, "Error");
  sourceWriter.println("throw new UndeclaredThrowableException(%s);", exceptionVar);
  sourceWriter.outdent();
  sourceWriter.println("}");
}
 
开发者ID:google,项目名称:easy-gwt-mock,代码行数:61,代码来源:MocksGenerator.java

示例6: toType

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private String toType(JType type, String innerExpression) {
    //System.out.println("toType " + type);
    if ((type.isPrimitive() == JPrimitiveType.DOUBLE) ||
            (type.isPrimitive() == JPrimitiveType.FLOAT) ||
            (type.isPrimitive() == JPrimitiveType.LONG) ||
            (type.isPrimitive() == JPrimitiveType.INT) ||
            (type.isPrimitive() == JPrimitiveType.SHORT)) {
        return " new JSONNumber( (double) " + innerExpression + ")";
    } else if (type.isPrimitive() == JPrimitiveType.BOOLEAN) {
        return " JSONBoolean.getInstance( " + innerExpression + " ) ";
    } else if (type.isPrimitive() == JPrimitiveType.CHAR ){
        return " new JSONString( Character.toString("+ innerExpression +") )";
    }

    StringBuilder sb = new StringBuilder(innerExpression +
            " == null ? JSONNull.getInstance() : ");
    if(type.isEnum() != null){
        sb = sb.append(" new JSONString(( (Enum) "+innerExpression+").name()) ");
    } else if (type.getQualifiedSourceName().equals("java.lang.String")) {
        sb = sb.append(" new JSONString( " + innerExpression + " ) ");
    } else if(type.getQualifiedSourceName().equals("java.lang.Character")){
        sb = sb.append(" new JSONString( Character.toString(" + innerExpression + ") ) ");
    }else if (type.isClassOrInterface() != null && type.isClassOrInterface().isAssignableTo(this.numberType)) {
        sb = sb.append("new JSONNumber( ((Number) " + innerExpression +
                ").doubleValue())");
    } else if (type.getQualifiedSourceName().equals("java.lang.Boolean")) {
        sb.append(" JSONBoolean.getInstance( " + innerExpression + " ) ");
    } else if(type.getQualifiedSourceName().equals(Serializable.class.getCanonicalName())){
        sb.append(" dynamicType("+innerExpression+" )");
    } else {
   
        BeanResolver child = findType(type);
        if (child == null) {
            if(type.isTypeParameter() != null){
                boolean found = false;
                for(JClassType bound : type.isTypeParameter().getBounds()){
                    if(bound.getQualifiedSourceName().equals(Serializable.class.getCanonicalName())){
                        sb.append(" dynamicType("+innerExpression+" ) ");
                        found = true;
                        break;
                    }
                }
                if(!found){
                    throw new RuntimeException(type+" could not be mapped to JSON.");
                }
            }else {
                throw new RuntimeException(type+" is not introspectable!");
            }
        } else {
            this.children.add(child);
            sb = sb.append("CODEC_" +
                    type.getQualifiedSourceName().replaceAll("\\.", "_") +
                    ".serializeToJSONObject( " + innerExpression + " ) ");
        }
    }

    return sb.toString();
}
 
开发者ID:kebernet,项目名称:gwittir,代码行数:59,代码来源:JSONCodecGenerator.java


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