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


Java JType.isParameterized方法代码示例

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


在下文中一共展示了JType.isParameterized方法的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: 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

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

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

示例6: addImport

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private void addImport(JType type) {
	JParameterizedType parametrizedType = type.isParameterized();
	if (parametrizedType != null) {
		this.imports.add(parametrizedType.getRawType());
		this.imports.addAll(Lists.newArrayList(parametrizedType.getTypeArgs()));
	} else {
		this.imports.add(type);
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:10,代码来源:ModelCreator.java

示例7: getGenerics

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private List<IsType> getGenerics(JType type) {
  final JParameterizedType genericType = type.isParameterized();
  List<IsType> generics = new ArrayList<>();
  if (genericType != null) {
    for (JClassType parameter : genericType.getTypeArgs()) {
      generics.add(binaryToSource(parameter.getErasedType().getQualifiedBinaryName()));
    }
  }
  return generics;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:11,代码来源:ModelArtifact.java

示例8: generateDeserializer

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private void generateDeserializer( SourceWriter sourceWriter, String methodName, JType type )
{
	generateDeserializerBegin( sourceWriter, methodName, type );

	if( type.getParameterizedQualifiedSourceName().equals( "java.lang.String" ) )
		sourceWriter.println( "return json.isString().stringValue();" );

	else if( type.getParameterizedQualifiedSourceName().equals( "java.lang.Integer" ) )
		sourceWriter.println( "return (Integer) json.isNumber().doubleValue();" );

	else if( type.getParameterizedQualifiedSourceName().equals( "int" ) )
		sourceWriter.println( "return (int) json.isNumber().doubleValue();" );

	else if( type.getParameterizedQualifiedSourceName().equals( "java.lang.Boolean" ) )
		sourceWriter.println( "return (Boolean) json.isBoolean().booleanValue();" );

	else if( type.getParameterizedQualifiedSourceName().equals( "boolean" ) )
		sourceWriter.println( "return (boolean) json.isBoolean().booleanValue();" );

	else if( type.getParameterizedQualifiedSourceName().equals( "java.util.Date" ) )
		sourceWriter.println( "return new Date( json.isString().stringValue() );" );

	else if( type.getQualifiedSourceName().equals( "java.util.List" ) )
	{
		JParameterizedType parametrizedType = type.isParameterized();
		JClassType itemsType = parametrizedType.getTypeArgs()[0];

		sourceWriter.println( "java.util.ArrayList res = new java.util.ArrayList();" );

		sourceWriter.println( "JSONArray jsonArray = json.isArray();" );
		sourceWriter.println( "for( int i=0; i<jsonArray.size(); i++ )" );
		sourceWriter.indent();
		sourceWriter.println( "res.add( " + getDeserializerMethodName( itemsType ) + "( jsonArray.get( i ) ) );" );
		sourceWriter.outdent();

		sourceWriter.println( "return res;" );
	}

	else if( type.isEnum() != null )
	{
		// JEnumType type.isEnum();
		sourceWriter.println( "return " + type.getParameterizedQualifiedSourceName() + ".valueOf( json.isString().stringValue() );" );
	}

	else
	{
		sourceWriter.println( type.getParameterizedQualifiedSourceName() + " res = new " + type.getParameterizedQualifiedSourceName() + "();" );

		JField fields[] = type.isClass().getFields();
		for( int i = 0; i < fields.length; i++ )
		{
			JField field = fields[i];

			String deserializerMethodName = getDeserializerMethodName( field.getType() );

			sourceWriter.println( field.getType().getParameterizedQualifiedSourceName() + " " + field.getName() + " = " + deserializerMethodName + "( json.isObject().get( \"" + field.getName() + "\" ) );" );
			sourceWriter.println( "res." + field.getName() + " = " + field.getName() + ";" );
		}

		sourceWriter.println( "return res;" );
	}

	generateDeserializerEnd( sourceWriter );
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:65,代码来源:CallDeserializerGenerator.java

示例9: generateStaticInitializer

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private void generateStaticInitializer(TreeLogger logger, SourceWriter srcWriter) {

		srcWriter.println("protected static final Map<String, PropertyDescription> PROPERTIES = Maps.newHashMap();");
		srcWriter.println("static{");
		srcWriter.indent();

		for (String propertyName : this.propertyTypes.keySet()) {
			JType propertyType = this.propertyTypes.get(propertyName);
			String simplePropertyTypeName = propertyType.getSimpleSourceName();
			String modelName = this.subModels.get(propertyType);
			if (modelName != null) {
				modelName += ".INSTANCE";
			}

			try {
				if (propertyType.isPrimitive() == null) {
					Class<?> propertyClass = Class.forName(propertyType.getQualifiedSourceName());

					if (Collection.class.isAssignableFrom(propertyClass)) {
						JParameterizedType parametrizedType = propertyType.isParameterized();
						JType subType = propertyType;
						if (parametrizedType != null) {
							subType = parametrizedType.getTypeArgs()[0];
							String submodelName = this.subModels.get(subType);
							if (submodelName != null) {
								submodelName += ".INSTANCE";
							} else {
								submodelName = subType.getSimpleSourceName() + ".class";
							}
							modelName =
								String.format("new ModelCollection<%s>(%s.class, %s)",
									subType.getSimpleSourceName(), propertyType.getSimpleSourceName(), submodelName);
						} else {
							logger.branch(Type.WARN, String.format(
								"Property [%s] on bean %s is a raw collection type. You cannot use it on editors.",
								propertyName, this.beanType.getQualifiedSourceName()));
							modelName = "new ModelCollection((Model) null)";
						}
					}
				}
			} catch (ClassNotFoundException e) {
				logger.branch(Type.WARN, String.format(
					"%s class not found.", propertyType.getQualifiedSourceName()));
			}
			Boolean getter = this.getters.containsKey(propertyName);
			Boolean setter = this.setters.containsKey(propertyName);

			srcWriter.print("PROPERTIES.put(\"%s\", newPropertyDescription(\"%s\", %s.class, %s, %s, %s", propertyName,
				propertyName, simplePropertyTypeName, modelName, getter, setter);
			this.generateValidators(srcWriter, propertyName);
			srcWriter.println("));");
		}
		srcWriter.outdent();
		srcWriter.println("}");

		srcWriter.println("protected Map<String, PropertyDescription> getProperties(){");
		srcWriter.println("	return PROPERTIES;");
		srcWriter.println("}");
	}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:60,代码来源:ModelCreator.java

示例10: getHandlerForEvent

import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
 * Retrieves the handler associated with the event.
 *
 * @param eventType the given event
 * @return the associated handler, <code>null</code> if not found
 */
private JClassType getHandlerForEvent(JClassType eventType) {

  // All handlers event must have an overrided method getAssociatedType().
  // We take advantage of this information to get the associated handler.
  // Ex:
  // com.google.gwt.event.dom.client.ClickEvent
  // ---> com.google.gwt.event.dom.client.ClickHandler
  //
  // com.google.gwt.event.dom.client.BlurEvent
  // ---> com.google.gwt.event.dom.client.BlurHandler

  if (eventType == null) {
    return null;
  }

  JMethod method = eventType.findMethod("getAssociatedType", new JType[0]);
  if (method == null) {
    logger.warn(
        "Method 'getAssociatedType()' could not be found in the event '%s'.",
        eventType.getName());
    return null;
  }

  JType returnType = method.getReturnType();
  if (returnType == null) {
    logger.warn(
        "The method 'getAssociatedType()' in the event '%s' returns void.",
        eventType.getName());
    return null;
  }

  JParameterizedType isParameterized = returnType.isParameterized();
  if (isParameterized == null) {
    logger.warn(
        "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>.",
        eventType.getName());
    return null;
  }

  JClassType[] argTypes = isParameterized.getTypeArgs();
  if ((argTypes.length != 1)
      && !argTypes[0].isAssignableTo(eventHandlerJClass)) {
    logger.warn(
        "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>.",
        eventType.getName());
    return null;
  }

  return argTypes[0];
}
 
开发者ID:ahome-it,项目名称:ahome-core,代码行数:57,代码来源:HandlerEvaluator.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.isParameterized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。