K
- the type of keys.V
- the type of values.@Incubating public interface MapProperty<K,V> extends Provider<Map<K,V>>
Map
of keys of type MapProperty
and values of type MapProperty
. Retains iteration order.
You can create a MapProperty
instance using factory method ObjectFactory.mapProperty(Class, Class)
.
Note: This interface is not intended for implementation by build script or plugin authors.
Modifier and Type | Method | Description |
---|---|---|
MapProperty<K,V> |
convention(Map<? extends K,? extends V> value) |
Specifies the value to use as the convention for this property.
|
MapProperty<K,V> |
convention(Provider<? extends Map<? extends K,? extends V>> valueProvider) |
Specifies the provider of the value to use as the convention for this property.
|
MapProperty<K,V> |
empty() |
Sets the value of this property to an empty map, and replaces any existing value.
|
void |
finalizeValue() |
Disallows further changes to the value of this property.
|
Provider<V> |
getting(K key) |
Returns a provider that resolves to the value of the mapping of the given key.
|
Provider<Set<K>> |
keySet() |
Returns a
Provider that returns the set of keys for the map that is the property value. |
void |
put(K key,
Provider<? extends V> providerOfValue) |
Adds a map entry to the property value.
|
void |
put(K key,
V value) |
Adds a map entry to the property value.
|
void |
putAll(Map<? extends K,? extends V> entries) |
Adds all entries from another
Map to the property value. |
void |
putAll(Provider<? extends Map<? extends K,? extends V>> provider) |
Adds all entries from another
Map to the property value. |
void |
set(Map<? extends K,? extends V> entries) |
Sets the value of this property to the entries of the given Map, and replaces any existing value.
|
void |
set(Provider<? extends Map<? extends K,? extends V>> provider) |
Sets the property to have the same value of the given provider, and replaces any existing value.
|
MapProperty<K,V> empty()
Provider<V> getting(K key)
The returned provider will track the value of this property and query its value when it is queried.
This method is equivalent to
map(m -> m.get(key))
but possibly more efficient.key
- the keyProvider
for the valuevoid set(@Nullable Map<? extends K,? extends V> entries)
This method can also be used to clear the value of the property, by passing null
as the value.
entries
- the entries, can be null
void set(Provider<? extends Map<? extends K,? extends V>> provider)
provider
- Provider of the entries.void put(K key, V value)
key
- the keyvalue
- the valuevoid put(K key, Provider<? extends V> providerOfValue)
The given provider will be queried when the value of this property is queried. This property will have no value when the given provider has no value.
key
- the keyproviderOfValue
- the provider of the valuevoid putAll(Map<? extends K,? extends V> entries)
Map
to the property value.entries
- a Map
containing the entries to addvoid putAll(Provider<? extends Map<? extends K,? extends V>> provider)
Map
to the property value.
The given provider will be queried when the value of this property is queried. This property will have no value when the given provider has no value.
provider
- the provider of the entriesProvider<Set<K>> keySet()
Provider
that returns the set of keys for the map that is the property value.
The returned provider will track the value of this property and query its value when it is queried.
This method is equivalent to
map(m -> m.keySet())
but possibly more efficient.Provider
that provides the set of keys for the mapMapProperty<K,V> convention(Map<? extends K,? extends V> value)
value
- The value.MapProperty<K,V> convention(Provider<? extends Map<? extends K,? extends V>> valueProvider)
valueProvider
- The provider of the value.void finalizeValue()
set(Map)
or put(Object, Object)
will fail.
When this property has elements provided by a Provider
, the value of the provider is queried when this method is called and the value of the provider will no longer be tracked.
Note that although the value of the property will not change, the resulting collection may contain mutable objects. Calling this method does not guarantee that the value will become immutable.