本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.getImplementedInterfaces方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.getImplementedInterfaces方法的具體用法?Java JClassType.getImplementedInterfaces怎麽用?Java JClassType.getImplementedInterfaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.typeinfo.JClassType
的用法示例。
在下文中一共展示了JClassType.getImplementedInterfaces方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processRelationClasses
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private void processRelationClasses(List<JClassType> types, JClassType classType){
if (classType.getSuperclass() != null){
processRelationClasses(types, classType.getSuperclass());
addClassIfNotExists(types, classType.getSuperclass());
}
for (JClassType type : classType.getImplementedInterfaces()){
addClassIfNotExists(types, type);
}
for (JField field : classType.getFields()) {
addClassIfNotExists(types, field.getType().isClassOrInterface());
}
for (JMethod method : classType.getMethods()){
if (method.getReturnType() != null)
addClassIfNotExists(types, method.getReturnType().isClassOrInterface());
//TODO How about parameters?
}
}
示例2: generate
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的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;
}