Tabnine Logo
Reflections.getSubTypesOf
Code IndexAdd Tabnine to your IDE (free)

How to use
getSubTypesOf
method
in
org.reflections.Reflections

Best Java code snippets using org.reflections.Reflections.getSubTypesOf (Showing top 20 results out of 1,701)

Refine searchRefine arrow

  • Reflections.<init>
origin: stackoverflow.com

Reflections reflections = new Reflections("my.project.prefix");
Set<Class<? extends Object>> allClasses = 
  reflections.getSubTypesOf(Object.class);
origin: stackoverflow.com

 Reflections reflections = new Reflections("com.mycompany");    
Set<Class<? extends MyInterface>> classes = reflections.getSubTypesOf(MyInterface.class);
origin: stackoverflow.com

 Reflections reflections = new Reflections("my.project.prefix");

Set<Class<? extends SomeType>> subTypes = reflections.getSubTypesOf(SomeType.class);

Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(SomeAnnotation.class);
origin: stackoverflow.com

 Reflections reflections = new Reflections("com.mycompany");    
Set<Class<? extends MyInterface>> classes = reflections.getSubTypesOf(MyInterface.class);
origin: frohoff/ysoserial

public static Set<Class<? extends ObjectPayload>> getPayloadClasses () {
  final Reflections reflections = new Reflections(ObjectPayload.class.getPackage().getName());
  final Set<Class<? extends ObjectPayload>> payloadTypes = reflections.getSubTypesOf(ObjectPayload.class);
  for ( Iterator<Class<? extends ObjectPayload>> iterator = payloadTypes.iterator(); iterator.hasNext(); ) {
    Class<? extends ObjectPayload> pc = iterator.next();
    if ( pc.isInterface() || Modifier.isAbstract(pc.getModifiers()) ) {
      iterator.remove();
    }
  }
  return payloadTypes;
}
origin: twitter/ambrose

 private static ObjectMapper newMapper() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
  mapper.enable(SerializationFeature.INDENT_OUTPUT);
  mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
  mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
  mapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
  mapper.disable(SerializationFeature.CLOSE_CLOSEABLE);
  mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
  mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

  Reflections reflections = new Reflections("com.twitter.ambrose");
  Set<Class<? extends Job>> jobSubTypes = reflections.getSubTypesOf(Job.class);
  mapper.registerSubtypes(jobSubTypes.toArray(new Class<?>[jobSubTypes.size()]));
  return mapper;
 }
}
origin: Alluxio/alluxio

/**
 * Get instances of all subclasses of {@link Command} in a sub-package called "command" the given
 * package.
 *
 * @param pkgName package prefix to look in
 * @param classArgs type of args to instantiate the class
 * @param objectArgs args to instantiate the class
 * @return a mapping from command name to command instance
 */
public static Map<String, Command> loadCommands(String pkgName, Class[] classArgs,
  Object[] objectArgs) {
 Map<String, Command> commandsMap = new HashMap<>();
 Reflections reflections = new Reflections(Command.class.getPackage().getName());
 for (Class<? extends Command> cls : reflections.getSubTypesOf(Command.class)) {
  // Add commands from <pkgName>.command.*
  if (cls.getPackage().getName().equals(pkgName + ".command")
    && !Modifier.isAbstract(cls.getModifiers())) {
   // Only instantiate a concrete class
   Command cmd = CommonUtils.createNewClassInstance(cls, classArgs, objectArgs);
   commandsMap.put(cmd.getCommandName(), cmd);
  }
 }
 return commandsMap;
}
origin: twosigma/beakerx

private Set<Class<? extends BeakerxWidget>> getAllInternalWidget() {
 Reflections reflections = new Reflections(PATH_TO_SCAN);
 return reflections.getSubTypesOf(BeakerxWidget.class);
}
origin: Codecademy/EventHub

@Provides
private EventHubHandler getEventHubHandler(Injector injector, EventHub eventHub)
  throws ClassNotFoundException {
 Map<String, Provider<Command>> commandsMap = Maps.newHashMap();
 Reflections reflections = new Reflections(PACKAGE_NAME);
 Set<Class<? extends Command>> commandClasses = reflections.getSubTypesOf(Command.class);
 for (Class<? extends Command> commandClass : commandClasses) {
  String path = commandClass.getAnnotation(Path.class).value();
  //noinspection unchecked
  commandsMap.put(path, (Provider<Command>) injector.getProvider(commandClass));
 }
 return new EventHubHandler(eventHub, commandsMap);
}
origin: SonarSource/sonarqube

/**
 * Compute set of canonical names of classes implementing ComputationStep in the specified package using reflection.
 */
private static Set<Object> retrieveStepPackageStepsCanonicalNames(String packageName) {
 Reflections reflections = new Reflections(packageName);
 return reflections.getSubTypesOf(ComputationStep.class).stream()
  .filter(input -> !Modifier.isAbstract(input.getModifiers()))
  .map(Class::getCanonicalName)
  .filter(Objects::nonNull)
  .collect(Collectors.toSet());
}
origin: cloudfoundry/uaa

