本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType類的典型用法代碼示例。如果您正苦於以下問題:Java JClassType類的具體用法?Java JClassType怎麽用?Java JClassType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JClassType類屬於com.google.gwt.core.ext.typeinfo包,在下文中一共展示了JClassType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testUselessEventFilterBus
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@Test(expected = Mvp4gAnnotationException.class)
public void testUselessEventFilterBus()
throws Mvp4gAnnotationException {
try {
List<JClassType> annotedClasses = new ArrayList<JClassType>();
annotedClasses.add(oracle.addClass(Events.EventBusUselessFilter.class));
loader.load(annotedClasses,
configuration);
} catch (Mvp4gAnnotationException e) {
assertTrue(e.getMessage()
.contains("Useless " +
Filters.class.getSimpleName() +
" annotation. Don't use this annotation if your module doesn't have any event filters. If you plan on adding filters when the application runs, set the forceFilters option to true."));
throw e;
}
}
示例2: generateOnce
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
private void generateOnce(PrintWriter printWriter, TreeLogger logger,
GeneratorContext generatorContext, JClassType componentJsType, ClassName componentTypeName)
throws UnableToCompleteException
{
String templateContent =
getTemplateContent(generatorContext.getResourcesOracle(), logger, componentTypeName);
LocalComponents localComponents = new LocalComponents();
findLocalComponentsForComponent(localComponents,
componentJsType.getSuperclass(),
generatorContext.getTypeOracle());
TemplateParserContext templateParserContext =
new TemplateParserContext(componentTypeName, localComponents);
registerFieldsAndMethodsInContext(templateParserContext, componentJsType);
TemplateParserResult templateParserResult =
new TemplateParser(logger).parseHtmlTemplate(templateContent, templateParserContext);
createTemplateImpl(generatorContext,
logger,
printWriter,
componentTypeName,
templateParserResult);
}
示例3: findLocalComponentsForComponent
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
/**
* Register all locally declared components.
* @param localComponents The {@link LocalComponents} where we register our local components
* @param componentType The JClass type of the local component
* @param typeOracle Used to retrieve a {@link JClassType} in GWT Context
*/
private void findLocalComponentsForComponent(LocalComponents localComponents,
JClassType componentType, TypeOracle typeOracle)
{
Component componentAnnotation = componentType.getAnnotation(Component.class);
if (componentAnnotation == null)
return;
Arrays
.stream(componentAnnotation.components())
.map(Class::getCanonicalName)
.map(typeOracle::findType)
.forEach(childType -> processLocalComponentClass(localComponents, childType));
findLocalComponentsForComponent(localComponents, componentType.getSuperclass(), typeOracle);
}
示例4: processLocalComponentClass
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
/**
* Register the local component and all of its {@link Prop}.
* This will be used for type validation.
* @param localComponents The {@link LocalComponents} object where we should register our {@link LocalComponent}
* @param localComponentType The {@link JClassType} of the {@link LocalComponent}
*/
private void processLocalComponentClass(LocalComponents localComponents,
JClassType localComponentType)
{
Component componentAnnotation = localComponentType.getAnnotation(Component.class);
String localComponentTagName =
componentToTagName(localComponentType.getName(), componentAnnotation);
if (localComponents.hasLocalComponent(localComponentTagName))
return;
LocalComponent localComponent = localComponents.addLocalComponent(localComponentTagName);
Arrays.stream(localComponentType.getFields()).forEach(field -> {
Prop propAnnotation = field.getAnnotation(Prop.class);
if (propAnnotation != null)
{
localComponent.addProp(field.getName(),
stringTypeToTypeName(field.getType().getQualifiedSourceName()),
propAnnotation.required());
}
});
}
示例5: registerFieldsAndMethodsInContext
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
/**
* Process the ComponentJsType class to register all the fields and methods visible in
* the context.
* @param templateResourceClass The class to process
*/
private void registerFieldsAndMethodsInContext(TemplateParserContext templateParserContext,
JClassType templateResourceClass)
{
// Stop recursion when getting to VueComponent class
if (templateResourceClass == null || templateResourceClass
.getQualifiedSourceName()
.equals(VueComponent.class.getCanonicalName()))
return;
Arrays
.stream(templateResourceClass.getFields())
.filter(ComponentGenerationUtil::isFieldVisibleInJS)
.forEach(jField -> templateParserContext.addRootVariable(jField
.getType()
.getQualifiedSourceName(), jField.getName()));
Arrays
.stream(templateResourceClass.getMethods())
.filter(ComponentGenerationUtil::isMethodVisibleInTemplate)
.map(JMethod::getName)
.forEach(templateParserContext::addRootMethod);
registerFieldsAndMethodsInContext(templateParserContext,
templateResourceClass.getSuperclass());
}
示例6: generate
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@Override public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
String result = null;
try {
String version = findVersion(logger, context);
JClassType classType = context.getTypeOracle().getType(typeName);
String packageName = packageNameFrom(classType);
String simpleName = simpleNameFrom(classType);
result = packageName + '.' + simpleName;
SourceWriter source = getSourceWriter(logger, context, classType);
if(source != null) { //? Otherwise, work needs to be done.
source.println();
source.println("private String value;");
source.println();
source.println("public " + simpleName + "() {");
populateInstanceFactory(logger, context, typeName, source, version);
source.println("}");
source.println();
source.println("@Override");
source.println("public String getValue() {");
source.println(" return value;");
source.println("}");
source.println(); source.commit(logger);
//emitVersionArtifact(logger, context, version);
}
} catch (NotFoundException nfe) {
logger.log(Type.ERROR, "Could not find extension point type '" + typeName + "'!", nfe);
throw new UnableToCompleteException();
}
return result;
}
示例7: 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);
}
示例8: printFactoryMethod
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
private void printFactoryMethod(SourceWriter out, JMethod methodToImplement,
JClassType mockControlInterface, String classToCreate) {
out.println("%s {", methodToImplement.getReadableDeclaration(false, false, false, false, true));
out.indent();
if (isNiceMock(methodToImplement, mockControlInterface)) {
out.print("return this.setToNice(new %s(", classToCreate);
printMatchingParameters(out, methodToImplement);
out.println(").__mockInit(this));");
} else {
out.print("return new %s(", classToCreate);
printMatchingParameters(out, methodToImplement);
out.println(").__mockInit(this);");
}
out.outdent();
out.println("}");
}
示例9: testWriteMultipleImpl
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@Test
public void testWriteMultipleImpl() {
TypeOracleStub oracle = (TypeOracleStub) configuration.getOracle();
JClassType moduleType = oracle.addClass(Modules.ModuleWithParent01.class);
ChildModuleElement childModule = new ChildModuleElement();
childModule.setClassName(moduleType.getQualifiedSourceName());
childModule.setName("childModule");
childModule.setAutoDisplay("false");
configuration.getChildModules()
.add(childModule);
SplitterElement splitter = new SplitterElement();
splitter.setName("splitter");
splitter.setClassName("Splitter");
configuration.getSplitters()
.add(splitter);
configuration.setSuffix("suffix");
assertOutput(getExpectedMultipleImpl(),
false);
writer.writeConf();
assertOutput(getExpectedMultipleImpl(),
true);
}
示例10: testEventBusForOtherModule
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@Test
public void testEventBusForOtherModule()
throws Mvp4gAnnotationException {
List<JClassType> annotedClasses = new ArrayList<JClassType>();
annotedClasses.add(oracle.addClass(Events.EventBusForOtherModule.class));
loader.load(annotedClasses,
configuration);
Map<String, JClassType> othersEventBusClassMap = configuration.getOthersEventBusClassMap();
Iterator<String> it = othersEventBusClassMap.keySet()
.iterator();
String key = it.next();
assertEquals(1,
othersEventBusClassMap.size());
assertEquals(Modules.Module01.class.getCanonicalName(),
key);
assertEquals(Events.EventBusForOtherModule.class.getCanonicalName(),
othersEventBusClassMap.get(key)
.getQualifiedSourceName());
}
示例11: testPath
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@Test
public void testPath()
throws Mvp4gAnnotationException {
List<JClassType> annotedClasses = new ArrayList<JClassType>();
annotedClasses.add(oracle.addClass(getSimpleClass()));
annotedClasses.add(oracle.addClass(getWithNameClass()));
Set<ServiceElement> services = getSet();
assertEquals(services.size(),
0);
loader.load(annotedClasses,
configuration);
assertEquals(services.size(),
2);
for (ServiceElement service : services) {
assertEquals(service.getPath(),
"path");
}
}
示例12: testNoInstanceOfHander
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@Test(expected = Mvp4gAnnotationException.class)
public void testNoInstanceOfHander()
throws Mvp4gAnnotationException {
try {
List<JClassType> annotedClasses = new ArrayList<JClassType>();
annotedClasses.add(oracle.addClass(PresenterWithName.class));
new PresenterAnnotationsLoader().load(annotedClasses,
configuration);
annotedClasses.clear();
annotedClasses = new ArrayList<JClassType>();
JClassType type = oracle.addClass(EventBusOk.class);
annotedClasses.add(type);
loader.load(annotedClasses,
configuration);
} catch (Mvp4gAnnotationException e) {
assertTrue(e.getMessage()
.contains("No instance of"));
throw e;
}
}
示例13: testWithClass
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testWithClass() {
JClassType[] types = new JClassType[5];
types[0] = oracle.findType(OnePresenter.class.getName());
types[1] = oracle.findType(OneHistory.class.getName());
types[2] = oracle.findType(OneEvents.class.getName());
types[3] = oracle.findType(OneService.class.getName());
types[4] = oracle.findType(OneEventHandler.class.getName());
Map<Class<? extends Annotation>, List<JClassType>> scanResult = AnnotationScanner.scan(logger,
oracle,
annotations);
for (int i = 0; i < types.length; i++) {
assertEquals(types[i],
scanResult.get(annotations[i])
.get(0));
}
}
示例14: doGetSourceWriter
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@Override
protected SourceWriter doGetSourceWriter(JClassType classType) {
String packageName = classType.getPackage().getName();
String simpleName = getSimpleUnitName(classType);
ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
packageName, simpleName);
composer.setSuperclass(TypeOracleImpl.class.getCanonicalName());
composer.addImport("org.lirazs.gbackbone.reflection.client.*");
composer.addImport("java.util.*");
composer.addImport(classType.getPackage().getName() + ".*");
PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
if (printWriter == null) {
return null;
} else {
SourceWriter sw = composer.createSourceWriter(context, printWriter);
return sw;
}
}
示例15: createSource
import com.google.gwt.core.ext.typeinfo.JClassType; //導入依賴的package包/類
@Override
protected void createSource(SourceWriter source, JClassType classType) {
source.println("public " + getSimpleUnitName(classType) + "(){");
source.indent();
List<JClassType> types = allReflectionClasses();
for(JClassType type : types){
ReflectionProxyGenerator gen = new ReflectionProxyGenerator();
try {
String classname = gen.generate(this.logger, context, type.getQualifiedSourceName());
source.println("new " + classname + "();");
} catch (UnableToCompleteException e) {
throw new CheckedExceptionWrapper(e);
}
}
source.outdent();
source.println("}");
}