Interface ApplicationContext
-
- All Implemented Interfaces:
public interface ApplicationContext
-
-
Method Summary
Modifier and Type Method Description abstract StringgetName()Application context name abstract Set<Key<?>>getPermittedKeys()Keys permitted for this context. abstract BooleanisKeyValid(Key<?> key)Checks if key is valid for this context. abstract <T extends Any> UnitaddIfNotPresent(Key<T> key, T value)Add value for given key if not already present. abstract <T extends Any> ObjectaddWithOverwrite(Key<T> key, T value)Add value for given key even if already present. abstract <T extends Any> Unitadd(Key<T> key, T value)Add value for given key. abstract <T extends Any> Booleanexists(Key<T> key)Check if any value or null associated with give key abstract <T extends Any> Tfetch(Key<T> key)Fetch value associated with key or null abstract <T extends Any> Terase(Key<T> key)Erase value associated with key if any abstract Unitclear()Clear the entire context abstract Set<Key<?>>keySet()Get a set of keys in context abstract Unitmerge(ApplicationContext other, ApplicationContextMergeStrategy mergeStrategy)Merge other context with this using the given merge strategy abstract ApplicationContextclone(String cloneName, Set<Key<?>> clonePermittedKeys)Creates a clone of this context with passed cloneName and clonePermittedKeys. -
-
Method Detail
-
getPermittedKeys
abstract Set<Key<?>> getPermittedKeys()
Keys permitted for this context. Empty set means all keys permitted.
Implementations should allow setting up of PermittedKeys at time of context initialization
- Returns:
set of permitted keys
-
isKeyValid
abstract Boolean isKeyValid(Key<?> key)
Checks if key is valid for this context.
- Returns:
key
-
addIfNotPresent
abstract <T extends Any> Unit addIfNotPresent(Key<T> key, T value)
Add value for given key if not already present.
This is semmantically same as
if(!exists(key)) add(key, value)*- Parameters:
value- </T>
-
addWithOverwrite
abstract <T extends Any> Object addWithOverwrite(Key<T> key, T value)
Add value for given key even if already present.
- Returns:
Previous value associated with key if any or null </T>
-
add
abstract <T extends Any> Unit add(Key<T> key, T value)
Add value for given key.
- Parameters:
value- </T>
-
exists
abstract <T extends Any> Boolean exists(Key<T> key)
Check if any value or null associated with give key
- Returns:
true if value or null associated with give key otherwise false </T>
-
fetch
abstract <T extends Any> T fetch(Key<T> key)
Fetch value associated with key or null
- Returns:
value associated with key or null </T>
-
erase
abstract <T extends Any> T erase(Key<T> key)
Erase value associated with key if any
- Returns:
value associate with key or null </T>
-
merge
abstract Unit merge(ApplicationContext other, ApplicationContextMergeStrategy mergeStrategy)
Merge other context with this using the given merge strategy
- Parameters:
other- other context.
-
clone
abstract ApplicationContext clone(String cloneName, Set<Key<?>> clonePermittedKeys)
Creates a clone of this context with passed cloneName and clonePermittedKeys. While cloning only the permittedKeys will be added
- Parameters:
cloneName- name of the cloned ApplicationContextclonePermittedKeys- permittedKeys of the cloned ApplicationContext
-
-
-
-