本文整理汇总了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;
}
开发者ID:liraz,项目名称:gwt-backbone,代码行数:5,代码来源:TypesLogVisitor.java
示例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;
}
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:73,代码来源:JacksonTypeOracle.java
示例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() ) );
}
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:4,代码来源:JTypeName.java
示例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";
}
开发者ID:kebernet,项目名称:gwittir,代码行数:50,代码来源:JSONCodecGenerator.java
示例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("}");
}
开发者ID:rfilippone,项目名称:gwt-dom-event-binder,代码行数:54,代码来源:DomEventBinderGenerator.java
示例6: visitGenericType
import com.google.gwt.core.ext.typeinfo.JGenericType; //导入依赖的package包/类
JGenericTypeVisitor visitGenericType(JGenericType type);
开发者ID:liraz,项目名称:gwt-backbone,代码行数:2,代码来源:TypeVisitor.java
注:本文中的com.google.gwt.core.ext.typeinfo.JGenericType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论