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


Java JClassType.isAssignableTo方法代碼示例

本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.isAssignableTo方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.isAssignableTo方法的具體用法?Java JClassType.isAssignableTo怎麽用?Java JClassType.isAssignableTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.core.ext.typeinfo.JClassType的用法示例。


在下文中一共展示了JClassType.isAssignableTo方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: allReflectionClasses

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private List<JClassType> allReflectionClasses(){
	List<JClassType> types = new ArrayList<JClassType>();
	
	try {
		JClassType reflectionClass = typeOracle.getType(FullReflection.class.getCanonicalName());
		for (JClassType classType : typeOracle.getTypes()) {
			if (classType.isAssignableTo(reflectionClass)){

				processRelationClasses(types, classType);
				addClassIfNotExists(types, classType);
				
			}
		}
	} catch (Exception e) {
		this.logger.log(TreeLogger.Type.ERROR, e.getMessage(), e);
	}
	 
	
	return types;
}
 
開發者ID:liraz,項目名稱:gwt-backbone,代碼行數:21,代碼來源:SourceVisitor.java

示例2: getTestCases

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
public static List<TestCase> getTestCases(TreeLogger logger, GeneratorContext context)
        throws UnableToCompleteException {
    if (DEBUG) logger = logger.branch(TreeLogger.WARN, "Getting test cases", null, null);
    TypeOracle oracle = context.getTypeOracle();
    JClassType jsTestCaseClass = oracle.findType(JsTestCase.class.getName());

    List<TestCase> testCases = new ArrayList<TestCase>();

    for (JClassType classType : oracle.getTypes()) {
        if (classType.equals(jsTestCaseClass) || !classType.isAssignableTo(jsTestCaseClass)) {
            continue;
        }

        if (classType.getEnclosingType() != null) {
            if (DEBUG) logger.log(TreeLogger.WARN, "Skipping nested class: " +
                    classType.getEnclosingType().getName() + "." + classType.getName());
            continue;
        }

        if (DEBUG) logger.log(TreeLogger.WARN, "Found class: " + classType.getName());
        testCases.add(new TestCase(classType, findTests(logger, context, classType)));
    }
    return testCases;
}
 
開發者ID:chromium,項目名稱:dom-distiller,代碼行數:25,代碼來源:JsTestEntryGenerator.java

