public class WordCache extends Logging.Loggable
Word
Objects.Constructor and Description |
---|
WordCache(IOUtils.SavingConfig config)
Creates a new instance using the given
IOUtils.SavingConfig . |
Modifier and Type | Method and Description |
---|---|
IOUtils.SavingConfig |
getSavingConfig()
Returns the used
IOUtils.SavingConfig . |
boolean |
isEnabled()
Returns whether the caching is enabled.
|
boolean |
isInCache(java.lang.String word)
Checks whether a word is present in the cache.
|
Word |
readFromCache(java.lang.String word)
Reads a
Word Object from the cache. |
void |
setEnabled(boolean enabled)
Enables or disables caching.
|
void |
writeInCache(Word word)
Writes the information of a
Word Object in the cache (when its
enabled). |
getLogger, setLogger
public WordCache(IOUtils.SavingConfig config)
IOUtils.SavingConfig
.config
- The saving configuration.public IOUtils.SavingConfig getSavingConfig()
IOUtils.SavingConfig
.public boolean isEnabled()
true
when enabled, else false
public void setEnabled(boolean enabled)
enabled
- Whether caching should be enabled.public void writeInCache(Word word)
Word
Object in the cache (when its
enabled).word
is null
.word
- The Word
to write.public Word readFromCache(java.lang.String word) throws java.lang.IllegalArgumentException
Word
Object from the cache.word
- The typed form of the word to read.Word
Object including all its information.java.lang.IllegalArgumentException
- When word
is not present in the cache.public boolean isInCache(java.lang.String word)
word
- The typed form of the word to check for.true
when it is present, else false
.