Class Address

All Implemented Interfaces:
Jsonifiable, UnsafeSerializable, GsonUtils.GsonPostProcessable, Serializable, Cloneable
Direct Known Subclasses:
ContactAddress, MarkAddress, RegistrarAddress

@Embeddable @MappedSuperclass public class Address extends ImmutableObject implements Jsonifiable, UnsafeSerializable, GsonUtils.GsonPostProcessable
Container for generic street address.

This is the "addrType" type from RFC5733. It also matches the "addrType" type from Mark and Signed Mark Objects Mapping.

See Also:
  • Field Details

    • street

      @Expose protected List<String> street
      At most three lines of addresses parsed from XML elements.

      This field is used to marshal to/unmarshal from XML elements. When persisting to/from SQL, the next three separate fields are used. Those lines are only used for persistence purpose and should not be directly used in Java.

      We need to keep the list and the three fields in sync in all the following scenarios when an entity containing a Address is created:

      • When creating an Address directly in java, using the Address.Builder: The Address.Builder.setStreet(ImmutableList) sets both the list and the fields.
      • When unmarshalling from XML: The list will be set based on the content of the XML. Afterwards, afterUnmarshal(Unmarshaller, Object)} will be called to set the fields.
      • When loading from the database: The fields will be set by the values in SQL. Afterwards, postLoad() will be called to set the list.
      The syncing is especially important because when merging a detached entity into a session, JPA provides no guarantee that transient fields will be preserved. In fact, Hibernate chooses to discard them when returning a newly merged entity. This means that it is not enough to provide callbacks to populate the fields based on the list before persistence, as merging does not invoke the callbacks, and we would lose the address fields if only the list is set. Instead, the fields must be populated when the list is.

      Schema validation will enforce the 3-line limit.

    • streetLine1

      @IgnoredInDiffableMap protected String streetLine1
    • streetLine2

      @IgnoredInDiffableMap protected String streetLine2
    • streetLine3

      @IgnoredInDiffableMap protected String streetLine3
    • city

      @Expose protected String city
    • state

      @Expose protected String state
    • zip

      @Expose protected String zip
    • countryCode

      @Expose protected String countryCode
  • Constructor Details

    • Address

      public Address()
  • Method Details

    • getStreet

      public<String> getStreet()
    • getCity

      public String getCity()
    • getState

      public String getState()
    • getZip

      public String getZip()
    • getCountryCode

      public String getCountryCode()
    • toJsonMap

      public Map<String,Object> toJsonMap()
      Description copied from interface: Jsonifiable
      Returns a JSON representation of this object.

      The returned value must not return sensitive fields, so that it may be safe to return to the client via an API response.

      Specified by:
      toJsonMap in interface Jsonifiable
    • asBuilder

      public Address.Builder<? extends Address> asBuilder()
    • postProcess

      public void postProcess()
      Specified by:
      postProcess in interface GsonUtils.GsonPostProcessable