Class ResourceResolver
java.lang.Object
eu.cloudnetservice.common.resource.ResourceResolver
A utility class to resolve the location of class resource on the class path or file system.
- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionresolveCodeSourceOfClass(@NonNull Class<?> caller) Resolves the parent location of the given class on the file system or on the class path.private static @NonNull IllegalStateExceptionresolveError(@NonNull Class<?> caller, @NonNull String reason) Constructs a new, unified illegal state exception that can be thrown to indicate that there was some error resolving the URI of a class.
-
Constructor Details
-
ResourceResolver
private ResourceResolver()
-
-
Method Details
-
resolveCodeSourceOfClass
Resolves the parent location of the given class on the file system or on the class path. This means that the method either returns the jar file that contains the given class or the directory in which the given class is located.- Parameters:
caller- the class to get the parent location of.- Returns:
- a URI pointing to the parent location of the given class.
- Throws:
NullPointerException- if the given class is null.IllegalStateException- if there is an error resolving the parent class uri.IllegalArgumentException- if a parent uri candidate was found but couldn't be converted into a URI object.
-
resolveError
@NonNull private static @NonNull IllegalStateException resolveError(@NonNull @NonNull Class<?> caller, @NonNull @NonNull String reason) Constructs a new, unified illegal state exception that can be thrown to indicate that there was some error resolving the URI of a class. The returned exceptions contains the class name and the given error as its detail message.- Parameters:
caller- the class to get the parent location of.reason- the reason why the uri resolution process failed.- Returns:
- a new illegal state exception using a unified detail message based on the given caller class and reason.
- Throws:
NullPointerException- if the given caller class or reason is null.
-