本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.isAbstract方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.isAbstract方法的具體用法?Java JClassType.isAbstract怎麽用?Java JClassType.isAbstract使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.typeinfo.JClassType
的用法示例。
在下文中一共展示了JClassType.isAbstract方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: printArrayFactoryMethod
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private void printArrayFactoryMethod( List<JClassType> clazzes, SourceWriter sourceWriter )
{
sourceWriter.println( );
sourceWriter.println("public <T, V extends T> T[] instantiateArray( Class<V> clazz, int length ) {");
for ( JClassType classType : clazzes )
{
if ( classType.isAbstract( ) )
continue;
sourceWriter.println( );
sourceWriter.indent( );
sourceWriter.println( "if (clazz.getName().endsWith(\"." + classType.getName( ) + "\")) {" );
sourceWriter.indent( );
sourceWriter.println( "return (T[]) new " + classType.getQualifiedSourceName( ) + "[length];" );
sourceWriter.outdent( );
sourceWriter.println( "}" );
sourceWriter.outdent( );
sourceWriter.println( );
}
sourceWriter.indent();
sourceWriter.println("return (T[]) null;");
sourceWriter.outdent();
sourceWriter.println();
sourceWriter.println("}");
sourceWriter.outdent( );
sourceWriter.println( );
}
示例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;
}