
com.steenhq.application.util.ReflectionUtil Maven / Gradle / Ivy
/*
* Copyright 2018 Frederick Steen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.steenhq.application.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
@SuppressWarnings("rawtypes")
public final class ReflectionUtil {
public static Set> getClassesRecursively(String fullPackageName, ClassLoader classLoader)
throws IOException, ClassNotFoundException {
Set> classes = new HashSet<>();
ImmutableSet classInfos = ClassPath.from(classLoader)
.getTopLevelClassesRecursive(fullPackageName);
for (ClassPath.ClassInfo info : classInfos) {
Class> clazz = Class.forName(info.getName());
classes.add(clazz);
}
return classes;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy