當前位置: 首頁>>代碼示例>>Java>>正文


Java JClassType類代碼示例

本文整理匯總了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;
  }
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:17,代碼來源:EventsAnnotationsLoaderTest.java

示例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);
}
 
開發者ID:Axellience,項目名稱:vue-gwt,代碼行數:26,代碼來源:TemplateGwtGenerator.java

示例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);
}
 
開發者ID:Axellience,項目名稱:vue-gwt,代碼行數:22,代碼來源:TemplateGwtGenerator.java

示例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());
        }
    });
}
 
開發者ID:Axellience,項目名稱:vue-gwt,代碼行數:28,代碼來源:TemplateGwtGenerator.java

示例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());
}
 
開發者ID:Axellience,項目名稱:vue-gwt,代碼行數:31,代碼來源:TemplateGwtGenerator.java

示例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;
  }
 
開發者ID:TOMOTON,項目名稱:gwt-dagger2,代碼行數:31,代碼來源:VersionGenerator.java

示例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);
}
 
開發者ID:czyzby,項目名稱:uedi,代碼行數:24,代碼來源:ReflectionPoolGenerator.java

示例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("}");
}
 
開發者ID:google,項目名稱:easy-gwt-mock,代碼行數:17,代碼來源:MocksControlGenerator.java

示例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);
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:26,代碼來源:Mvp4gConfigurationFileReaderTest.java

示例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());
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:21,代碼來源:EventsAnnotationsLoaderTest.java

示例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");
  }
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:19,代碼來源:ServicesAnnotationsLoaderTest.java

示例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;
  }
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:23,代碼來源:EventsAnnotationsLoaderTest.java

示例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));
  }
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:21,代碼來源:TestAnnotationScanner.java

示例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;
	}
}
 
開發者ID:liraz,項目名稱:gwt-backbone,代碼行數:20,代碼來源:SourceVisitor.java

示例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("}");
}
 
開發者ID:liraz,項目名稱:gwt-backbone,代碼行數:21,代碼來源:SourceVisitor.java


注:本文中的com.google.gwt.core.ext.typeinfo.JClassType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。