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> T get​(java.lang.Class<T> clazz)
    Returns the property of given class.
    java.lang.Object get​(java.lang.String key)
    Returns the property with given key.
    java.lang.Iterable<java.lang.String> getKeys()
    Returns the property keys.
    boolean hasKey​(java.lang.Class<?> clazz)
    Returns whether the context has such a value.
    boolean hasKey​(java.lang.String key)
    Returns whether the context has such a value.
    <T> T remove​(java.lang.Class<T> clazz)
    Removes the property of given class.
    java.lang.Object remove​(java.lang.String key)
    Removes the property with given key.
    <T> void set​(java.lang.Class<T> clazz, T value)
    Sets the property.
    void set​(java.lang.String key, java.lang.Object value)
    Sets the property.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • get

      public java.lang.Object get​(java.lang.String key)
      Returns the property with given key.
      Specified by:
      get in interface ILicenseContext
      Parameters:
      key - key of property
      Returns:
      the value or null if 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:
      get in interface ILicenseContext
      Type Parameters:
      T - type of value
      Parameters:
      clazz - type of property
      Returns:
      the value or null if the property doesn't exist
    • hasKey

      public boolean hasKey​(java.lang.Class<?> clazz)
      Returns whether the context has such a value.
      Specified by:
      hasKey in interface ILicenseContext
      Parameters:
      clazz - the clazz to look for (name is key)
      Returns:
      true when context has this key
    • hasKey

      public boolean hasKey​(java.lang.String key)
      Returns whether the context has such a value.
      Specified by:
      hasKey in interface ILicenseContext
      Parameters:
      key - the key to look for
      Returns:
      true when context has this key
    • set

      public void set​(java.lang.String key, java.lang.Object value)
      Sets the property.
      Specified by:
      set in interface ILicenseContext
      Parameters:
      key - key of property
      value - 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:
      set in interface ILicenseContext
      Type Parameters:
      T - type of value
      Parameters:
      clazz - class of property
      value - value
    • getKeys

      public java.lang.Iterable<java.lang.String> getKeys()
      Returns the property keys.
      Specified by:
      getKeys in interface ILicenseContext
      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:
      remove in interface ILicenseContext
      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:
      remove in interface ILicenseContext
      Type Parameters:
      T - type of value
      Parameters:
      clazz - class of property
      Returns:
      the value that was removed