Class JSONDialect
- java.lang.Object
-
- xyz.srnyx.annoyingapi.storage.dialects.Dialect
-
- xyz.srnyx.annoyingapi.storage.dialects.JSONDialect
-
public class JSONDialect extends Dialect
Data dialect for JSON database
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJSONDialect.JsonFileA wrapper for a JSON file with utility methods-
Nested classes/interfaces inherited from class xyz.srnyx.annoyingapi.storage.dialects.Dialect
Dialect.MigrationData
-
-
Field Summary
-
Fields inherited from class xyz.srnyx.annoyingapi.storage.dialects.Dialect
dataManager
-
-
Constructor Summary
Constructors Constructor Description JSONDialect(@NotNull DataManager dataManager)Creates a new H2 dialect
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable ValuegetFromCacheImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String key)Get a value from the cacheprotected @NotNull java.util.Optional<java.lang.String>getFromDatabaseImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String key)Get a value from the databaseprotected @NotNull java.util.Optional<Dialect.MigrationData>getMigrationDataFromDatabaseImpl(@NotNull DataManager newManager)Get migration data from the databasevoidmarkRemovedInCacheImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String key)Mark a value as removed in the cacheprotected booleanremoveFromDatabaseImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String key)Remove a value from the databasevoidsaveCacheImpl()Save all cache data to the databasevoidsaveCacheImpl(@NotNull java.lang.String table, @NotNull java.lang.String target)Save a specific target in a table to the cachevoidsetToCacheImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String key, @NotNull Value value)Set a value to the cacheprotected @Nullable FailedSetsetToDatabaseImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String key, @NotNull java.lang.String value)Set a value to the databaseprotected @NotNull java.util.Set<FailedSet>setToDatabaseImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.util.concurrent.ConcurrentHashMap<java.lang.String,Value> data)Set multiple values to the database-
Methods inherited from class xyz.srnyx.annoyingapi.storage.dialects.Dialect
getFromCache, getFromDatabase, getMigrationDataFromDatabase, markRemovedInCache, removeValueFromDatabase, saveCache, saveCache, setToCache, setToDatabase, setToDatabase, setToDatabase
-
-
-
-
Constructor Detail
-
JSONDialect
public JSONDialect(@NotNull @NotNull DataManager dataManager)Creates a new H2 dialect- Parameters:
dataManager-Dialect.dataManager
-
-
Method Detail
-
getFromCacheImpl
@Nullable public @Nullable Value getFromCacheImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String key)
Description copied from class:DialectGet a value from the cache- Specified by:
getFromCacheImplin classDialect- Parameters:
table- the tabletarget- the targetkey- the key- Returns:
- the value inside a
Value, null if it isn't cached
-
setToCacheImpl
public void setToCacheImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String key, @NotNull @NotNull Value value)Description copied from class:DialectSet a value to the cache- Specified by:
setToCacheImplin classDialect- Parameters:
table- the tabletarget- the targetkey- the keyvalue- the value inside aValue
-
markRemovedInCacheImpl
public void markRemovedInCacheImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String key)Description copied from class:DialectMark a value as removed in the cache- Specified by:
markRemovedInCacheImplin classDialect- Parameters:
table- the tabletarget- the targetkey- the key
-
saveCacheImpl
public void saveCacheImpl()
Description copied from class:DialectSave all cache data to the database- Specified by:
saveCacheImplin classDialect
-
saveCacheImpl
public void saveCacheImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target)Description copied from class:DialectSave a specific target in a table to the cache- Specified by:
saveCacheImplin classDialect- Parameters:
table- the table to save intarget- the target to save
-
getMigrationDataFromDatabaseImpl
@NotNull protected @NotNull java.util.Optional<Dialect.MigrationData> getMigrationDataFromDatabaseImpl(@NotNull @NotNull DataManager newManager)
Description copied from class:DialectGet migration data from the database- Specified by:
getMigrationDataFromDatabaseImplin classDialect- Parameters:
newManager- the newDataManagerto migrate to- Returns:
- the migration data, empty if something went wrong
-
getFromDatabaseImpl
@NotNull protected @NotNull java.util.Optional<java.lang.String> getFromDatabaseImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String key)Description copied from class:DialectGet a value from the database- Specified by:
getFromDatabaseImplin classDialect- Parameters:
table- the table to get fromtarget- the target to get fromkey- the key to get- Returns:
- the value, empty if not found
-
setToDatabaseImpl
@Nullable protected @Nullable FailedSet setToDatabaseImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String value)
Description copied from class:DialectSet a value to the database- Specified by:
setToDatabaseImplin classDialect- Parameters:
table- the table to set totarget- the target to set tokey- the key to setvalue- the value to set- Returns:
- the failed value information, null if successful
-
setToDatabaseImpl
@NotNull protected @NotNull java.util.Set<FailedSet> setToDatabaseImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.util.concurrent.ConcurrentHashMap<java.lang.String,Value> data)
Description copied from class:DialectSet multiple values to the database- Specified by:
setToDatabaseImplin classDialect- Parameters:
table- the table to set totarget- the target to set todata- the data to set- Returns:
- set of failed values as
FailedSets
-
removeFromDatabaseImpl
protected boolean removeFromDatabaseImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String key)Description copied from class:DialectRemove a value from the database- Specified by:
removeFromDatabaseImplin classDialect- Parameters:
table- the table to remove fromtarget- the target to remove fromkey- the key to remove- Returns:
- true if the value was successfully removed, false otherwise
-
-