Interface MutableDataHolder

    • Method Detail

      • get

        @Deprecated
        default <T> T get​(@NotNull
                          DataKey<T> key)
        Deprecated.
        use key.get(dataHolder) instead, which will do the same thing an carries nullable information for the data
        Get the given key, if it does not exist then use the key's factory to create a new value and put it into the collection so that the following get of the same key will find a value
        Specified by:
        get in interface DataHolder
        Type Parameters:
        T - Type returned by key
        Parameters:
        key - data key
        Returns:
        return stored value or newly created value
      • getOrCompute

        java.lang.Object getOrCompute​(@NotNull
                                      DataKeyBase<?> key,
                                      @NotNull
                                      DataValueFactory<?> factory)
        Description copied from interface: DataHolder
        Get key if it exists or compute using supplier

        Method used by DataKey classes to access data.

        NOTE: MutableDataHolders will compute an absent key and add it to its dataSet. DataHolders will return computed value but not change contained dataSet because they are immutable. So value will be computed every time it is requested.

        Specified by:
        getOrCompute in interface DataHolder
        Parameters:
        key - data key
        factory - factory taking this data holder and computing/providing default value
        Returns:
        object value for the key
      • set

        @NotNull
        <T> MutableDataHolder set​(@NotNull
                                  DataKey<T> key,
                                  @NotNull
                                  T value)
        Store the given value for the key
        Type Parameters:
        T - data type of the data referred by the key
        Parameters:
        key - data key
        value - value to store
        Returns:
        mutable data holder for chained calls
      • set

        @NotNull
        <T> MutableDataHolder set​(@NotNull
                                  NullableDataKey<T> key,
                                  @Nullable
                                  T value)
        Store the given value for the key
        Type Parameters:
        T - data type of the data referred by the key
        Parameters:
        key - data key
        value - value to store
        Returns:
        mutable data holder for chained calls
      • remove

        @NotNull
        MutableDataHolder remove​(@NotNull
                                 DataKeyBase<?> key)
        Remove the stored value for the key, used to force to default or to force recompute
        Parameters:
        key - data key to remove
        Returns:
        mutable data holder for chained calls
      • setFrom

        @NotNull
        MutableDataHolder setFrom​(@NotNull
                                  MutableDataSetter dataSetter)
        Store the given value for the key
        Parameters:
        dataSetter - data setter which will set values
        Returns:
        mutable data holder for chained calls
      • setAll

        @NotNull
        MutableDataHolder setAll​(@NotNull
                                 DataHolder other)
        Copy all values from one data holder to this data holder
        Parameters:
        other - data holder from which to copy all values
        Returns:
        mutable data holder for chained calls
      • clear

        @NotNull
        MutableDataHolder clear()
        clear all options out of the data set
        Returns:
        mutable data holder for chained calls