intellij-randomness / com.fwdekker.randomness.word / DictionaryReference

DictionaryReference

data class DictionaryReference : Dictionary

References a dictionary by its properties.

Using a reference, each access goes through the cache first, so that outdated instances of a dictionary (i.e. those flushed when clearing the cache) are not used anymore. This ensures that only the latest instance of that dictionary is used, which is important when a dictionary has to be used both before and after clearing a cache.

Constructors

<init>

DictionaryReference(isBundled: Boolean, filename: String)

References a dictionary by its properties.

Properties

filename

var filename: String

The filename of the referred-to dictionary.

isBundled

val isBundled: Boolean

True if this dictionary refers to a BundledDictionary.

referent

val referent: Dictionary

The dictionary that is referred to by this reference, as fetched from the cache.

words

val words: Set<String>

The words in the dictionary.

Functions

toString

fun toString(): String

validate

fun validate(): Unit

Throws an InvalidDictionaryException iff this dictionary is currently invalid.

Inherited Functions

isValid

open fun isValid(): Boolean

Returns true iff validate does not throw an exception.

Companion Object Properties

DICTIONARY_CAST_EXCEPTION

const val DICTIONARY_CAST_EXCEPTION: String

The error message that is displayed if an unknown dictionary implementation is used.

Companion Object Functions

to

fun to(dictionary: Dictionary): DictionaryReference

Returns a reference to the given dictionary.