本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.isInterface方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.isInterface方法的具體用法?Java JClassType.isInterface怎麽用?Java JClassType.isInterface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.typeinfo.JClassType
的用法示例。
在下文中一共展示了JClassType.isInterface方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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包/類
/** {@inheritDoc} */
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
JClassType extensionManager = typeOracle.findType(typeName);
if (extensionManager == null) {
logger.log(TreeLogger.ERROR, "Can't find interface type '" + typeName + "'", null);
throw new UnableToCompleteException();
}
if (extensionManager.isInterface() == null) {
logger.log(
TreeLogger.ERROR,
extensionManager.getQualifiedSourceName() + " is not an interface",
null);
throw new UnableToCompleteException();
}
List<JClassType> extensions = new ArrayList<>();
for (JClassType type : typeOracle.getTypes()) {
if (type.isAnnotationPresent(Extension.class)) {
extensions.add(type);
}
}
String packageName = extensionManager.getPackage().getName();
String className = extensionManager.getSimpleSourceName() + "Impl";
generateClass(logger, context, packageName, className, extensions);
return packageName + "." + className;
}
示例3: generateIncrementally
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public RebindResult generateIncrementally(TreeLogger logger,
GeneratorContext generatorContext,
String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = generatorContext.getTypeOracle();
assert (typeOracle != null);
JClassType originalType = typeOracle.findType(typeName);
if (originalType == null) {
logger.log(TreeLogger.ERROR,
"Unable to find metadata for type '" + typeName + "'");
throw new UnableToCompleteException();
}
if (originalType.isInterface() == null) {
logger.log(TreeLogger.ERROR,
"'" + typeName + "' is not a interface");
throw new UnableToCompleteException();
}
TreeLogger moduleLogger = logger.branch(TreeLogger.DEBUG,
"Generating client proxy for remote service interface '" + originalType.getQualifiedSourceName() + "'",
null);
return create(originalType,
moduleLogger,
generatorContext,
typeName);
}
示例4: generateIncrementally
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public RebindResult generateIncrementally(TreeLogger logger,
GeneratorContext generatorContext,
String moduleClass)
throws UnableToCompleteException {
TypeOracle typeOracle = generatorContext.getTypeOracle();
assert (typeOracle != null);
JClassType module = typeOracle.findType(moduleClass);
if (module == null) {
logger.log(TreeLogger.ERROR,
"Unable to find metadata for module class '" + moduleClass + "'");
throw new UnableToCompleteException();
}
if (module.isInterface() == null) {
logger.log(TreeLogger.ERROR,
"'" + moduleClass + "' is not a interface");
throw new UnableToCompleteException();
}
TreeLogger moduleLogger = logger.branch(TreeLogger.DEBUG,
"Generating mvp4g configuration for module class '" + module.getQualifiedSourceName() + "'",
null);
return create(moduleLogger,
generatorContext,
moduleClass);
}
示例5: 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 subsystemExtensionManager = typeOracle.findType(typeName);
if (subsystemExtensionManager == null) {
logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
throw new UnableToCompleteException();
}
if (subsystemExtensionManager.isInterface() == null) {
logger.log(TreeLogger.ERROR, subsystemExtensionManager.getQualifiedSourceName() + " is not an interface",
null);
throw new UnableToCompleteException();
}
List<SubsystemExtension> subsystemExtensions = new ArrayList<SubsystemExtension>();
for (JClassType type : typeOracle.getTypes()) {
if (type.isAnnotationPresent(SubsystemExtension.class)) {
subsystemExtensions.add(type.getAnnotation(SubsystemExtension.class));
}
}
String packageName = subsystemExtensionManager.getPackage().getName();
String className = subsystemExtensionManager.getSimpleSourceName() + "Impl";
generateClass(logger, context, packageName, className, subsystemExtensions);
return packageName + "." + className;
}
示例6: generateMock
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Generates a mock class for {@code interfaceToMock}.
*/
String generateMock(JClassType typeToMock) throws UnableToCompleteException {
JPackage interfacePackage = typeToMock.getPackage();
String packageName = interfacePackage == null ? "" : interfacePackage.getName();
String newClassName = typeToMock.getName().replace(".", "_") + "Mock";
// GenericType<Integer> has to generate a different mock implementation than
// GenericType<String>, that's what we check and do here
if (typeToMock.isParameterized() != null) {
StringBuilder typeList = new StringBuilder();
for (JClassType genericArg : typeToMock.isParameterized().getTypeArgs()) {
typeList.append(genericArg.getParameterizedQualifiedSourceName());
}
newClassName += Integer.toHexString(typeList.toString().hashCode());
}
String fullNewClassName = packageName + "." + newClassName;
PrintWriter printWriter = this.context.tryCreate(this.logger, packageName, newClassName);
if (printWriter == null) {
// We generated this before.
return fullNewClassName;
}
ClassSourceFileComposerFactory composer =
new ClassSourceFileComposerFactory(packageName, newClassName);
composer.addImport(MocksControlBase.class.getCanonicalName());
composer.addImport(Method.class.getCanonicalName());
composer.addImport(Call.class.getCanonicalName());
composer.addImport(UndeclaredThrowableException.class.getCanonicalName());
if (typeToMock.isInterface() != null) {
composer.addImplementedInterface(typeToMock.getParameterizedQualifiedSourceName());
} else {
composer.setSuperclass(typeToMock.getParameterizedQualifiedSourceName());
}
SourceWriter sourceWriter = composer.createSourceWriter(this.context, printWriter);
sourceWriter.println();
JMethod[] overridableMethods = typeToMock.getOverridableMethods();
List<JMethod> methodsToMock = new ArrayList<JMethod>();
Set<String> needsDefaultImplementation = new HashSet<String>();
for (JMethod method : overridableMethods) {
if (isSpecialMethodOfObject(method)) {
needsDefaultImplementation.add(method.getName());
} else if (method.getParameterTypes().length == 0 && method.getName().equals("getClass")) {
// ignore, Bug 5026788 in GWT
} else {
methodsToMock.add(method);
}
}
printFields(sourceWriter, methodsToMock);
printConstructors(sourceWriter, newClassName, typeToMock.getConstructors());
printMockMethods(sourceWriter, methodsToMock, newClassName);
printDefaultMethods(sourceWriter, typeToMock, needsDefaultImplementation);
sourceWriter.commit(this.logger);
return fullNewClassName;
}
示例7: printDefaultMethods
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Print the default implementation for {@link java.lang.Object} methods.
* If typeToMock is a class it will only print default implementations for
* methods of Object listed in the methods parameter. If typeToMock is an interface
* it will always print default implementations for all methods of Object.
*/
private void printDefaultMethods(SourceWriter writer, JClassType typeToMock, Set<String> methods) {
// always print default implementations for interfaces
boolean isInterface = typeToMock.isInterface() != null;
if (isInterface || methods.contains("equals")) {
writer.println("public boolean equals(Object obj) {");
writer.indent();
writer.println("this.mocksControl.unmockableCallTo(\"equals()\");");
writer.println("return obj == this;"); // object identity since Mocks don't hold any data
writer.outdent();
writer.println("}");
writer.println();
}
if (isInterface || methods.contains("toString")) {
writer.println("public String toString() {");
writer.indent();
writer.println("this.mocksControl.unmockableCallTo(\"toString()\");");
writer.println("return \"Mock for %s\";", typeToMock.getName());
writer.outdent();
writer.println("}");
writer.println();
}
if (isInterface || methods.contains("hashCode")) {
writer.println("public int hashCode() {");
writer.indent();
writer.println("this.mocksControl.unmockableCallTo(\"hashCode()\");");
writer.println("return System.identityHashCode(this);"); // hashCode of java.lang.Object
writer.outdent();
writer.println("}");
writer.println();
}
if (isInterface || methods.contains("finalize")) {
writer.println("protected void finalize() throws Throwable {");
writer.indent();
writer.println("this.mocksControl.unmockableCallTo(\"finalize()\");");
writer.println("super.finalize();");
writer.outdent();
writer.println("}");
writer.println();
}
}
示例8: 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;
}