本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.isClass方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.isClass方法的具體用法?Java JClassType.isClass怎麽用?Java JClassType.isClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.typeinfo.JClassType
的用法示例。
在下文中一共展示了JClassType.isClass方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findReflectedClasses
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
protected Set<JType> findReflectedClasses(final GeneratorContext context, final TypeOracle typeOracle,
final TreeLogger logger) throws UnableToCompleteException {
final Set<JType> types = new HashSet<JType>();
final Set<String> uediInterfaceNames = getUediInterfaceNames();
final Set<JClassType> uediInterfaces = new HashSet<JClassType>();
final String rootPackage = getRootPackage(context, logger);
for (final JPackage jPackage : typeOracle.getPackages()) {
for (final JClassType jType : jPackage.getTypes()) {
if (uediInterfaceNames.contains(jType.getQualifiedSourceName())) {
uediInterfaces.add(jType);
} else if (jType.isClass() != null && jType.isInterface() == null && !jType.isClass().isAbstract()
&& jType.getQualifiedSourceName().startsWith(rootPackage)) {
types.add(jType);
}
}
}
if (uediInterfaces.size() < uediInterfaceNames.size()) {
logger.log(Type.ERROR, "UEDIT: Unable to find UEDI interfaces in classpath. Aborting.");
throw new UnableToCompleteException();
}
return filter(types, uediInterfaces);
}
示例2: generate
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
JClassType componentExtensionManager = typeOracle.findType(typeName);
if (componentExtensionManager == null) {
logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
throw new UnableToCompleteException();
}
if (componentExtensionManager.isInterface() == null) {
logger.log(TreeLogger.ERROR, componentExtensionManager.getQualifiedSourceName() + " is not an interface",
null);
throw new UnableToCompleteException();
}
JClassType componentProvider = typeOracle.findType(ComponentProvider.class.getCanonicalName());
if (componentProvider == null) {
logger.log(TreeLogger.ERROR, "Unable to find metadata for type 'ComponentProvider'", null);
throw new UnableToCompleteException();
}
List<JClassType> componentExtensionClasses = new ArrayList<JClassType>();
for (JClassType type : typeOracle.getTypes()) {
if (type.isAnnotationPresent(ComponentExtension.class)) {
if (type.isClass() == null || type.isAbstract()) {
// type must be a class that can be instantiated
logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
+ "' cannot be instantiated.", null);
throw new UnableToCompleteException();
} else if (!type.isDefaultInstantiable()) {
// type must have default constructor
logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
+ "' does not provide a default constructor.", null);
throw new UnableToCompleteException();
} else if (!type.isAssignableTo(componentProvider)) {
// type must implement ComponentProvider
logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
+ "' does not implement ComponentProvider.", null);
throw new UnableToCompleteException();
}
componentExtensionClasses.add(type);
}
}
String packageName = componentExtensionManager.getPackage().getName();
String className = componentExtensionManager.getSimpleSourceName() + "Impl";
generateClass(logger, context, packageName, className, componentExtensionClasses);
return packageName + "." + className;
}