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


Java JParameterizedType类代码示例

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


JParameterizedType类属于com.google.gwt.core.ext.typeinfo包,在下文中一共展示了JParameterizedType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAssociationType

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的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

示例2: getReflectedType

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
private JClassType getReflectedType( TypeOracle typeOracle, String askedTypeName ) throws UnableToCompleteException
{
	JClassType askedType;
	try
	{
		askedType = typeOracle.getType( askedTypeName );
	}
	catch( NotFoundException e )
	{
		throw new UnableToCompleteException();
	}

	for( JClassType classType : askedType.getImplementedInterfaces() )
	{
		if( !classType.getQualifiedSourceName().equals( "fr.lteconsulting.hexa.classinfo.Clazz" ) )
			continue;

		JParameterizedType parametrized = classType.isParameterized();
		JClassType[] typeArgs = parametrized.getTypeArgs();

		return typeArgs[0];
	}

	throw new UnableToCompleteException();
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:26,代码来源:ClazzGenerator.java

示例3: writeCommandDefinition

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
private void writeCommandDefinition(TreeLogger logger, SourceWriter srcWriter, JMethod method,
	JParameter callbackParameter) throws UnableToCompleteException {
	srcWriter.print("CommandDefinition commandDefinition  = new CommandDefinition(");
	srcWriter.print("\"%s\", ", this.serviceType.getQualifiedSourceName());
	srcWriter.print("\"%s\", ", method.getName());
	if (callbackParameter != null) {
		JParameterizedType parameterizedCallback = callbackParameter.getType().isParameterized();
		if (parameterizedCallback != null) {
			srcWriter.print("\"%s\" ", parameterizedCallback.getTypeArgs()[0].getQualifiedSourceName());
		} else {
			logger.branch(TreeLogger.ERROR, "Callback argument type for method " + method.getName()
				+ " is not parametrized", null);
			throw new UnableToCompleteException();
		}

	} else {
		srcWriter.print("\"%s\" ", method.getReturnType().getQualifiedSourceName());
	}
	for (JParameter parameter : method.getParameters()) {
		if (!parameter.equals(callbackParameter)) {
			srcWriter.print(", \"%s\"", parameter.getType().getQualifiedSourceName());
		}
	}
	srcWriter.println(");");
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:26,代码来源:ServiceBinderCreator.java

示例4: typeAsString

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
private String typeAsString(JType type, boolean translatePrimitives) {
	StringBuilder sb = new StringBuilder();
	if (translatePrimitives && type instanceof JPrimitiveType) {
		sb.append(((JPrimitiveType) type).getQualifiedBoxedSourceName());
	} else {
		sb.append(type.getSimpleSourceName());
		if (type instanceof JParameterizedType) {
			JParameterizedType parameterizedType = (JParameterizedType) type;
			sb.append("<");
			int i = 0;
			for (JType paramType : parameterizedType.getTypeArgs()) {
				if (i++ > 0) {
					sb.append(", ");
				}
				sb.append(this.typeAsString(paramType, false));
			}
			sb.append(">");
		}
	}
	return sb.toString();
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:22,代码来源:ServiceBinderCreator.java

示例5: collectImports

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
private void collectImports() {
	Collection<JType> toImports = Sets.newHashSet();
	for (JMethod method : this.serviceType.getOverridableMethods()) {
		toImports.add(method.getReturnType());
		for (JParameter parameter : method.getParameters()) {
			toImports.add(parameter.getType());
		}
	}
	this.imports.addAll(toImports);
	for (JType importType : this.imports) {
		if (importType instanceof JParameterizedType) {
			JParameterizedType parameterizedType = (JParameterizedType) importType;
			for (JType paramType : parameterizedType.getTypeArgs()) {
				toImports.add(paramType);
			}
		}
	}
	this.imports.addAll(toImports);
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:20,代码来源:ServiceBinderCreator.java

示例6: initComposer

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
@Override
public void initComposer(ClassSourceFileComposerFactory composerFactory) {
	composerFactory.addImport(Place.class.getName());
	composerFactory.addImport(Presenter.class.getName());
	for (JMethod presenterMethod : this.presenterMethods) {
		if (presenterMethod.getParameters().length > 0) {
			JType placeType = presenterMethod.getParameters()[0].getType();
			composerFactory.addImport(placeType.getQualifiedSourceName());
			if (placeType instanceof JParameterizedType) {
				JParameterizedType parameterizedType = (JParameterizedType) placeType;
				for (JType paramType : parameterizedType.getTypeArgs()) {
					composerFactory.addImport(paramType.getQualifiedSourceName());
				}
			}
		}
	}

	composerFactory.addImplementedInterface(Presenter.class.getSimpleName());
	composerFactory.addImport(AcceptsOneWidget.class.getName());
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:21,代码来源:InjectPresenterCreator.java

示例7: InitializeFormCreator

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
public InitializeFormCreator(JField modelField) {
	this.modelField = modelField;
	this.fieldType = modelField.getType();

	Initialize initializeAnnotation = modelField.getAnnotation(Initialize.class);
	this.constantClassName = initializeAnnotation.constantsClass();
	if (ConstantsWithLookup.class.equals(this.constantClassName)) {
		this.constantClassName = null;
	}
	if (this.fieldType instanceof JParameterizedType) {
		JParameterizedType paramType = (JParameterizedType) this.fieldType;
		this.beanType = paramType.getTypeArgs()[0];
	} else {
		throw new RuntimeException("modelField can not be injected as Model");
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:17,代码来源:InitializeFormCreator.java

示例8: UiBinderLocalizedCreator

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
public UiBinderLocalizedCreator(JClassType binderType, GwtLocale locale) {
	this.binderType = binderType;
	this.locale = locale;

	for (JClassType interfaceType : binderType.getImplementedInterfaces()) {
		if (interfaceType.getQualifiedSourceName().equals(UiBinderLocalized.class.getCanonicalName())
			&& interfaceType instanceof JParameterizedType) {
			JParameterizedType paramType = (JParameterizedType) interfaceType;
			this.widgetType = paramType.getTypeArgs()[0];
			this.targetType = paramType.getTypeArgs()[1];
		}
	}
	UiTemplate templateAnnotation = binderType.getAnnotation(UiTemplate.class);
	if (templateAnnotation != null) {
		this.templateName = templateAnnotation.value().replace(UiBinderLocalizedCreator.TEMPLATE_SUFFIX, "");
	}
	if (this.templateName == null) {
		this.templateName = this.targetType.getSimpleSourceName();
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:21,代码来源:UiBinderLocalizedCreator.java

示例9: decideReturnType

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
private JType decideReturnType(Class cellType)
{
   String cellClassName = Cell.class.getName();
   JClassType cellJType = findType(cellType);
   for (JClassType superType : cellJType.getFlattenedSupertypeHierarchy())
   {
      if (cellClassName.equals(superType.getQualifiedSourceName()))
      {
         JParameterizedType parameterizedType = superType.isParameterized();
         if (parameterizedType != null)
         {
            return parameterizedType.getTypeArgs()[0];
         }
      }
   }
   return null;
}
 
开发者ID:symulakr,项目名称:gwt-generators,代码行数:18,代码来源:CellInfoExtractor.java

示例10: findStorageTypes

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
@Override
public Set<JType> findStorageTypes() throws UnableToCompleteException {
  Set<JType> serializables = new HashSet<JType>();

  JClassType keyProviderIntf = typeOracle.findType(StorageKeyProvider.class.getName());
  JClassType[] keyProviderTypes = keyProviderIntf.getSubtypes();
  for (JClassType keyProviderType : keyProviderTypes) {
    for (JMethod method : keyProviderType.getMethods()) {
      if(method.isStatic() || method.getParameters().length > 1){
        continue;
      }
      JParameterizedType storageKeyType = method.getReturnType().isParameterized();
      if (storageKeyType != null) {
        JClassType type = storageKeyType.getTypeArgs()[0];
        addIfIsValidType(serializables, type);
      }
    }
  }
  return serializables;
}
 
开发者ID:seanchenxi,项目名称:gwt-storage,代码行数:21,代码来源:TypeProviderFinder.java

示例11: validateMethodDef

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
private boolean validateMethodDef(JMethod method) throws UnableToCompleteException {
  if(!method.getEnclosingType().equals(providerType)){
    return false;
  }
  JParameterizedType returnType = method.getReturnType().isParameterized();
  boolean isCorrectReturnType = returnType != null  && returnType.isAssignableTo(storageKeyGenericType);
  JClassType valueType = isCorrectReturnType ? returnType.getTypeArgs()[0] : null;
  if(!isValideType(valueType)){
    logger.branch(TreeLogger.Type.ERROR, "method "+ method.getReadableDeclaration() +"'s returned store type is not extends to IsSerializable nor Serializable");
    throw new UnableToCompleteException();
  }

  int length = method.getParameters().length;
  if(length > 1){
    logger.branch(TreeLogger.Type.WARN, "method "+ method.getReadableDeclaration() +" should only have one or zero parameter");
    throw new UnableToCompleteException();
  }
  return true;
}
 
开发者ID:seanchenxi,项目名称:gwt-storage,代码行数:20,代码来源:StorageKeyProviderModel.java

示例12: resolveType

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的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

示例13: getBeanType

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
private JClassType getBeanType(final TreeLogger logger, final JClassType validator,
    final JClassType gwtSpecificInterface) throws UnableToCompleteException {
  if (gwtSpecificInterface instanceof JParameterizedType) {
    final JParameterizedType paramType = (JParameterizedType) gwtSpecificInterface;
    return paramType.getTypeArgs()[0];
  }
  logger.log(TreeLogger.ERROR,
      validator.getQualifiedSourceName() + " must implement "
          + GwtSpecificValidator.class.getCanonicalName() + " with a one generic parameter.",
      null);
  throw new UnableToCompleteException();
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:13,代码来源:ValidatorGenerator.java

示例14: addImport

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的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

示例15: InjectModelCreator

import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入依赖的package包/类
public InjectModelCreator(JField modelField) {
	this.modelField = modelField;
	this.fieldType = modelField.getType();

	if (this.fieldType instanceof JParameterizedType) {
		JParameterizedType paramType = (JParameterizedType) this.fieldType;
		this.beanType = paramType.getTypeArgs()[0];
	} else {
		throw new RuntimeException("modelField can not be injected as Model");
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:12,代码来源:InjectModelCreator.java


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