Package rs.baselib.licensing
Class DefaultLicenseContext
java.lang.Object
rs.baselib.licensing.DefaultLicenseContext
- All Implemented Interfaces:
ILicenseContext
public class DefaultLicenseContext extends java.lang.Object implements ILicenseContext
Default implementation of an
ILicenseContext.- Author:
- ralph
-
Constructor Summary
Constructors Constructor Description DefaultLicenseContext()Constructor. -
Method Summary
Modifier and Type Method Description <T> Tget(java.lang.Class<T> clazz)Returns the property of given class.java.lang.Objectget(java.lang.String key)Returns the property with given key.java.lang.Iterable<java.lang.String>getKeys()Returns the property keys.booleanhasKey(java.lang.Class<?> clazz)Returns whether the context has such a value.booleanhasKey(java.lang.String key)Returns whether the context has such a value.<T> Tremove(java.lang.Class<T> clazz)Removes the property of given class.java.lang.Objectremove(java.lang.String key)Removes the property with given key.<T> voidset(java.lang.Class<T> clazz, T value)Sets the property.voidset(java.lang.String key, java.lang.Object value)Sets the property.
-
Constructor Details
-
DefaultLicenseContext
public DefaultLicenseContext()Constructor.
-
-
Method Details
-
get
public java.lang.Object get(java.lang.String key)Returns the property with given key.- Specified by:
getin interfaceILicenseContext- Parameters:
key- key of property- Returns:
- the value or
nullif the property doesn't exist
-
get
public <T> T get(java.lang.Class<T> clazz)Returns the property of given class. The class parameter will be the key of the property.- Specified by:
getin interfaceILicenseContext- Type Parameters:
T- type of value- Parameters:
clazz- type of property- Returns:
- the value or
nullif the property doesn't exist
-
hasKey
public boolean hasKey(java.lang.Class<?> clazz)Returns whether the context has such a value.- Specified by:
hasKeyin interfaceILicenseContext- Parameters:
clazz- the clazz to look for (name is key)- Returns:
truewhen context has this key
-
hasKey
public boolean hasKey(java.lang.String key)Returns whether the context has such a value.- Specified by:
hasKeyin interfaceILicenseContext- Parameters:
key- the key to look for- Returns:
truewhen context has this key
-
set
public void set(java.lang.String key, java.lang.Object value)Sets the property.- Specified by:
setin interfaceILicenseContext- Parameters:
key- key of propertyvalue- value
-
set
public <T> void set(java.lang.Class<T> clazz, T value)Sets the property. The property key will be the name of the class parameter.- Specified by:
setin interfaceILicenseContext- Type Parameters:
T- type of value- Parameters:
clazz- class of propertyvalue- value
-
getKeys
public java.lang.Iterable<java.lang.String> getKeys()Returns the property keys.- Specified by:
getKeysin interfaceILicenseContext- Returns:
- an iterable of all property keys
-
remove
public java.lang.Object remove(java.lang.String key)Removes the property with given key.- Specified by:
removein interfaceILicenseContext- Parameters:
key- key of property- Returns:
- the value that was removed
-
remove
public <T> T remove(java.lang.Class<T> clazz)Removes the property of given class. The key of the removed property is the class parameter name.- Specified by:
removein interfaceILicenseContext- Type Parameters:
T- type of value- Parameters:
clazz- class of property- Returns:
- the value that was removed
-