Package eu.bandm.tools.util.files
Class Installable<T>
java.lang.Object
eu.bandm.tools.util.files.Installable<T>
- Type Parameters:
T
- the type of object to store
- All Implemented Interfaces:
Supplier<T>
Store a reference to an object that may be created at runtime or
serialized as a resource.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
-
Field Details
-
resourceSeparator
- See Also:
-
-
Constructor Details
-
Installable
public Installable(Class<?> ownerClass, Class<? extends T> valueClass, String name, @Opt @Opt Supplier<? extends T> creator) Create a new instance.An attempt is made to load the serialized object as a resource. If that fails, the object is created newly.
- Parameters:
ownerClass
- the class that owns the stored object and the resourcevalueClass
- the type of the stored objectthe
- simple name of the object and resourcecreator
- a function object to create the object on the fly- Throws:
IllegalArgumentException
- ifname
is not a valid Java identifier
-
-
Method Details
-
get
Return the stored object. -
getResourceName
Return the resource name for the stored object. -
store
Store the object in a file.The relative file name is the resource name for the stored object.
To install the file as a resource, place it in the classpath beside the owner class.
- Parameters:
targetDirectory
- the target directory- Throws:
IOException
- if the object file cannot be written.
-