本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.JParameterizedType.getTypeArgs方法的典型用法代码示例。如果您正苦于以下问题:Java JParameterizedType.getTypeArgs方法的具体用法?Java JParameterizedType.getTypeArgs怎么用?Java JParameterizedType.getTypeArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.core.ext.typeinfo.JParameterizedType
的用法示例。
在下文中一共展示了JParameterizedType.getTypeArgs方法的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();
}
示例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();
}
示例3: 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();
}
示例4: 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);
}
示例5: 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());
}
示例6: 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");
}
}
示例7: 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();
}
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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();
}
示例12: 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");
}
}
示例13: getGenerics
import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入方法依赖的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;
}
示例14: extractParameterizedType
import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入方法依赖的package包/类
/**
* Extract the parameter's type.
*
* @param clazz the name of the interface
* @param parameterizedType the parameterized type
*
* @return the extracted type
* @throws UnableToCompleteException if the type contains zero or more than one parameter
*/
private JClassType extractParameterizedType( String clazz, JParameterizedType parameterizedType ) throws UnableToCompleteException {
if ( parameterizedType == null ) {
logger.log( TreeLogger.Type.ERROR, "Expected the " + clazz + " declaration to specify a parameterized type." );
throw new UnableToCompleteException();
}
JClassType[] typeParameters = parameterizedType.getTypeArgs();
if ( typeParameters == null || typeParameters.length != 1 ) {
logger.log( TreeLogger.Type.ERROR, "Expected the " + clazz + " declaration to specify 1 parameterized type." );
throw new UnableToCompleteException();
}
return typeParameters[0];
}
示例15: generate
import com.google.gwt.core.ext.typeinfo.JParameterizedType; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext context,
String requestedClass) throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
JClassType objectType = typeOracle.findType(requestedClass);
if (objectType == null) {
logger.log(TreeLogger.ERROR, "Could not find type: " + requestedClass);
throw new UnableToCompleteException();
}
implTypeName = objectType.getSimpleSourceName() + "Impl";
implPackageName = objectType.getPackage().getName();
JClassType[] implementedTypes = objectType.getImplementedInterfaces();
// Can only implement one interface
if (implementedTypes == null
|| implementedTypes.length != 1
|| !implementedTypes[0].getQualifiedSourceName().equals(
TextBinder.class.getName())) {
logger
.log(
TreeLogger.ERROR,
"The type: " + requestedClass
+ " Must implement only one interface: "
+ TextBinder.class.getName());
throw new UnableToCompleteException();
}
// Get parameterized type
JParameterizedType parameterType = implementedTypes[0].isParameterized();
if (parameterType == null) {
logger.log(TreeLogger.ERROR, "The type: " + requestedClass
+ " Must implement only one parameterized interface: "
+ TextBinder.class.getName());
throw new UnableToCompleteException();
}
if (parameterType.getTypeArgs() == null
|| parameterType.getTypeArgs().length != 2) {
logger.log(TreeLogger.ERROR,
"The type: " + requestedClass
+ " Must implement two parameterized interface: "
+ TextBinder.class.getName() + " with two Parameter");
throw new UnableToCompleteException();
}
parameterizedType1 = parameterType.getTypeArgs()[0];
parameterizedType2 = parameterType.getTypeArgs()[1];
// logger.log(TreeLogger.INFO ,
// parameterizedType2.getParameterizedQualifiedSourceName() +"\n"
// + parameterizedType2.getQualifiedSourceName());
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
implPackageName, implTypeName);
composerFactory.addImport(Map.class.getCanonicalName());
composerFactory.addImport(List.class.getCanonicalName());
// composerFactory.addImport(Field.class.getCanonicalName());
composerFactory
.addImplementedInterface(objectType.getQualifiedSourceName());
PrintWriter printWriter = context.tryCreate(logger, implPackageName,
implTypeName);
if (printWriter != null) {
SourceWriter sourceWriter = composerFactory.createSourceWriter(context,
printWriter);
composeBindMethod(logger, sourceWriter);
composeSyncMethod(logger, sourceWriter);
sourceWriter.commit(logger);
}
return implPackageName + "." + implTypeName;
}