K
- key typeV
- value typepublic static class Variant.MapVariant<K,V> extends Variant<Map<K,V>> implements Iterable<Map.Entry<K,Variant<V>>>
isProperty
Variant.ClosureResultOrigin, Variant.ClosureVariant, Variant.CollectionVariant<T extends Collection<V>,V>, Variant.DereferenceOrigin, Variant.ListVariant<V>, Variant.MapVariant<K,V>, Variant.MethodResultOrigin, Variant.Origin, Variant.PropertyOrigin, Variant.RecordOrigin, Variant.RecordVariant, Variant.ReferenceOrigin, Variant.ScopedClosureVariant
context, definitionType, NULL, origin
Constructor and Description |
---|
MapVariant(Map<K,V> data,
Type valueType,
Variant.Origin origin,
Class<K> keyClass,
Class<V> valueClass,
LspsContextHolder context)
Creates the variant.
|
Modifier and Type | Method and Description |
---|---|
Variant.MapVariant<K,V> |
checkPresent()
Fails if the value is absent.
|
boolean |
containsKey(K key)
Checks whether given key is present in the map.
|
Variant<V> |
get(K key)
Returns the value from the map as a Variant.
|
boolean |
isNullOrEmpty() |
Iterator<Map.Entry<K,Variant<V>>> |
iterator()
Unmodifiable iterator.
|
Variant.MapVariant<K,V> |
orEmpty()
Returns variant which is always present.
|
Variant.MapVariant<K,V> |
orVariant(Map<K,V> defaultValue)
Returns this instance if it is present; a new variant with the defaultValue otherwise.
|
int |
size()
Returns the list size.
|
Variant.MapVariant<K,V> |
toNull()
Creates a new variant of same type and origin, but with null map.
|
Variant.MapVariant<K,V> |
toValue(Map<K,V> newValue)
Creates a new variant of same type and origin, but with given value.
|
bool, cast, closure, collection, collectionOf, date, decimal, definitionOf, definitionOf, dereference, enumerationConstant, enumValueOf, enumValueOfIgnoreCase, equals, fail, fail, get, getHandle, getInstanceType, getOrigin, hasHandle, hashCode, instanceOf, integer, isAbsent, isClosure, isPath, isPresent, isProperty, isPropertyPath, isRecord, list, listHolder, listOf, map, mapHolder, mapOf, ofOrigin, ofUnknownOrigin, ofUnknownOrigin, or, param, path, property, propertyPath, record, reference, requireDefined, set, setHolder, setOf, setReferencedValue, setReferencedValueCollection, startTransaction, string, toString, toUpperCase, valueOrNull, wrap
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public MapVariant(Map<K,V> data, Type valueType, Variant.Origin origin, Class<K> keyClass, Class<V> valueClass, LspsContextHolder context)
data
- the value, may be null.valueType
- The type of the value, either the record property type, or the closure result type. null: see Variant.requireDefined()
.origin
- The value origin, such as "ui::Geolocation.latitude".keyClass
- valueClass
- context
- public int size()
public Variant<V> get(K key)
key
- the key.public Variant.MapVariant<K,V> toNull()
public Variant.MapVariant<K,V> toValue(Map<K,V> newValue)
public Iterator<Map.Entry<K,Variant<V>>> iterator()
public boolean containsKey(K key)
key
- the key, may be null.public Variant.MapVariant<K,V> checkPresent()
Variant
checkPresent
in class Variant<Map<K,V>>
public Variant.MapVariant<K,V> orVariant(Map<K,V> defaultValue)
Variant
Variant.get()
instead.
For a default value of null, use Variant.valueOrNull()
.public Variant.MapVariant<K,V> orEmpty()
public boolean isNullOrEmpty()
true
if there is no contained value or if the contained map is empty.Copyright © 2007-2018 Whitestein Technologies. All Rights Reserved.