Class ImmutableKernel

java.lang.Object
io.github.ai4ci.abm.riskmodel.ImmutableKernel
All Implemented Interfaces:
Kernel, Serializable

@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableKernel extends Object implements Kernel
Immutable implementation of Kernel.

Use the builder to create immutable instances: ImmutableKernel.builder().

See Also:
  • Method Details

    • getDensity

      public double[] getDensity()
      Kernel values, offset as required, compared to a convolution this is in reverse order. The first value in this array is applied to the most recent data point, which may be in the future (prospective).
      Specified by:
      getDensity in interface Kernel
    • getOffset

      public int getOffset()
      index of zero point in values. positive values mean that the kernel is 2 sided. zero means only left sided. negatives don't make particular sense but should work consistently
      Specified by:
      getOffset in interface Kernel
    • withDensity

      public final ImmutableKernel withDensity(double... elements)
      Copy the current immutable object with elements that replace the content of density. The array is cloned before being saved as attribute values.
      Parameters:
      elements - The non-null elements for density
      Returns:
      A modified copy of this object
    • withOffset

      public final ImmutableKernel withOffset(int value)
      Copy the current immutable object by setting a value for the offset attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for offset
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableKernel 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: density, offset.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static ImmutableKernel copyOf(Kernel instance)
      Creates an immutable copy of a Kernel 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 Kernel instance
    • toBuilder

      public ImmutableKernel.Builder toBuilder()
      Creates a builder for ImmutableKernel.prefilled with attibute values of this instance to easily create modified copies.
      Returns:
      A new ImmutableKernel builder with attributes of this instance
    • builder

      public static ImmutableKernel.Builder builder()
      Creates a builder for ImmutableKernel.
       ImmutableKernel.builder()
          .setDensity(double) // required density
          .setOffset(int) // required offset
          .build();
       
      Returns:
      A new ImmutableKernel builder