Package org.openapitools.codegen.utils
Interface JsonCache.Root
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classJsonCache.Root.MergePolicyDescribes cache behaviour when a load method is called for a cache instance that is already loaded.-
Nested classes/interfaces inherited from interface org.openapitools.codegen.utils.JsonCache
JsonCache.CacheException, JsonCache.Factory, JsonCache.Root
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonCache.Rootflush(File file)If the cache is dirty, saves the object graph in JSON format to the specified file.JsonCache.Rootflush(OutputStream out)If the cache is dirty, saves the object graph in JSON format to the specified stream.JsonCache.RootflushOnShutdown(File file)Makes a best-effort attempt to ensure that the cache gets flushed to a disk file if dirty on shutdown.JsonCache.RootflushOnShutdown(OutputStream out)Makes a best-effort attempt to ensure that the cache gets flushed to an output stream if dirty on shutdown.com.fasterxml.jackson.databind.ObjectMappergetMapper()Returns the mapper used for JSON-object marshalling and serialisation operations.JsonCache.Root.MergePolicygetMergePolicy()Returns the merge policy that applies whenload()is called on a cache that is already loaded.booleanisDirty()Indicates whether the cached has unsaved changes.JsonCache.Rootload(File file)Loads the cache from the specified file.JsonCache.Rootload(InputStream in)Loads the cache from the specified stream.JsonCache.Rootmapper(com.fasterxml.jackson.databind.ObjectMapper mapper)Sets the mapper to use for JSON-object marshalling and serialisation operations.JsonCache.RootmergePolicy(JsonCache.Root.MergePolicy policy)Sets the merge policy that applies whenload()is called for a cache that is already loaded.JsonCache.Rootsave(File file)Saves the object graph in JSON format to the specified file.JsonCache.Rootsave(OutputStream out)Saves the object graph in JSON format to the specified stream.JsonCache.Rootunload()Unloads the object graph, setting the root node tonull.-
Methods inherited from interface org.openapitools.codegen.utils.JsonCache
add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, child, child, delete, delete, exists, exists, get, get, get, get, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBigInteger, getBigInteger, getBinary, getBinary, getBinary, getBinary, getBoolean, getBoolean, getBoolean, getBoolean, getDouble, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getFloat, getInt, getInt, getInt, getInt, getLong, getLong, getLong, getLong, getNodeType, getNodeType, getNumber, getNumber, getNumber, getNumber, getObject, getObject, getObject, getObject, getObjects, getObjects, getObjects, getObjects, getShort, getShort, getShort, getShort, getString, getString, getString, getString, parent, root, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, size, size
-
-
-
-
Method Detail
-
flush
JsonCache.Root flush(File file) throws JsonCache.CacheException
If the cache is dirty, saves the object graph in JSON format to the specified file.- Parameters:
file- The output file.- Returns:
- The receiver, to allow chaining.
- Throws:
JsonCache.CacheException- if the root node does not exist or if unable to create or write the file.NullPointerException- iffileisnull.- See Also:
flushOnShutdown(File),save(File)
-
flush
JsonCache.Root flush(OutputStream out) throws JsonCache.CacheException
If the cache is dirty, saves the object graph in JSON format to the specified stream.- Parameters:
out- The output stream, which is closed before the method returns.- Returns:
- The receiver, to allow chaining.
- Throws:
JsonCache.CacheException- if the root node does not exist or if unable to create or write the file.NullPointerException- ifoutisnull.- See Also:
flushOnShutdown(OutputStream),save(OutputStream)
-
flushOnShutdown
JsonCache.Root flushOnShutdown(File file)
Makes a best-effort attempt to ensure that the cache gets flushed to a disk file if dirty on shutdown. The call has no additional effect if the shutdown hook has already been registered.- Parameters:
file- The output file.- Returns:
- The receiver, to allow chaining.
- Throws:
NullPointerException- iffileisnull.- See Also:
save(File)
-
flushOnShutdown
JsonCache.Root flushOnShutdown(OutputStream out)
Makes a best-effort attempt to ensure that the cache gets flushed to an output stream if dirty on shutdown. The call has no additional effect if the shutdown hook has already been registered.- Parameters:
out- The output stream, which is closed after writing it on shutdown.- Returns:
- The receiver, to allow chaining.
- Throws:
NullPointerException- ifoutisnull.- See Also:
save(OutputStream)
-
getMapper
com.fasterxml.jackson.databind.ObjectMapper getMapper()
Returns the mapper used for JSON-object marshalling and serialisation operations. Callers may configure the mapper to achieve the desired JSON serialisation format.- Returns:
- The mapper.
- See Also:
mapper(ObjectMapper)
-
getMergePolicy
JsonCache.Root.MergePolicy getMergePolicy()
Returns the merge policy that applies whenload()is called on a cache that is already loaded. The default isJsonCache.Root.MergePolicy.MERGE_RECURSIVE;- Returns:
- The merge policy.
- See Also:
mergePolicy(MergePolicy)
-
isDirty
boolean isDirty()
Indicates whether the cached has unsaved changes.- Returns:
trueif there are unsaved changes.
-
load
JsonCache.Root load(File file) throws JsonCache.CacheException
Loads the cache from the specified file. If the cache is already loaded, merges the incoming tree according to the currentmerge policy. The call has no effect if the file does not exist.- Parameters:
file- The JSON file to load.- Returns:
- The receiver, to allow chaining.
- Throws:
JsonCache.CacheException- if the file exists but could not be read or its content is not valid JSON.NullPointerException- iffileisnull.- See Also:
save(File),save(OutputStream),unload()
-
load
JsonCache.Root load(InputStream in) throws JsonCache.CacheException
Loads the cache from the specified stream. If the cache is already loaded, merges the incoming tree according to the currentmerge policy.- Parameters:
in- The input stream from which to load, which is closed before the method returns.- Returns:
- The receiver, to allow chaining.
- Throws:
JsonCache.CacheException- if the stream content is not valid JSON.NullPointerException- ifinisnull.- See Also:
save(File),save(OutputStream),unload()
-
mapper
JsonCache.Root mapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
Sets the mapper to use for JSON-object marshalling and serialisation operations.- Parameters:
mapper- The new mapper.- Returns:
- The receiver, to allow chaining.
- Throws:
NullPointerException- ifmapperisnull.- See Also:
getMapper()
-
mergePolicy
JsonCache.Root mergePolicy(JsonCache.Root.MergePolicy policy)
Sets the merge policy that applies whenload()is called for a cache that is already loaded.- Parameters:
policy- The merge policy.- Returns:
- The receiver, to allow chaining.
- Throws:
NullPointerException- ifpolicyis null.- See Also:
getMergePolicy()
-
save
JsonCache.Root save(File file) throws JsonCache.CacheException
Saves the object graph in JSON format to the specified file.- Parameters:
file- The output file.- Returns:
- The receiver, to allow chaining.
- Throws:
NullPointerException- iffileis null.JsonCache.CacheException- if the root node does not exist or if unable to create or write the file.
-
save
JsonCache.Root save(OutputStream out) throws JsonCache.CacheException
Saves the object graph in JSON format to the specified stream.- Parameters:
out- The output stream, which is closed before the method returns.- Returns:
- The receiver, to allow chaining.
- Throws:
NullPointerException- ifoutis null.JsonCache.CacheException- if the root node does not exist or if unable to create or write the file.
-
unload
JsonCache.Root unload()
Unloads the object graph, setting the root node tonull.- Returns:
- The receiver, to allow chaining.
- See Also:
load(File),load(InputStream)
-
-