Package me.croabeast.common
Interface Loadable
public interface Loadable
Represents an object that can be loaded and unloaded dynamically.
This interface provides a standard contract for managing the lifecycle of objects that require initialization and cleanup. Implementing classes should define what "loading" and "unloading" mean in their specific context.
Example usage:
public class ConfigManager implements Loadable {
private boolean loaded;
@Override
public boolean isLoaded() {
return loaded;
}
@Override
public void load() {
// Load configuration files
loaded = true;
}
@Override
public void unload() {
// Release resources
loaded = false;
}
}-
Method Summary
-
Method Details
-
isLoaded
boolean isLoaded()Checks whether this object is currently loaded.- Returns:
trueif the object is loaded,falseotherwise
-
load
void load()Loads the object, initializing necessary resources.This method should be implemented to perform any setup operations required before using the object.
-
unload
void unload()Unloads the object, releasing any held resources.This method should clean up any allocated memory, close file streams, or reset states as necessary.
-