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 intgetCurrentUses()Gets the current amount of uses of the licenseDategetExpirationDate()Gets the expiration date of the license.ArrayList<String>getGroups()Gets all groups of the licenseStringgetLicenseKey()Gets the current license key.intgetMaxUses()Gets the maximum amount of uses of the license.ArrayList<LicenseMeta>getMeta()Gets all meta information of the licenseStringgetMeta(String key)Gets a specific meta information of the license.ArrayList<String>getPermissions()Gets all permissions of the licenseLicenseStatusgetStatus()Gets the status of the licensebooleanhasGroup(String group)Checks if the license has a specific groupbooleanhasPermission(String permission)Checks if the license has a specific permissionbooleanisExpired()Checks if the license has expiredbooleanisMaxUsesReached()Checks if the license has reached the maximum amount of uses (if the maximum amount of uses is set)booleanisValid()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:
trueif the license is valid andfalseif not
-
isExpired
public boolean isExpired()
Checks if the license has expired- Returns:
trueif the license has expired andfalseif 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:
trueif the license has reached the maximum amount of uses andfalseif 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:
trueif the license has the group andfalseif 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:
trueif the license has the permission andfalseif 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
-
-