Class AccessRight

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

public class AccessRight
extends java.lang.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
  • Method Summary

    Modifier and Type Method Description
    boolean covers​(java.time.LocalDateTime moment)
    Check if this access right happens in the given moment or not.
    java.time.OffsetDateTime getEndTime()
    The moment (excluded) when the user is allowed (or not) anymore on the parking site.
    java.lang.String getParkingSiteId()
    The identifier of the parking site that the user is able (or not) to enter.
    java.time.OffsetDateTime getStartTime()
    The moment (included) when the user is allowed (or not) on the parking site.
    java.util.Collection<UserId> getUserIds()
    A list of known user ids known by Commuty that target the user concerning by this access right.
    boolean isGranted()
    The status of the access right, whether the user is allowed (true) on the parking site or not (false).
    boolean startsAfter​(java.time.LocalDateTime moment)
    Check if this access right's start time is after the given moment.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • getUserIds

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

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

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

      public java.time.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).
    • toString

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

      public boolean covers​(java.time.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​(java.time.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.