Interface HasMultipleValues<T>
- Type Parameters:
T
- the type of elements.
- All Superinterfaces:
HasConfigurableValue
,SupportsConvention
- All Known Subinterfaces:
ListProperty<T>
,SetProperty<T>
HasMultipleValues
, such as a collection property.
Note: This interface is not intended for implementation by build script or plugin authors. You can use the factory methods on ObjectFactory
to create various subtypes of this interface.
- Since:
- 4.5
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an element to the property value.void
Adds an element to the property value.void
Adds zero or more elements to the property value.void
Adds zero or more elements to the property value.void
Adds zero or more elements to the property value.convention
(Iterable<? extends T> elements) Specifies the value to use as the convention for this property.convention
(Provider<? extends Iterable<? extends T>> provider) Specifies the provider of the value to use as the convention for this property.empty()
Sets the value of this property to an empty collection, and replaces any existing value.void
Disallows further changes to the value of this property.void
Sets the value of the property to the elements of the given iterable, and replaces any existing value.void
Sets the property to have the same value of the given provider, and replaces any existing value.Sets the value of the property to the elements of the given iterable, 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
Methods inherited from interface org.gradle.api.provider.SupportsConvention
unset, unsetConvention
-
Method Details
-
set
Sets the value of the property to the elements of the given iterable, and replaces any existing value. This property will query the elements of the iterable 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:
elements
- The elements, can be null.
-
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 elements.
-
value
Sets the value of the property to the elements of the given iterable, and replaces any existing value. This property will query the elements of the iterable each time the value of this property is queried.This is the same as
set(Iterable)
but returns this property to allow method chaining.- Parameters:
elements
- The elements, can be null.- 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 elements.- Returns:
- this
- Since:
- 5.6
-
empty
HasMultipleValues<T> empty()Sets the value of this property to an empty collection, and replaces any existing value.- Returns:
- this property.
- Since:
- 5.0
-
add
Adds an element to the property value.- Parameters:
element
- The element
-
add
Adds an element 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 an element
-
addAll
Adds zero or more elements to the property value.- Parameters:
elements
- The elements to add- Since:
- 4.10
-
addAll
Adds zero or more elements to the property value.The given iterable will be queried when the value of this property is queried.
- Parameters:
elements
- The elements to add.- Since:
- 4.10
-
addAll
Adds zero or more elements 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
- Provider of elements
-
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:
elements
- The elements, ornull
when the convention is that the property has no value.- Returns:
- this
- Since:
- 5.1
-
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:
provider
- The provider of the elements- Returns:
- this
- Since:
- 5.1
-
finalizeValue
void finalizeValue()Disallows further changes to the value of this property. Calls to methods that change the value of this property, such asset(Iterable)
oradd(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.
- Specified by:
finalizeValue
in interfaceHasConfigurableValue
- Since:
- 5.0
-