Class ImmutableHistogram

java.lang.Object
pl.poznan.put.circular.Histogram
pl.poznan.put.circular.ImmutableHistogram

@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ImmutableHistogram extends Histogram
Immutable implementation of Histogram.

Use the builder to create immutable instances: ImmutableHistogram.builder(). Use the static factory method to create immutable instances: ImmutableHistogram.of().

  • Method Details

    • data

      public Collection<Angle> data()
      Specified by:
      data in class Histogram
      Returns:
      A collection of angular data.
    • binWidth

      public double binWidth()
      Specified by:
      binWidth in class Histogram
      Returns:
      The width of bin in range [0, pi).
    • withData

      public final ImmutableHistogram withData(Collection<Angle> value)
      Copy the current immutable object by setting a value for the data attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for data
      Returns:
      A modified copy of the this object
    • withBinWidth

      public final ImmutableHistogram withBinWidth(double value)
      Copy the current immutable object by setting a value for the binWidth attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for binWidth
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableHistogram that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: data, binWidth.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value Histogram with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • bins

      protected Collection<pl.poznan.put.circular.Histogram.Bin> bins()

      Returns a lazily initialized value of the bins attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Overrides:
      bins in class Histogram
      Returns:
      A lazily initialized value of the bins attribute
    • of

      public static ImmutableHistogram of(Collection<Angle> data, double binWidth)
      Construct a new immutable Histogram instance.
      Parameters:
      data - The value for the data attribute
      binWidth - The value for the binWidth attribute
      Returns:
      An immutable Histogram instance
    • copyOf

      public static ImmutableHistogram copyOf(Histogram instance)
      Creates an immutable copy of a Histogram value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable Histogram instance
    • builder

      public static ImmutableHistogram.Builder builder()
      Creates a builder for ImmutableHistogram.
       ImmutableHistogram.builder()
          .data(Collection&lt;pl.poznan.put.circular.Angle&gt;) // required data
          .binWidth(double) // required binWidth
          .build();
       
      Returns:
      A new ImmutableHistogram builder