Class AccessRight

java.lang.Object
net.commuty.parking.model.AccessRight

public class AccessRight extends Object
This holds the access right:
  • for a user identified by one or more of its ids;
  • for a specific parking site;
  • for a period of time (starting from getStartTime() until before getEndTime());
  • whether is access is allowed or not.

An access right will never overlap two days, meaning that it will always start on or after midnight and end on or before midnight the next day.

It is possible for a user to have multiple access rights on a parking site for a day.

In this case, the periods (from start time until end time) will also never overlap. Moreover, all the periods will cover a complete day.

For instance:

A user that is not granted today will:
  • have one granted right starting from today midnight until tomorrow midnight
A user that is granted today from 08:00 until 16:00 will:
  • have one not granted right starting from today midnight until today 08:00
  • have one granted right starting from today 08:00 until today 16:00
  • have one not granted right starting from today 16:00 until tomorrow midnight
  • Constructor Details

  • Method Details

    • getUserIds

      public Collection<UserId> getUserIds()
      A list of known user ids known by Commuty that target the user concerning by this access right.
    • getParkingSiteId

      public String getParkingSiteId()
      The identifier of the parking site that the user is able (or not) to enter.
    • getStartTime

      public OffsetDateTime getStartTime()
      The moment (included) when the user is allowed (or not) on the parking site.
    • getEndTime

      public OffsetDateTime getEndTime()
      The moment (excluded) when the user is allowed (or not) anymore on the parking site.
    • isGranted

      public boolean isGranted()
      The status of the access right, whether the user is allowed (true) on the parking site or not (false).
    • getAttributes

      public Map<AccessRightAttributeName,String> getAttributes()
      Extra attributes of the access right. It is present only when includeAttributes contains at least one AccessRightAttributeName when fetching access rights.
      Otherwise, this list is empty.
    • getId

      public UUID getId()
      The unique identifier of this access right. Only present when the extra attributes are fetched, via the includeAttributes parameter.
      Otherwise, this is null.
    • getReason

      public AccessRightReason getReason()
      The AccessRightReason of why this access right exists. Only present when the extra attributes are fetched, via the includeAttributes parameter.
      Otherwise, this is null.
    • getParkingSpotId

      public UUID getParkingSpotId()
      When an access right is granted for a specific parking spot, this value represents its unique identifier. It is null otherwise.
    • getParkingSpotName

      public String getParkingSpotName()
      When an access right is granted for a specific parking spot, this value represents its name as defined by the managers. It is null otherwise.
    • getParkingSpotDisplayName

      public String getParkingSpotDisplayName()
      When an access right is granted for a specific parking spot, this value represents its display name as it is shown to the end-users. It is null otherwise.
    • isVisitor

      public Boolean isVisitor()
      true when this access right is granted for a visitor. false otherwise. The boolean value is null when this attribute is not requested.
    • getSubjectId

      public UUID getSubjectId()
      Returns:
      A unique identifier identifying the actual "subject" whose the access right belongs to. This can be the ID of a user, a visitor or an access exception.
    • getSubjectLabel

      public String getSubjectLabel()
      Returns:
      A label describing the "subject" whose the access right belongs to. This is usually the full name of a user, a visitor or an access exception.
    • toString

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

      public boolean covers(LocalDateTime moment)
      Check if this access right happens in the given moment or not.
      Parameters:
      moment - The moment to check.
      Returns:
      true if the moment given is during the access right, false otherwise.
    • startsAfter

      public boolean startsAfter(LocalDateTime moment)
      Check if this access right's start time is after the given moment.
      Parameters:
      moment - The moment to check.
      Returns:
      true if the given moment is after the start time, false otherwise.