@Test public void testCanGetTypeClass() throws ResourceInitializationException { Set<Class<? extends Entity>> typeClasses = TypeUtils.getTypeClasses(Entity.class, new String[] {Person.class.getSimpleName()}); assertEquals(1, typeClasses.size()); assertTrue(typeClasses.contains(Person.class)); }
public static <T extends BaleenAnnotation> Set<Class<? extends T>> getTypeClasses( Class<T> parentClass, String... typeNames) throws ResourceInitializationException { Set<Class<? extends T>> allAnnotationClasses = getAnnotationClasses(parentClass); if (typeNames == null || typeNames.length == 0) { return allAnnotationClasses; } else { Set<Class<? extends T>> annotationClasses = new HashSet<>(); for (String type : typeNames) { try { annotationClasses.add( allAnnotationClasses.stream() .filter(a -> a.getName().endsWith("." + type)) .findFirst() .orElseThrow( () -> new BaleenException(type + " not found under " + parentClass.getName()))); } catch (BaleenException e) { throw new ResourceInitializationException(e); } } return annotationClasses; } }
TypeUtils { public static <T extends BaleenAnnotation> Set<Class<? extends T>> getTypeClasses( Class<T> parentClass, String... typeNames) throws ResourceInitializationException { Set<Class<? extends T>> allAnnotationClasses = getAnnotationClasses(parentClass); if (typeNames == null || typeNames.length == 0) { return allAnnotationClasses; } else { Set<Class<? extends T>> annotationClasses = new HashSet<>(); for (String type : typeNames) { try { annotationClasses.add( allAnnotationClasses.stream() .filter(a -> a.getName().endsWith("." + type)) .findFirst() .orElseThrow( () -> new BaleenException(type + " not found under " + parentClass.getName()))); } catch (BaleenException e) { throw new ResourceInitializationException(e); } } return annotationClasses; } } }
TypeUtils { public static <T extends BaleenAnnotation> Set<Class<? extends T>> getTypeClasses( Class<T> parentClass, String... typeNames) throws ResourceInitializationException { Set<Class<? extends T>> allAnnotationClasses = getAnnotationClasses(parentClass); if (typeNames == null || typeNames.length == 0) { return allAnnotationClasses; } else { Set<Class<? extends T>> annotationClasses = new HashSet<>(); for (String type : typeNames) { try { annotationClasses.add( allAnnotationClasses.stream() .filter(a -> a.getName().endsWith("." + type)) .findFirst() .orElseThrow( () -> new BaleenException(type + " not found under " + parentClass.getName()))); } catch (BaleenException e) { throw new ResourceInitializationException(e); } } return annotationClasses; } } private  TypeUtils(); }
TypeUtils { public static <T extends BaleenAnnotation> Set<Class<? extends T>> getTypeClasses( Class<T> parentClass, String... typeNames) throws ResourceInitializationException { Set<Class<? extends T>> allAnnotationClasses = getAnnotationClasses(parentClass); if (typeNames == null || typeNames.length == 0) { return allAnnotationClasses; } else { Set<Class<? extends T>> annotationClasses = new HashSet<>(); for (String type : typeNames) { try { annotationClasses.add( allAnnotationClasses.stream() .filter(a -> a.getName().endsWith("." + type)) .findFirst() .orElseThrow( () -> new BaleenException(type + " not found under " + parentClass.getName()))); } catch (BaleenException e) { throw new ResourceInitializationException(e); } } return annotationClasses; } } private  TypeUtils(); static Class<? extends AnnotationBase> getType(String typeName, JCas jCas); @SuppressWarnings("unchecked") static Class<AnnotationBase> getType(String typeName, TypeSystem typeSystem); @SuppressWarnings("unchecked") static Class<? extends Entity> getEntityClass(String typeName, JCas jCas); @SuppressWarnings({"unchecked", "squid:S2175" /* false positive */}) static List<T> filterAnnotations(
      Collection<? extends BaleenAnnotation> collection, Set<Class<? extends T>> annotationTypes); static Set<Class<? extends T>> getAnnotationClasses(
      Class<T> annotationType); static Set<Class<? extends T>> getTypeClasses(
      Class<T> parentClass, String... typeNames); }
TypeUtils { public static <T extends BaleenAnnotation> Set<Class<? extends T>> getTypeClasses( Class<T> parentClass, String... typeNames) throws ResourceInitializationException { Set<Class<? extends T>> allAnnotationClasses = getAnnotationClasses(parentClass); if (typeNames == null || typeNames.length == 0) { return allAnnotationClasses; } else { Set<Class<? extends T>> annotationClasses = new HashSet<>(); for (String type : typeNames) { try { annotationClasses.add( allAnnotationClasses.stream() .filter(a -> a.getName().endsWith("." + type)) .findFirst() .orElseThrow( () -> new BaleenException(type + " not found under " + parentClass.getName()))); } catch (BaleenException e) { throw new ResourceInitializationException(e); } } return annotationClasses; } } private  TypeUtils(); static Class<? extends AnnotationBase> getType(String typeName, JCas jCas); @SuppressWarnings("unchecked") static Class<AnnotationBase> getType(String typeName, TypeSystem typeSystem); @SuppressWarnings("unchecked") static Class<? extends Entity> getEntityClass(String typeName, JCas jCas); @SuppressWarnings({"unchecked", "squid:S2175" /* false positive */}) static List<T> filterAnnotations(
      Collection<? extends BaleenAnnotation> collection, Set<Class<? extends T>> annotationTypes); static Set<Class<? extends T>> getAnnotationClasses(
      Class<T> annotationType); static Set<Class<? extends T>> getTypeClasses(
      Class<T> parentClass, String... typeNames);  }