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

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

  • Method Details

    • assign

      public final SequencedSet<? extends Assignment<?>> assign(Function<? super Annotated<? extends AnnotatedConstruct>, ?> r)
      Specified by:
      assign in interface Aggregate
    • 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
      Throws:
      ClassCastException - if the cast is inappropriate
    • dependencies

      public final SequencedSet<? extends Annotated<? extends Element>> dependencies()
      Specified by:
      dependencies in interface Aggregate
    • 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 final 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
    • 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