Package net.commuty.parking.model
Class AccessRight
java.lang.Object
net.commuty.parking.model.AccessRight
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
-
Constructor Summary
ConstructorsConstructorDescriptionAccessRight(Collection<UserId> userIds, String parkingSiteId, OffsetDateTime startTime, OffsetDateTime endTime, boolean granted, Map<AccessRightAttributeName, String> attributes) -
Method Summary
Modifier and TypeMethodDescriptionbooleancovers(LocalDateTime moment) Check if this access right happens in the given moment or not.Extra attributes of the access right.The moment (excluded) when the user is allowed (or not) anymore on the parking site.getId()The unique identifier of this access right.The identifier of the parking site that the user is able (or not) to enter.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.When an access right is granted for a specific parking spot, this value represents its unique identifier.When an access right is granted for a specific parking spot, this value represents its name as defined by the managers.TheAccessRightReasonof why this access right exists.The moment (included) when the user is allowed (or not) on the parking site.A list of known user ids known by Commuty that target the user concerning by this access right.booleanThe status of the access right, whether the user is allowed (true) on the parking site or not (false).truewhen this access right is granted for a visitor.booleanstartsAfter(LocalDateTime moment) Check if this access right's start time is after the given moment.toString()
-
Constructor Details
-
AccessRight
public AccessRight(Collection<UserId> userIds, String parkingSiteId, OffsetDateTime startTime, OffsetDateTime endTime, boolean granted, Map<AccessRightAttributeName, String> attributes)
-
-
Method Details
-
getUserIds
A list of known user ids known by Commuty that target the user concerning by this access right. -
getParkingSiteId
The identifier of the parking site that the user is able (or not) to enter. -
getStartTime
The moment (included) when the user is allowed (or not) on the parking site. -
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
Extra attributes of the access right. It is present only whenincludeAttributescontains at least oneAccessRightAttributeNamewhen fetching access rights.
Otherwise, this list is empty. -
getId
The unique identifier of this access right. Only present when the extra attributes are fetched, via theincludeAttributesparameter.
Otherwise, this isnull. -
getReason
TheAccessRightReasonof why this access right exists. Only present when the extra attributes are fetched, via theincludeAttributesparameter.
Otherwise, this isnull. -
getParkingSpotId
When an access right is granted for a specific parking spot, this value represents its unique identifier. It is null otherwise. -
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
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
truewhen this access right is granted for a visitor.falseotherwise. The boolean value isnullwhen this attribute is not requested. -
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
- 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
-
covers
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
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.
-