Record Class PhoneNumber

java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.domain.sms.PhoneNumber
Record Components:
e164 - the number: a plus sign, then 7 to 15 digits, the first of which is not zero.

public record PhoneNumber(String e164) extends Record
A phone number in E.164 format. Only the shape is validated here; turning user input into E.164 is the job of a PhoneNormalizer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
    The field for the e164 record component.
    private static final Pattern
    Shape of an E.164 number.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Validates the number.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the e164 record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • e164

      private final String e164
      The field for the e164 record component.
    • E164

      private static final Pattern E164
      Shape of an E.164 number.
  • Constructor Details

    • PhoneNumber

      public PhoneNumber(String e164)
      Validates the number.
      Throws:
      IllegalArgumentException - if the value is missing or not in E.164 shape.
  • Method Details

    • 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
    • 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
    • equals

      public final boolean equals(Object o)
      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:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • e164

      public String e164()
      Returns the value of the e164 record component.
      Returns:
      the value of the e164 record component