本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.JGenericType类的典型用法代码示例。如果您正苦于以下问题:Java JGenericType类的具体用法?Java JGenericType怎么用?Java JGenericType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JGenericType类属于com.google.gwt.core.ext.typeinfo包,在下文中一共展示了JGenericType类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitGenericType
import com.google.gwt.core.ext.typeinfo.JGenericType; //导入依赖的package包/类
public JGenericTypeVisitor visitGenericType(JGenericType type) {
// TODO Auto-generated method stub
return null;
}
示例2: replaceType
import com.google.gwt.core.ext.typeinfo.JGenericType; //导入依赖的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;
}
示例3: genericName
import com.google.gwt.core.ext.typeinfo.JGenericType; //导入依赖的package包/类
private ParameterizedTypeName genericName( JGenericType type ) {
return ParameterizedTypeName.get( className( type ), typeName( true, type.getTypeParameters() ) );
}
示例4: generate
import com.google.gwt.core.ext.typeinfo.JGenericType; //导入依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext context,
String typeName) throws UnableToCompleteException {
logger.log(Type.INFO, "Generating codec for " + typeName);
JClassType type = null;
JClassType jsonCodec = null;
try {
type = context.getTypeOracle().getType(typeName);
jsonCodec = context.getTypeOracle()
.getType(JSONCodec.class.getCanonicalName());
this.collectionType = context.getTypeOracle()
.getType(Collection.class.getCanonicalName());
this.listType = context.getTypeOracle()
.getType(List.class.getCanonicalName());
this.setType = context.getTypeOracle()
.getType(Set.class.getCanonicalName());
this.numberType = context.getTypeOracle()
.getType(Number.class.getCanonicalName());
} catch (NotFoundException ex) {
logger.log(TreeLogger.ERROR, typeName, ex);
return null;
}
if (type.isClass() != null) { //Don't regenerate from Impls.
return type.getQualifiedSourceName();
}
JClassType subtype = type.asParameterizationOf((JGenericType) jsonCodec)
.getTypeArgs()[0];
this.types = this.getIntrospectableTypes(logger, context.getTypeOracle());
BeanResolver thisType = findType(subtype);
if (thisType == null) {
logger.log(Type.ERROR,
"Unable to find introspectable type " + subtype);
throw new UnableToCompleteException();
}
this.writeClassSerializer(logger, context, thisType);
this.writeTopSerializer(logger, context, type, subtype);
return type.getQualifiedSourceName() + "_Impl";
}
示例5: write_doBindEventHandlers
import com.google.gwt.core.ext.typeinfo.JGenericType; //导入依赖的package包/类
private void write_doBindEventHandlers(JClassType target, TypeOracle typeOracle, SourceWriter writer, TreeLogger logger) {
writer.println("protected List<HandlerRegistration> doBindEventHandlers(final %s target, IsWidget isWidget) {", target.getQualifiedSourceName());
writer.indent();
writer.println("List<HandlerRegistration> registrations = new LinkedList<HandlerRegistration>();");
for (JMethod method : target.getMethods()) {
DomEventHandler annotation = method.getAnnotation(DomEventHandler.class);
if (annotation != null) {
if (method.getParameters().length != 1)
break;
JType paramJType = method.getParameters()[0].getType();
String paramTypeQualifiedSourceName = paramJType.getQualifiedSourceName();
JClassType paramJClassType = typeOracle.findType(paramTypeQualifiedSourceName);
if (!paramJClassType.isAssignableTo(typeOracle.findType(DomEvent.class.getCanonicalName())))
break;
JGenericType domEventJGenericType = typeOracle.findType(DomEvent.class.getCanonicalName()).isGenericType();
JParameterizedType paramJParameterizedType = paramJClassType.asParameterizationOf(domEventJGenericType);
JClassType handlerJClassType = paramJParameterizedType.getTypeArgs()[0];
writer.println("registrations.add(isWidget.asWidget().addDomHandler(new " + paramJParameterizedType.getTypeArgs()[0].getParameterizedQualifiedSourceName() + "() {");
writer.indent();
writer.println(handlerJClassType.getOverridableMethods()[0].getReadableDeclaration(false, false, false, false, true) + " {");
writer.indent();
if (annotation.value().length > 0) {
writer.println("Element targetElement = Element.as(event.getNativeEvent().getEventTarget());");
if (annotation.value()[0].startsWith("!")) {
writer.println("if (targetElement != target." + annotation.value()[0].substring(1) + ") {");
} else {
writer.println("if (targetElement == target." + annotation.value()[0] + ") {");
}
writer.indent();
writer.println("target." + method.getName() + "(event);");
writer.outdent();
writer.println("}");
} else {
writer.println("target." + method.getName() + "(event);");
}
writer.outdent();
writer.println("}");
writer.outdent();
writer.println("}, " + paramTypeQualifiedSourceName + ".getType()));");
}
}
writer.println("return registrations;");
writer.outdent();
writer.println("}");
}
示例6: visitGenericType
import com.google.gwt.core.ext.typeinfo.JGenericType; //导入依赖的package包/类
JGenericTypeVisitor visitGenericType(JGenericType type);