public static Class[] callGetDeclaredClasses(Class thiz) throws SecurityException { return thiz.getDeclaredClasses(); }
@Override public String[] getMemberClassNames() { LinkedHashSet<String> memberClassNames = new LinkedHashSet<>(4); for (Class<?> nestedClass : this.introspectedClass.getDeclaredClasses()) { memberClassNames.add(nestedClass.getName()); } return StringUtils.toStringArray(memberClassNames); }
public static Collection<Status> all() { Collection<Status> result = new ArrayList<>(); for ( Class<?> child : Status.class.getDeclaredClasses() ) { if ( child.isEnum() && Status.class.isAssignableFrom( child ) ) { @SuppressWarnings( "unchecked" ) Class<? extends Status> statusType = (Class<? extends Status>) child; Collections.addAll( result, statusType.getEnumConstants() ); } } return result; }
/** * {@inheritDoc} */ public TypeList getDeclaredTypes() { return new TypeList.ForLoadedTypes(type.getDeclaredClasses()); }
/** Reflectively instantiate the package-private {@code MethodResolutionPhase} enum. */ private static Object newMethodResolutionPhase(boolean autoboxing) { for (Class<?> c : Resolve.class.getDeclaredClasses()) { if (!c.getName().equals("com.sun.tools.javac.comp.Resolve$MethodResolutionPhase")) { continue; } for (Object e : c.getEnumConstants()) { if (e.toString().equals(autoboxing ? "BOX" : "BASIC")) { return e; } } } return null; }
@Override public String[] getMemberClassNames() { LinkedHashSet<String> memberClassNames = new LinkedHashSet<>(4); for (Class<?> nestedClass : this.introspectedClass.getDeclaredClasses()) { memberClassNames.add(nestedClass.getName()); } return StringUtils.toStringArray(memberClassNames); }
for (Class<?> candidate : declaringClass.getDeclaredClasses()) { if (isDefaultConfigurationClassCandidate(candidate)) { configClasses.add(candidate);
@NotNull private static Type getResultType(@NotNull String method) { for (Class<?> c : DlvRequest.class.getDeclaredClasses()) { if (method.equals(c.getSimpleName())) { Type s = c.getGenericSuperclass(); assert s instanceof ParameterizedType : c.getCanonicalName() + " should have a generic parameter for correct callback processing"; Type[] arguments = ((ParameterizedType)s).getActualTypeArguments(); assert arguments.length == 1 : c.getCanonicalName() + " should have only one generic argument for correct callback processing"; return arguments[0]; } } CommandProcessorKt.getLOG().error("Unknown response " + method + ", please register an appropriate request into com.goide.dlv.protocol.DlvRequest"); return Object.class; } }
public void testFinalizeClassHasNoNestedClasses() throws Exception { // Ensure that the Finalizer class has no nested classes. // See https://code.google.com/p/guava-libraries/issues/detail?id=1505 assertEquals(Collections.emptyList(), Arrays.asList(Finalizer.class.getDeclaredClasses())); } }
Class<?> sourceClass = (Class<?>) sourceToProcess; try { Class<?>[] declaredClasses = sourceClass.getDeclaredClasses(); List<SourceClass> members = new ArrayList<>(declaredClasses.length); for (Class<?> declaredClass : declaredClasses) {
/** * Get inner class by its name from the enclosing class. * * @param parentCls Parent class to resolve inner class for. * @param innerClsName Name of the inner class. * @return Inner class. */ @Nullable public static <T> Class<T> getInnerClass(Class<?> parentCls, String innerClsName) { for (Class<?> cls : parentCls.getDeclaredClasses()) if (innerClsName.equals(cls.getSimpleName())) return (Class<T>)cls; return null; }
@BeforeClass public static void collectAllDifferentInconsistencyTypes() { Class<?> reportClass = ConsistencyReport.class; for ( Class<?> cls : reportClass.getDeclaredClasses() ) { for ( Method method : cls.getDeclaredMethods() ) { if ( method.getAnnotation( Documented.class ) != null ) { Set<String> types = allReports.computeIfAbsent( cls, k -> new HashSet<>() ); types.add( method.getName() ); } } } }
private final static void setEnv(Map<String, String> newenv) throws Exception { Class[] classes = Collections.class.getDeclaredClasses(); Map<String, String> env = System.getenv(); for (Class cl : classes) { if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) { Field field = cl.getDeclaredField("m"); field.setAccessible(true); Object obj = field.get(env); Map<String, String> map = (Map<String, String>) obj; map.clear(); map.putAll(newenv); } } }
private final static void setEnv(Map<String, String> newenv) throws Exception { Class[] classes = Collections.class.getDeclaredClasses(); Map<String, String> env = System.getenv(); for (Class cl : classes) { if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) { Field field = cl.getDeclaredField("m"); field.setAccessible(true); Object obj = field.get(env); Map<String, String> map = (Map<String, String>) obj; map.clear(); map.putAll(newenv); } } }
@SuppressWarnings("unchecked") public static Map<String, String> getModifiableSystemEnvironment() { Class<?>[] classes = Collections.class.getDeclaredClasses(); Map<String, String> env = System.getenv(); for (Class<?> cl : classes) {
public static <E extends Enum<?> & Feature<?>> void assertGoodFeatureEnum( Class<E> featureEnumClass) { final Class<?>[] classes = featureEnumClass.getDeclaredClasses(); for (Class<?> containedClass : classes) { if (containedClass.getSimpleName().equals("Require")) { if (containedClass.isAnnotation()) { assertGoodTesterAnnotation(asAnnotation(containedClass)); } else { fail( rootLocaleFormat( "Feature enum %s contains a class named " + "'Require' but it is not an annotation.", featureEnumClass)); } return; } } fail( rootLocaleFormat( "Feature enum %s should contain an " + "annotation named 'Require'.", featureEnumClass)); }
@Test public void inner_class_exists() throws Exception { Class[] innerClasses = WaitlistContract.class.getDeclaredClasses(); assertEquals("There should be 1 Inner class inside the contract class", 1, innerClasses.length); }
@Test public void inner_class_type_correct() throws Exception { Class[] innerClasses = WaitlistContract.class.getDeclaredClasses(); assertEquals("Cannot find inner class to complete unit test", 1, innerClasses.length); Class entryClass = innerClasses[0]; assertTrue("Inner class should implement the BaseColumns interface", BaseColumns.class.isAssignableFrom(entryClass)); assertTrue("Inner class should be final", Modifier.isFinal(entryClass.getModifiers())); assertTrue("Inner class should be static", Modifier.isStatic(entryClass.getModifiers())); }
@Test public void inner_class_type_correct() throws Exception { Class[] innerClasses = WaitlistContract.class.getDeclaredClasses(); assertEquals("Cannot find inner class to complete unit test", 1, innerClasses.length); Class entryClass = innerClasses[0]; assertTrue("Inner class should implement the BaseColumns interface", BaseColumns.class.isAssignableFrom(entryClass)); assertTrue("Inner class should be final", Modifier.isFinal(entryClass.getModifiers())); assertTrue("Inner class should be static", Modifier.isStatic(entryClass.getModifiers())); }
@Test public void inner_class_type_correct() throws Exception { Class[] innerClasses = WaitlistContract.class.getDeclaredClasses(); assertEquals("Cannot find inner class to complete unit test", 1, innerClasses.length); Class entryClass = innerClasses[0]; assertTrue("Inner class should implement the BaseColumns interface", BaseColumns.class.isAssignableFrom(entryClass)); assertTrue("Inner class should be final", Modifier.isFinal(entryClass.getModifiers())); assertTrue("Inner class should be static", Modifier.isStatic(entryClass.getModifiers())); }