protected static Class<?>[] allSuiteClasses() {
  Reflections reflections = new Reflections("org.cloudfoundry.identity.uaa");
  Set<Class<? extends InjectedMockContextTest>> subTypes =
    reflections.getSubTypesOf(InjectedMockContextTest.class).stream().filter(
      c -> !Modifier.isAbstract(c.getModifiers())
    ).collect(Collectors.toSet());
  return subTypes.toArray(new Class[subTypes.size()]);
}
origin: apache/flink

  @Test
  public void testTypeInfoTestCoverage() {
    Reflections reflections = new Reflections("org.apache.flink");

    Set<Class<? extends TypeInformation>> typeInfos = reflections.getSubTypesOf(TypeInformation.class);

    Set<String> typeInfoTestNames = reflections.getSubTypesOf(TypeInformationTestBase.class)
        .stream().map(Class::getName).collect(Collectors.toSet());

    // check if a test exists for each type information
    for (Class<? extends TypeInformation> typeInfo : typeInfos) {
      // we skip abstract classes and inner classes to skip type information defined in test classes
      if (Modifier.isAbstract(typeInfo.getModifiers()) ||
          Modifier.isPrivate(typeInfo.getModifiers()) ||
          typeInfo.getName().contains("Test$") ||
          typeInfo.getName().contains("TestBase$") ||
          typeInfo.getName().contains("ITCase$") ||
          typeInfo.getName().contains("$$anon") ||
          typeInfo.getName().contains("queryablestate")) {
        continue;
      }

      final String testToFind = typeInfo.getName() + "Test";
      if (!typeInfoTestNames.contains(testToFind)) {
        fail("Could not find test '" + testToFind + "' that covers '" + typeInfo.getName() + "'.");
      }
    }
  }
}
origin: apache/kylin

  public static void main(String[] args) {
    Set<Class<? extends Serializable>> subTypesOfSerializable = new Reflections("org.apache.kylin").getSubTypesOf(Serializable.class);
    String begin = "kyroClasses.add(";
    String end = ".class);";
    TreeSet<String> sortedSet = new TreeSet();
    for (Class clazz : subTypesOfSerializable) {
      if (clazz.getCanonicalName() != null)
        sortedSet.add(clazz.getCanonicalName());
    }
    Set<Class<? extends BytesSerializer>> subTypesOfBytes = new Reflections("org.apache.kylin.metadata.datatype").getSubTypesOf(BytesSerializer.class);
    for (Class clazz : subTypesOfBytes) {
      if (clazz.getCanonicalName() != null)
        sortedSet.add(clazz.getCanonicalName());
    }
    Set<Class<? extends MeasureIngester>> subTypesOfMeasure = new Reflections("org.apache.kylin.measure").getSubTypesOf(MeasureIngester.class);
    for (Class clazz : subTypesOfMeasure) {
      if (clazz.getCanonicalName() != null)
        sortedSet.add(clazz.getCanonicalName());
    }
    for (String className : sortedSet) {
      System.out.println(begin + className + end);
    }
  }
}
origin: apache/flink

