ru.vyarus.java.generics.resolver.GenericsResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of generics-resolver Show documentation
Show all versions of generics-resolver Show documentation
Java generics runtime resolver
package ru.vyarus.java.generics.resolver;
import ru.vyarus.java.generics.resolver.context.GenericsContext;
import ru.vyarus.java.generics.resolver.context.GenericsInfoFactory;
/**
* Resolves class hierarchy generics and provides api for introspection.
*
* @author Vyacheslav Rusakov
* @since 17.11.2014
*/
public final class GenericsResolver {
private GenericsResolver() {
}
/**
* By default returned context set on root class, which can't be introspected (because only parent class hods
* generics information for current class). To use it switch context to required type from hierarchy:
* {@code returnedContext.type(SomeTypeFromHierarchy.class)}.
* Note: when ignore classes provided, produced {@code GenericsInfo} instance will not be cached
* (and full version from cache will not be used also)
*
* @param type root class to resolve generics hierarchy
* @param ignoreClasses list of classes to ignore during inspection (useful to avoid interface clashes
* or to limit resolution depth)
* @return resolved generics context object
*/
public static GenericsContext resolve(final Class> type, final Class>... ignoreClasses) {
return new GenericsContext(GenericsInfoFactory.create(type, ignoreClasses), type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy