K
- Key typeV
- Value typepublic final class KeyValueTable<K,V> extends DatabaseAccessor
execute()
method or
on first call of any data-retrieving methodget(Object)
method call Constructor and Description |
---|
KeyValueTable(java.lang.String name,
Database database,
java.lang.String tableName,
java.lang.String keyColumn,
java.lang.String valueColumn)
Creates
KeyValueTable based on the table with given
tableName |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(java.lang.Object key)
Returns
true if this KeyValueTable contains a mapping
for the specified key. |
boolean |
containsValue(java.lang.Object value)
Returns
true if this KeyValueTable maps one or more
keys to the specified value. |
void |
execute()
Loads (reloads) Key-Value mappings from database table
This method is automatically invoked if data is not loaded on first data-retrieving method call |
V |
get(K key)
Returns the value to which the specified key is mapped, or
null
if this KeyValueTable contains no mapping for the key. |
boolean |
isEmpty()
Returns
true if this KeyValueTable contains no
key-value mappings. |
java.util.Set<K> |
keySet()
Returns a
Set view of the keys contained in this table. |
int |
size()
Returns the number of key-value mappings in this
KeyValueTable . |
java.util.Collection<V> |
values()
Returns a
Collection view of the values contained in this
KeyValueTable . |
destroy, getName, toString
public KeyValueTable(java.lang.String name, Database database, java.lang.String tableName, java.lang.String keyColumn, java.lang.String valueColumn)
KeyValueTable
based on the table with given
tableName
name
- object name (decoration purpose)database
- database to connect totableName
- name of table with Key-Value mappingskeyColumn
- Key column name in the tablevalueColumn
- Value column name in the tablepublic void execute()
public V get(K key)
null
if this KeyValueTable
contains no mapping for the key.
More formally, if this KeyValueTable
contains a mapping from a
key k
to a value v
such that
(key==null ? k==null : key.equals(k))
, then this method returns
v
; otherwise it returns null
. (There can be at most one
such mapping.)
A return value of null
does not necessarily indicate that
the KeyValueTable
contains no mapping for the key; it's also
possible that the KeyValueTable
explicitly maps the key to
null
. The containsKey
operation may be used
to distinguish these two cases.
key
- the key whose associated value is to be returnednull
if this KeyValueTable
contains no mapping for the keypublic java.util.Set<K> keySet()
Set
view of the keys contained in this table. The set
is unmodifiable.KeyValueTable
public boolean containsKey(java.lang.Object key)
true
if this KeyValueTable
contains a mapping
for the specified key. More formally, returns true
if and only
if this KeyValueTable
contains a mapping for a key k
such that (key==null ? k==null : key.equals(k))
. (There can
be at most one such mapping.)key
- key whose presence in this KeyValueTable
is to be
testedtrue
if this KeyValueTable
contains a mapping
for the specified keypublic boolean containsValue(java.lang.Object value)
true
if this KeyValueTable
maps one or more
keys to the specified value. More formally, returns true
if
and only if this KeyValueTable
contains at least one mapping to a
value v
such that
(value==null ? v==null : value.equals(v))
. This operation
will require time linear in the KeyValueTable
size.value
- value whose presence in this KeyValueTable
is to be
testedtrue
if this KeyValueTable
maps one or more
keys to the specified valuepublic boolean isEmpty()
true
if this KeyValueTable
contains no
key-value mappings.true
if this KeyValueTable
contains no
key-value mappingspublic int size()
KeyValueTable
.
If the KeyValueTable
contains more than
Integer.MAX_VALUE
elements, returns Integer.MAX_VALUE
.KeyValueTable
public java.util.Collection<V> values()
Collection
view of the values contained in this
KeyValueTable
. The collection is unmodifiable.KeyValueTable
Copyright © AnyLogic North America, LLC. All Rights Reserved.