@Test
public void ensureStateHandlesHaveSerialVersionUID() {
  try {
    Reflections reflections = new Reflections("org.apache.flink");
    // check all state handles
    @SuppressWarnings("unchecked")
    Set<Class<?>> stateHandleImplementations = (Set<Class<?>>) (Set<?>)
        reflections.getSubTypesOf(StateObject.class);
    for (Class<?> clazz : stateHandleImplementations) {
      validataSerialVersionUID(clazz);
    }
  }
  catch (Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}
origin: igniterealtime/Smack

  testPackages = config.testPackages.toArray(new String[config.testPackages.size()]);
Reflections reflections = new Reflections(testPackages, new SubTypesScanner(),
        new TypeAnnotationsScanner(), new MethodAnnotationsScanner(), new MethodParameterScanner());
Set<Class<? extends AbstractSmackIntegrationTest>> inttestClasses = reflections.getSubTypesOf(AbstractSmackIntegrationTest.class);
Set<Class<? extends AbstractSmackLowLevelIntegrationTest>> lowLevelInttestClasses = reflections.getSubTypesOf(AbstractSmackLowLevelIntegrationTest.class);
origin: querydsl/querydsl

args.put(String.class, "obj");
Reflections reflections = new Reflections();
Set<Class<? extends Expression>> types = reflections.getSubTypesOf(Expression.class);
for (Class<?> type : types) {
  if (!type.isInterface() && !type.isMemberClass() && !Modifier.isAbstract(type.getModifiers())) {
origin: apache/metron

 private static synchronized void load() {
  LOG.debug("Starting Parser Index Load");
  ClassLoader classLoader = ParserIndex.class.getClassLoader();
  Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(effectiveClassPathUrls(classLoader)));
  Set<Class<? extends MessageParser>> indexLoc = reflections.getSubTypesOf(MessageParser.class);
  Map<String, String> availableParsersLoc = new HashMap<>();
  indexLoc.forEach(parserClass -> {
   if (!"BasicParser".equals(parserClass.getSimpleName())) {
    availableParsersLoc.put(parserClass.getSimpleName().replaceAll("Basic|Parser", ""),
        parserClass.getName());
   }
  });
  LOG.debug("Finished Parser Index Load; found {} parsers, indexed {} parsers", indexLoc.size(), availableParsersLoc.size());
  index = indexLoc;
  availableParsers = availableParsersLoc;
 }
}
origin: KylinOLAP/Kylin

private void init() {
  providers = Maps.newConcurrentMap();
  // use reflection to load providers
  final Set<Class<? extends IRealizationProvider>> realizationProviders = new Reflections("org.apache.kylin", new SubTypesScanner()).getSubTypesOf(IRealizationProvider.class);
  List<Throwable> es = Lists.newArrayList();
  for (Class<? extends IRealizationProvider> cls : realizationProviders) {
    try {
      IRealizationProvider p = (IRealizationProvider) cls.getMethod("getInstance", KylinConfig.class).invoke(null, config);
      providers.put(p.getRealizationType(), p);
    } catch (Exception | NoClassDefFoundError e) {
      es.add(e);
    }
    if (es.size() > 0) {
      for (Throwable exceptionOrError : es) {
        logger.error("Create new store instance failed ", exceptionOrError);
      }
      throw new IllegalArgumentException("Failed to find metadata store by url: " + config.getMetadataUrl());
    }
  }
  logger.info("RealizationRegistry is " + providers);
}
origin: apache/cloudstack

public KVMStoragePoolManager(StorageLayer storagelayer, KVMHAMonitor monitor) {
  this._haMonitor = monitor;
  this._storageMapper.put("libvirt", new LibvirtStorageAdaptor(storagelayer));
  // add other storage adaptors here
  // this._storageMapper.put("newadaptor", new NewStorageAdaptor(storagelayer));
  this._storageMapper.put(StoragePoolType.ManagedNFS.toString(), new ManagedNfsStorageAdaptor(storagelayer));
  // add any adaptors that wish to register themselves via annotation
  Reflections reflections = new Reflections("com.cloud.hypervisor.kvm.storage");
  Set<Class<? extends StorageAdaptor>> storageAdaptors = reflections.getSubTypesOf(StorageAdaptor.class);
  for (Class<? extends StorageAdaptor> storageAdaptor : storageAdaptors) {
    StorageAdaptorInfo info = storageAdaptor.getAnnotation(StorageAdaptorInfo.class);
    if (info != null && info.storagePoolType() != null) {
      if (this._storageMapper.containsKey(info.storagePoolType().toString())) {
        s_logger.error("Duplicate StorageAdaptor type " + info.storagePoolType().toString() + ", not loading " + storageAdaptor.getName());
      } else {
        try {
          this._storageMapper.put(info.storagePoolType().toString(), storageAdaptor.newInstance());
        } catch (Exception ex) {
          throw new CloudRuntimeException(ex.toString());
        }
      }
    }
  }
  for (Map.Entry<String, StorageAdaptor> adaptors : this._storageMapper.entrySet()) {
    s_logger.debug("Registered a StorageAdaptor for " + adaptors.getKey());
  }
}
origin: com.teradata.tempto/tempto-core

  @Override
  @SuppressWarnings("unchecked")
  public Set<Class> load(Class key)
      throws Exception
  {
    Reflections reflections = new Reflections(PACKAGES_PREFIX);
    return reflections.getSubTypesOf(key);
  }
});
org.reflectionsReflectionsgetSubTypesOf

Javadoc

gets all sub types in hierarchy of a given type

depends on SubTypesScanner configured

Popular methods of Reflections

  • <init>
    a convenient constructor for Reflections, where given Object... parameter types can be either: * St
  • getTypesAnnotatedWith
    get types annotated with a given annotation, both classes and annotations, including annotation memb
  • getResources
  • getMethodsAnnotatedWith
    get all methods annotated with a given annotation, including annotation member values matchingdepend
  • getStore
    returns the org.reflections.Store used for storing and querying the metadata
  • getFieldsAnnotatedWith
    get all methods annotated with a given annotation, including annotation member values matchingdepend
  • merge
    merges a Reflections instance metadata into this instance
  • collect
  • getConstructorsAnnotatedWith
    get all constructors annotated with a given annotation, including annotation member values matchingd
  • getConstructorsWithAnyParamAnnotated
    get constructors with any parameter annotated with given annotation, including annotation member val
  • getMethodsWithAnyParamAnnotated
    get methods with any parameter annotated with given annotation, including annotation member values m
  • save
    serialize to a given directory and filename using given serializer* it is preferred to specify a des
  • getMethodsWithAnyParamAnnotated,
  • save,
  • scan,
  • getAllAnnotated,
  • index,
  • loaders,
  • expandSuperTypes,
  • expandSupertypes,
  • getConfiguration

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now