Class ImmutableContact

java.lang.Object
io.github.ai4ci.abm.ImmutableContact
All Implemented Interfaces:
Contact, Serializable

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

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

See Also:
  • Method Details

    • isDetected

      public boolean isDetected()
      Was a contact detected by a smart agent
      Specified by:
      isDetected in interface Contact
    • getParticipant1Id

      public int getParticipant1Id()
      Specified by:
      getParticipant1Id in interface Contact
      Returns:
      The value of the participant1Id attribute
    • getParticipant2Id

      public int getParticipant2Id()
      Specified by:
      getParticipant2Id in interface Contact
      Returns:
      The value of the participant2Id attribute
    • withDetected

      public final ImmutableContact withDetected(boolean value)
      Copy the current immutable object by setting a value for the detected attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for detected
      Returns:
      A modified copy of the this object
    • withParticipant1Id

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

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

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

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

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

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

      public static ImmutableContact.Builder builder()
      Creates a builder for ImmutableContact.
       ImmutableContact.builder()
          .setDetected(boolean) // required detected
          .setParticipant1Id(int) // required participant1Id
          .setParticipant2Id(int) // required participant2Id
          .build();
       
      Returns:
      A new ImmutableContact builder