Record Class Bean<I>

java.lang.Object
java.lang.Record
org.microbean.bean.Bean<I>
Type Parameters:
I - the type of the contextual instances the associated Factory creates
Record Components:
id - the Id; must not be null
factory - the Factory; must not be null
All Implemented Interfaces:
Constable, Aggregate, Ranked

public record Bean<I>(Id id, Factory<I> factory) extends Record implements Aggregate, Constable, Ranked
A (Constable) pairing of an Id with a Factory.
Author:
Laird Nelson
See Also:
  • Constructor Details

  • Method Details

    • alternate

      public final boolean alternate()
      Description copied from interface: Ranked
      Returns true if this Ranked is to be considered an alternate, which may have an effect on how the return value of the Ranked.rank() method is interpreted in some situations.

      The default implementation of this method returns false.

      Overrides of this method must be idempotent and return a determinate value.

      Specified by:
      alternate in interface Ranked
      Returns:
      true if this Ranked is to be considered an alternate
    • cast

      public final <X> Bean<X> cast()
      Returns this Bean, forcibly cast appropriately.
      Type Parameters:
      X - the type of contextual instances this Bean creates
      Returns:
      this Bean
    • dependencies

      Description copied from interface: Aggregate
      Returns an unmodifiable SequencedSet of AttributedElement instances.
      Specified by:
      dependencies in interface Aggregate
      Returns:
      an unmodifiable SequencedSet of AttributedElement instances; never null
      See Also:
    • describeConstable

      Specified by:
      describeConstable in interface Constable
    • equals

      public final boolean equals(Object other)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      other - the object with which to compare
      Returns:
      true if this object is the same as the other argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • rank

      public final int rank()
      Description copied from interface: Ranked
      Returns the rank of this Ranked implementation.

      Implementations of this method may return any integer: positive, zero, or negative.

      The default implementation of this method returns the value of the Ranked.DEFAULT_RANK field (0).

      Overrides of this method must return a determinate value.

      Specified by:
      rank in interface Ranked
      Returns:
      the rank of this Ranked implementation
      See Also:
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • id

      public Id id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • factory

      public Factory<I> factory()
      Returns the value of the factory record component.
      Returns:
      the value of the factory record component