Package de.licenseapi.entities
Class License
- java.lang.Object
-
- de.licenseapi.entities.License
-
public class License extends Object
-
-
Constructor Summary
Constructors Constructor Description License(LicenseStatus status, String licenseKey, ArrayList<String> groups, ArrayList<String> permissions, ArrayList<LicenseMeta> meta, int maxUses, int currentUses, Date expirationDate)
Creates a new license object with the given parameters
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getCurrentUses()
Gets the current amount of uses of the licenseDate
getExpirationDate()
Gets the expiration date of the license.ArrayList<String>
getGroups()
Gets all groups of the licenseString
getLicenseKey()
Gets the current license key.int
getMaxUses()
Gets the maximum amount of uses of the license.ArrayList<LicenseMeta>
getMeta()
Gets all meta information of the licenseString
getMeta(String key)
Gets a specific meta information of the license.ArrayList<String>
getPermissions()
Gets all permissions of the licenseLicenseStatus
getStatus()
Gets the status of the licenseboolean
hasGroup(String group)
Checks if the license has a specific groupboolean
hasPermission(String permission)
Checks if the license has a specific permissionboolean
isExpired()
Checks if the license has expiredboolean
isMaxUsesReached()
Checks if the license has reached the maximum amount of uses (if the maximum amount of uses is set)boolean
isValid()
Checks if the license is valid
-
-
-
Constructor Detail
-
License
public License(LicenseStatus status, String licenseKey, ArrayList<String> groups, ArrayList<String> permissions, ArrayList<LicenseMeta> meta, int maxUses, int currentUses, Date expirationDate)
Creates a new license object with the given parameters- Parameters:
status
- The status of the licenselicenseKey
- The license keygroups
- The groups of the licensepermissions
- The permissions of the licensemeta
- The meta information of the licensemaxUses
- The maximum amount of uses of the licensecurrentUses
- The current amount of uses of the licenseexpirationDate
- The expiration date of the license
-
-
Method Detail
-
getStatus
public LicenseStatus getStatus()
Gets the status of the licenseThe status can be one of the following:
- Returns:
- the status of the license
-
isValid
public boolean isValid()
Checks if the license is valid- Returns:
true
if the license is valid andfalse
if not
-
isExpired
public boolean isExpired()
Checks if the license has expired- Returns:
true
if the license has expired andfalse
if not
-
isMaxUsesReached
public boolean isMaxUsesReached()
Checks if the license has reached the maximum amount of uses (if the maximum amount of uses is set)- Returns:
true
if the license has reached the maximum amount of uses andfalse
if not
-
getLicenseKey
public String getLicenseKey()
Gets the current license key. If the license key is invalid, this method will returnnull
- Returns:
- the current license key
-
getGroups
public ArrayList<String> getGroups()
Gets all groups of the license- Returns:
- all groups of the license
-
hasGroup
public boolean hasGroup(String group)
Checks if the license has a specific group- Parameters:
group
- The group you want to check- Returns:
true
if the license has the group andfalse
if not
-
getPermissions
public ArrayList<String> getPermissions()
Gets all permissions of the license- Returns:
- all permissions of the license
-
hasPermission
public boolean hasPermission(String permission)
Checks if the license has a specific permission- Parameters:
permission
- The permission you want to check- Returns:
true
if the license has the permission andfalse
if not
-
getMeta
public ArrayList<LicenseMeta> getMeta()
Gets all meta information of the license- Returns:
- all meta information of the license
-
getMeta
public String getMeta(String key)
Gets a specific meta information of the license. If the meta information does not exist, this method will returnnull
- Parameters:
key
- The key of the meta information you want to get- Returns:
- the value of the meta information
-
getMaxUses
public int getMaxUses()
Gets the maximum amount of uses of the license. If the maximum amount of uses is not set, this method will return-1
- Returns:
- the maximum amount of uses of the license
-
getCurrentUses
public int getCurrentUses()
Gets the current amount of uses of the license- Returns:
- the current amount of uses of the license
-
getExpirationDate
public Date getExpirationDate()
Gets the expiration date of the license. If the license has no expiration date, this method will returnnull
- Returns:
- the expiration date of the license
-
-