JsonFiles
final class JsonFiles
Package: dev.joid.internal · Module: core · Source: JsonFiles.java
Reads and writes the JSON files of JOID safely: atomic writes, and a damaged file set aside instead of lost.
Description
Section titled “Description”The stores and the remembered properties of the UIs keep their files with it.
Every failure prints a [JOID] warning instead of throwing.
Learn more
Section titled “Learn more”Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
JsonObject | read(File file, String consequence) static | Returns the JSON object of file, or null when the file does not exist or cannot be used. |
void | write(File file, String json) static | Writes json to file through a temporary file in the same folder, created when missing, then moves it in place in one step, so a crash never leaves half a file. |
void | keep(File file, String failure, String consequence) static | Renames file to <name>.corrupt, replacing an older one, and prints a warning with failure and consequence. |
Method details
Section titled “Method details”JsonObject read(File file, String consequence) static
Returns the JSON object of file, or null when the file does not exist or cannot be used.
A file that holds no JSON object is renamed to <name>.corrupt; the warning ends with consequence, which says what happens instead.
void write(File file, String json) static
Writes json to file through a temporary file in the same folder, created when missing, then moves it in place in one step, so a crash never leaves half a file.
It does nothing when json is the text that it last read or wrote for that file and the file exists.
void keep(File file, String failure, String consequence) static
Renames file to <name>.corrupt, replacing an older one, and prints a warning with failure and consequence.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
