Interface MapProperty<K,V>
- Type Parameters:
K
- the type of keys.V
- the type of values.
- All Superinterfaces:
HasConfigurableValue
,Provider<Map<K,
,V>> SupportsConvention
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.
- Since:
- 5.1
-
Method Summary
Modifier and TypeMethodDescriptionconvention
(Map<? extends K, ? extends V> value) Specifies the value to use as the convention for this property.convention
(Provider<? extends Map<? extends K, ? extends V>> valueProvider) Specifies the provider of the value to use as the convention for this property.empty()
Sets the value of this property to an empty map, and replaces any existing value.void
Disallows further changes to the value of this property.Returns a provider that resolves to the value of the mapping of the given key.keySet()
Returns aProvider
that returns the set of keys for the map that is the property value.void
Adds a map entry to the property value.void
Adds a map entry to the property value.void
Adds all entries from anotherMap
to the property value.void
Adds all entries from anotherMap
to the property value.void
Sets the value of this property to the entries of the given Map, and replaces any existing value.void
Sets the property to have the same value of the given provider, and replaces any existing value.unset()
Unsets this object's explicit value, allowing the convention to be selected when evaluating this object's value.Unsets this object's convention value.Sets the value of this property to the entries of the given Map, and replaces any existing value.Sets the property to have the same value of the given provider, and replaces any existing value.Methods inherited from interface org.gradle.api.provider.HasConfigurableValue
disallowChanges, disallowUnsafeRead, finalizeValueOnRead
-
Method Details
-
empty
MapProperty<K,V> empty()Sets the value of this property to an empty map, and replaces any existing value.- Returns:
- this property.
-
getting
Returns a provider that resolves to the value of the mapping of the given key. It will have no value if the property has no value, or if it does not contain a mapping for the key.The returned provider will track the value of this property and query its value when it is queried.
This method is equivalent to
but possibly more efficient.map(m -> m.get(key))
- Parameters:
key
- the key- Returns:
- a
Provider
for the value
-
set
Sets the value of this property to the entries of the given Map, and replaces any existing value. This property will query the entries of the map each time the value of this property is queried.This method can also be used to discard the value of the property, by passing
null
as the value. The convention for this property, if any, will be used to provide the value instead.- Parameters:
entries
- the entries, can benull
-
set
Sets the property to have the same value of the given provider, and replaces any existing value. This property will track the value of the provider and query its value each time the value of this property is queried. When the provider has no value, this property will also have no value.- Parameters:
provider
- Provider of the entries.
-
value
Sets the value of this property to the entries of the given Map, and replaces any existing value. This property will query the entries of the map each time the value of this property is queried.This is the same as
set(Map)
but returns this property to allow method chaining.- Parameters:
entries
- the entries, can benull
- Returns:
- this
- Since:
- 5.6
-
value
Sets the property to have the same value of the given provider, and replaces any existing value. This property will track the value of the provider and query its value each time the value of this property is queried. When the provider has no value, this property will also have no value.This is the same as
set(Provider)
but returns this property to allow method chaining.- Parameters:
provider
- Provider of the entries.- Since:
- 5.6
-
put
Adds a map entry to the property value.- Parameters:
key
- the keyvalue
- the value
-
put
Adds a map entry 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.
- Parameters:
key
- the keyproviderOfValue
- the provider of the value
-
putAll
Adds all entries from anotherMap
to the property value.- Parameters:
entries
- aMap
containing the entries to add
-
putAll
Adds all entries from anotherMap
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.
- Parameters:
provider
- the provider of the entries
-
keySet
Returns aProvider
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
but possibly more efficient.map(m -> m.keySet())
- Returns:
- a
Provider
that provides the set of keys for the map
-
convention
Specifies the value to use as the convention for this property. The convention is used when no value has been set for this property.- Parameters:
value
- The value, ornull
when the convention is that the property has no value.- Returns:
- this
-
convention
Specifies the provider of the value to use as the convention for this property. The convention is used when no value has been set for this property.- Parameters:
valueProvider
- The provider of the value.- Returns:
- this
-
unset
Unsets this object's explicit value, allowing the convention to be selected when evaluating this object's value.This is similar to calling
value(Map)
with anull
argument.- Specified by:
unset
in interfaceSupportsConvention
-
unsetConvention
Unsets this object's convention value.This is similar to calling
convention(Map)
with anull
argument.- Specified by:
unsetConvention
in interfaceSupportsConvention
-
finalizeValue
void finalizeValue()Disallows further changes to the value of this property. Calls to methods that change the value of this property, such asset(Map)
orput(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 map may contain mutable objects. Calling this method does not guarantee that the value will become immutable.
- Specified by:
finalizeValue
in interfaceHasConfigurableValue
-