A tiny json based application data utility for Java.
- No Redundancy
- Easily Handles multiple references of same Storage
- Real-Time Write i.e Automatically Saves file on changes
- Auto constructs the entire path
All we need is a DataStorage object.
DataStorage storage = DataStorage.getStorage("settings"); // auto adds ".json suffix", the call is equivalent to "settings.json" storage.put("theme", "dark"); // When put(String, Object) is called // The above line will finish off writing settings.json in the current working directoryDataStorage storage = DataStorage.getStorage(".config", "settings.json"); storage.put("theme", "dark"); // When put(String, Object) is called // The above line will finish off writing settings.json in the .config working directoryNow, if there are multiple cases requesting the reference to the same DataStorage object, so instead of creating multiple instances pointing to the same storage location, the same instance is referenced at every call.
Example:
public class Preferences{ public void saveTheme(){ DataStorage storage = DataStorage.getStorage(".config", "settings.json"); storage.put("theme", "dark"); } public void saveUserInfo(){ DataStorage storage = DataStorage.getStorage(".config", "settings.json"); storage.put("username", "iron-man"); storage.put("password", "!@#$%^&*^"); } }Although, the storage objects request the same json file, so instead of creating multiple references of the class, a single instance is shared to both.
its Like
storage1 = storage2 = the_shared_object