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 beforegetEndTime()); - 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
- 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 booleancovers(java.time.LocalDateTime moment)Check if this access right happens in the given moment or not.java.time.OffsetDateTimegetEndTime()The moment (excluded) when the user is allowed (or not) anymore on the parking site.java.lang.StringgetParkingSiteId()The identifier of the parking site that the user is able (or not) to enter.java.time.OffsetDateTimegetStartTime()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.booleanisGranted()The status of the access right, whether the user is allowed (true) on the parking site or not (false).booleanstartsAfter(java.time.LocalDateTime moment)Check if this access right's start time is after the given moment.java.lang.StringtoString()
-
Method Details
-
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:
toStringin classjava.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:
trueif the moment given is during the access right,falseotherwise.
-
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:
trueif the given moment is after the start time,falseotherwise.
-