Class BasicSolarNodeOwnership

java.lang.Object
net.solarnetwork.central.domain.BasicSolarNodeOwnership
All Implemented Interfaces:
Serializable, SolarNodeOwnership, net.solarnetwork.domain.Differentiable<SolarNodeOwnership>

public class BasicSolarNodeOwnership extends Object implements Serializable, SolarNodeOwnership, net.solarnetwork.domain.Differentiable<SolarNodeOwnership>
Basic implementation of SolarNodeOwnership.
See Also:
  • Constructor Details

    • BasicSolarNodeOwnership

      public BasicSolarNodeOwnership(Long nodeId, Long userId, String country, ZoneId zone, boolean requiresAuthorization, boolean archived)
      Constructor.
      Parameters:
      nodeId - the node ID
      userId - the owner user ID
      country - the country code
      zone - the zone, or null to use UTC
      requiresAuthorization - true if authorization is required to access the node's data
      archived - true if the node has been archived
      Throws:
      IllegalArgumentException - if nodeId or userId is null
  • Method Details

    • ownershipFor

      public static BasicSolarNodeOwnership ownershipFor(Long nodeId, Long userId)
      Create a new ownership instance.

      The zone will be set to UTC. The requiresAuthorization and archived properties will be set to false.

      Parameters:
      nodeId - the node ID
      userId - the user ID
      Returns:
      the new ownership
      Throws:
      IllegalArgumentException - if nodeId or userId is null
    • ownershipFor

      public static BasicSolarNodeOwnership ownershipFor(Long nodeId, Long userId, String country, String timeZoneId)
      Create a new private ownership instance.

      The requiresAuthorization property will be set to true. The archived property will be set to false.

      Parameters:
      nodeId - the node ID
      userId - the user ID
      country - the country
      timeZoneId - the time zone ID
      Returns:
      the new ownership
      Throws:
      IllegalArgumentException - if nodeId or userId is null
    • privateOwnershipFor

      public static BasicSolarNodeOwnership privateOwnershipFor(Long nodeId, Long userId)
      Create a new private ownership instance.

      The zone will be set to UTC. The requiresAuthorization property will be set to true. The archived property will be set to false.

      Parameters:
      nodeId - the node ID
      userId - the user ID
      Returns:
      the new ownership
      Throws:
      IllegalArgumentException - if nodeId or userId is null
    • privateOwnershipFor

      public static BasicSolarNodeOwnership privateOwnershipFor(Long nodeId, Long userId, String country, String timeZoneId)
      Create a new private ownership instance.

      The requiresAuthorization property will be set to true. The archived property will be set to false.

      Parameters:
      nodeId - the node ID
      userId - the user ID
      country - the country
      timeZoneId - the time zone ID
      Returns:
      the new ownership
      Throws:
      IllegalArgumentException - if nodeId or userId is null
    • isSameAs

      public boolean isSameAs(SolarNodeOwnership other)
      Test if the properties of another object are the same as in this instance.
      Parameters:
      other - the other entity to compare to
      Returns:
      true if the properties of this instance are equal to the other
    • differsFrom

      public boolean differsFrom(SolarNodeOwnership other)
      Specified by:
      differsFrom in interface net.solarnetwork.domain.Differentiable<SolarNodeOwnership>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Compare node ownership.

      This compares only by node ID.

      Overrides:
      equals in class Object
    • getNodeId

      public Long getNodeId()
      Description copied from interface: SolarNodeOwnership
      Get the node ID.
      Specified by:
      getNodeId in interface SolarNodeOwnership
      Returns:
      the node ID
    • getUserId

      public Long getUserId()
      Description copied from interface: SolarNodeOwnership
      Get the user ID of the owner of a node.
      Specified by:
      getUserId in interface SolarNodeOwnership
      Returns:
      the owner user ID
    • getCountry

      public String getCountry()
      Description copied from interface: SolarNodeOwnership
      Get the ISO 3166-1 alpha-2 character country code.
      Specified by:
      getCountry in interface SolarNodeOwnership
      Returns:
      2-character country code
    • getZone

      public ZoneId getZone()
      Description copied from interface: SolarNodeOwnership
      Get the node's time zone.
      Specified by:
      getZone in interface SolarNodeOwnership
      Returns:
      the time zone
    • isRequiresAuthorization

      public boolean isRequiresAuthorization()
      Description copied from interface: SolarNodeOwnership
      Flag indicating if a node's data is "public" vs "private".
      Specified by:
      isRequiresAuthorization in interface SolarNodeOwnership
      Returns:
      true if the node requires authorization for viewing its data
    • isArchived

      public boolean isArchived()
      Description copied from interface: SolarNodeOwnership
      Flag indicating if a node has been "archived".
      Specified by:
      isArchived in interface SolarNodeOwnership
      Returns:
      true if the node has been archived