List of usage examples for com.google.gwt.core.ext.typeinfo JGenericType getTypeParameters
JTypeParameter[] getTypeParameters();
From source file:com.github.nmorel.gwtjackson.rebind.AbstractCreator.java
License:Apache License
private ImmutableList<? extends JType> getTypeParameters(JClassType classType, boolean subtype) { JParameterizedType parameterizedType = classType.isParameterized(); if (null != parameterizedType) { return ImmutableList.copyOf(parameterizedType.getTypeArgs()); }/*from ww w . j a v a 2 s. c o m*/ JGenericType genericType = classType.isGenericType(); if (null != genericType) { if (subtype) { // if it's a subtype we look for parent in hierarchy equals to mapped class JClassType mappedClassType = getMapperInfo().get().getType(); JClassType parentClassType = null; for (JClassType parent : genericType.getFlattenedSupertypeHierarchy()) { if (parent.getQualifiedSourceName().equals(mappedClassType.getQualifiedSourceName())) { parentClassType = parent; break; } } ImmutableList.Builder<JType> builder = ImmutableList.builder(); for (JTypeParameter typeParameter : genericType.getTypeParameters()) { JType arg = null; if (null != parentClassType && null != parentClassType.isParameterized()) { int i = 0; for (JClassType parentTypeParameter : parentClassType.isParameterized().getTypeArgs()) { if (null != parentTypeParameter.isTypeParameter() && parentTypeParameter .isTypeParameter().getName().equals(typeParameter.getName())) { if (null != mappedClassType.isGenericType()) { arg = mappedClassType.isGenericType().getTypeParameters()[i]; } else { arg = mappedClassType.isParameterized().getTypeArgs()[i]; } break; } i++; } } if (null == arg) { arg = typeParameter.getBaseType(); } builder.add(arg); } return builder.build(); } else { ImmutableList.Builder<JType> builder = ImmutableList.builder(); for (JTypeParameter typeParameter : genericType.getTypeParameters()) { builder.add(typeParameter.getBaseType()); } return builder.build(); } } return ImmutableList.of(); }
From source file:org.fusesource.restygwt.rebind.DirectRestBaseSourceCreator.java
License:Apache License
private String createClassDeclarationGenericType() { String parameters = ""; if (source instanceof JGenericType) { JGenericType genericType = (JGenericType) source; StringBuilder builder = new StringBuilder(); builder.append("<"); boolean first = true; for (JTypeParameter arg : genericType.getTypeParameters()) { if (!first) builder.append(","); builder.append(arg.getName()); builder.append(" extends "); builder.append(arg.getFirstBound().getParameterizedQualifiedSourceName()); first = false;/*ww w . j a v a 2 s . c o m*/ } builder.append(">"); parameters = builder.toString(); } return parameters; }
From source file:org.jboss.errai.codegen.meta.impl.gwt.GWTClass.java
License:Apache License
@Override public MetaTypeVariable[] getTypeParameters() { final List<MetaTypeVariable> typeVariables = new ArrayList<MetaTypeVariable>(); final JGenericType genericType = getEnclosedMetaObject().isGenericType(); if (genericType != null) { for (final JTypeParameter typeParameter : genericType.getTypeParameters()) { typeVariables.add(new GWTTypeVariable(oracle, typeParameter)); }//from ww w . jav a2 s . c om } return typeVariables.toArray(new MetaTypeVariable[typeVariables.size()]); }
From source file:org.jboss.errai.ioc.rebind.ioc.codegen.meta.impl.gwt.GWTClass.java
License:Apache License
@Override public MetaTypeVariable[] getTypeParameters() { List<MetaTypeVariable> typeVariables = new ArrayList<MetaTypeVariable>(); JGenericType genericType = getEnclosedMetaObject().isGenericType(); if (genericType != null) { for (JTypeParameter typeParameter : genericType.getTypeParameters()) { typeVariables.add(new GWTTypeVariable(typeParameter)); }// w w w . jav a 2 s . c o m } return typeVariables.toArray(new MetaTypeVariable[typeVariables.size()]); }