示例3: getAllInstantiableClassesByThisfactory

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
 * Filter all classes visible to GWT client side and return only those deemed instantiable
 * through the factory class we are generating (that is EntityInputFactoryImpl).
 * <p>
 * Allowing all classes to be instantiable would potentially generate too huge class method
 * perhaps even too huge to compile. There must be some sub-selection. Classes can be filtered
 * based on marker interface, or class annotation see {@link JClassType#getAnnotation(Class)},
 * or some regex matching based on package or class name.
 * 
 * @param context
 * @return Filter all classes visible to GWT client side and return only those deemed
 *         instantiable
 */
private List<JClassType> getAllInstantiableClassesByThisfactory(GeneratorContext context) {
  TypeOracle oracle = context.getTypeOracle();
  JClassType markerInterface1 = oracle.findType(IEntityInput.class.getName());
  JClassType markerInterface2 = oracle.findType(Entity.class.getName());
  List<JClassType> allInstantiableClasses = new LinkedList<JClassType>();

  for (JClassType classType : oracle.getTypes()) {
    if (!classType.equals(markerInterface1) && classType.isAssignableTo(markerInterface1)) {
      allInstantiableClasses.add(classType);
    }
    else if (!classType.equals(markerInterface2) && classType.isAssignableTo(markerInterface2)) {
      allInstantiableClasses.add(classType);
    }
  }

  return allInstantiableClasses;
}
 
開發者ID:KnowledgeCaptureAndDiscovery,項目名稱:ontosoft,代碼行數:31,代碼來源:EntityGenerator.java

示例4: buildEventBusElement

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
 * Build event bus element according to the implemented interface.
 *
 * @param c             annoted class type
 * @param configuration configuration containing loaded elements of the application
 * @return event bus corresponding to the implemented interface (null if none of the interfaces
 * are implemented)
 */
private EventBusElement buildEventBusElement(JClassType c,
                                             Mvp4gConfiguration configuration) {

  TypeOracle oracle = configuration.getOracle();

  EventBusElement eventBus = null;
  if (c.isAssignableTo(oracle.findType(EventBusWithLookup.class.getCanonicalName()))) {
    eventBus = new EventBusElement(c.getQualifiedSourceName(),
                                   BaseEventBusWithLookUp.class.getCanonicalName(),
                                   true);
  } else if (c.isAssignableTo(oracle.findType(EventBus.class.getCanonicalName()))) {
    eventBus = new EventBusElement(c.getQualifiedSourceName(),
                                   BaseEventBus.class.getCanonicalName(),
                                   false);
  }

  return eventBus;
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:27,代碼來源:EventsAnnotationsLoader.java

示例5: isAssignableFromAny

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
protected boolean isAssignableFromAny(final Set<JClassType> uediInterfaces, final JClassType classType) {
    for (final JClassType uediInterface : uediInterfaces) {
        if (classType.isAssignableTo(uediInterface)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:czyzby,項目名稱:uedi,代碼行數:9,代碼來源:ReflectionPoolGenerator.java

示例6: controlType

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
 * Control if the class can accept the annotation.
 *
 * @param c
 *   class to control
 * @param mandatoryInterface
 *   interface that the class must implement
 *
 * @throws Mvp4gAnnotationException
 *   if the class don't implement the interface
 */
@SuppressWarnings("unchecked")
protected void controlType(JClassType c,
                           JClassType mandatoryInterface)
  throws Mvp4gAnnotationException {
  if (!c.isAssignableTo(mandatoryInterface)) {
    String annotationClassName = ((Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]).getCanonicalName();
    throw new Mvp4gAnnotationException(c.getQualifiedSourceName(),
                                       null,
                                       "this class must implement " + mandatoryInterface.getQualifiedSourceName() + " since it is annoted with " + annotationClassName + ".");
  }
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:23,代碼來源:Mvp4gAnnotationsLoader.java

示例7: generate

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public String generate( TreeLogger logger, GeneratorContext context, String typeName ) throws UnableToCompleteException
{
    TypeOracle oracle = context.getTypeOracle( );

    JClassType instantiableType = oracle.findType( Reflectable.class.getName( ) );

    List<JClassType> clazzes = new ArrayList<JClassType>( );

    PropertyOracle propertyOracle = context.getPropertyOracle( );

    for ( JClassType classType : oracle.getTypes( ) )
    {
        if ( !classType.equals( instantiableType ) && classType.isAssignableTo( instantiableType ) )
            clazzes.add( classType );
    }

    final String genPackageName = "org.lirazs.gbackbone.client.generator";
    final String genClassName = "ReflectionImpl";

    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory( genPackageName, genClassName );
    composer.addImplementedInterface( Reflection.class.getCanonicalName( ) );

    composer.addImport( "org.lirazs.gbackbone.client.generator.*" );
    composer.addImport( "org.lirazs.gbackbone.client.core.data.Options" );
    composer.addImport( "com.google.gwt.json.client.JSONObject" );

    PrintWriter printWriter = context.tryCreate( logger, genPackageName, genClassName );

    if ( printWriter != null )
    {
        SourceWriter sourceWriter = composer.createSourceWriter( context, printWriter );
        sourceWriter.println( "ReflectionImpl( ) {" );
        sourceWriter.println( "}" );

        printFactoryMethod(clazzes, sourceWriter);
        printJSONFactoryMethod(clazzes, sourceWriter);
        printArrayFactoryMethod( clazzes, sourceWriter );

        sourceWriter.commit( logger );
    }

    return composer.getCreatedClassName( );
}
 
開發者ID:liraz,項目名稱:gwt-backbone,代碼行數:45,代碼來源:ReflectionGenerator.java

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


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