Interface HasConfigurableValue

All Known Subinterfaces:
ConfigurableFileCollection, DirectoryProperty, FileSystemLocationProperty<T>, HasMultipleValues<T>, ListProperty<T>, MapProperty<K,V>, Property<T>, RegularFileProperty, SetProperty<T>

@Incubating public interface HasConfigurableValue
Represents an object that holds a value that is configurable, meaning that the value or some source for the value, such as a Provider, can be specified directly on the object.

This interface provides methods to manage the lifecycle of the value. Using these methods, the value of the object can be finalized, which means that the value will no longer change. Note that this is not the same as an immutable value. You can think of a finalized value as similar to a final variable in Java. While the value does not change, the value itself may still be mutable.

When a task property has a value of this type, it will be implicitly finalized when the task starts execution, to prevent accidental changes to the task parameters as the task runs.

Note: This interface is not intended for implementation by build script or plugin authors.

Since:
5.6
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Disallows further direct changes to this object.
    void
    Calculates the final value of this object and disallows further changes to this object.
  • Method Details

    • finalizeValue

      void finalizeValue()
      Calculates the final value of this object and disallows further changes to this object.

      To calculate the final value of this object, any source for the value is queried and the result used as the final value for this object. The source is discarded.

      Subsequent attempts to change the value of this object or the source from which the value is derived will fail with an exception.

      Note that although the value of this object will no longer change, the value may itself be mutable. Calling this method does not guarantee that the value will become immutable, though some implementations may support this.

    • disallowChanges

      void disallowChanges()
      Disallows further direct changes to this object.

      This differs from finalizeValue() in that it does not calculate the final value of this object, and so any source for the value will continue to be used until the value is finalized.