public abstract static class AbstractContext.AbstractBuilder<B extends AbstractContext.AbstractBuilder<B>>
extends java.lang.Object
AbstractContext
instances. Instances of
this class are not thread-safe.Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Object,java.lang.Object>> |
attributes
Map with the attributes of this context.
|
Constructor and Description |
---|
AbstractContext.AbstractBuilder()
Create a new Builder instance without any provider, e.g. for creating
new
AbstractContext instances for querying. |
AbstractContext.AbstractBuilder(AbstractContext context)
Create a new Builder, hereby using the given
AbstractContext
's values as defaults. |
Modifier and Type | Method and Description |
---|---|
abstract AbstractContext |
create()
Creates a new
AbstractContext with the data from this Builder
instance. |
B |
remove(java.lang.Class type)
Removes all attributes of a given type, using
attribute.getClass() as attribute
type and attribute.getClass().getName() as attribute
name. |
B |
remove(java.lang.Class type,
java.lang.Object key)
Removes an attribute, using
attribute.getClass() as attribute
type. |
B |
set(java.lang.Object value)
Sets an attribute, using
attribute.getClass() as attribute
type and attribute.getClass().getName() as attribute
name. |
B |
set(java.lang.Object value,
java.lang.Object key)
Sets an attribute, using
attribute.getClass() as attribute
type. |
<T> B |
set(T attribute,
java.lang.Object key,
java.lang.Class<? extends T> type)
Sets an attribute.
|
B |
setAll(AbstractContext context)
Apply all attributes on the given context.
|
java.lang.String |
toString() |
protected final java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Object,java.lang.Object>> attributes
public AbstractContext.AbstractBuilder()
AbstractContext
instances for querying.public AbstractContext.AbstractBuilder(AbstractContext context)
AbstractContext
's values as defaults. This allows changing an existing
AbstractContext
easily.context
- the context, not null
public abstract AbstractContext create()
AbstractContext
with the data from this Builder
instance.AbstractContext
. never null
.public B remove(java.lang.Class type)
attribute.getClass()
as attribute
type and attribute.getClass().getName()
as attribute
name.type
- the attribute's type, not null
public B remove(java.lang.Class type, java.lang.Object key)
attribute.getClass()
as attribute
type.type
- the attribute's type to be removedkey
- the attribute's key, not null
public B set(java.lang.Object value)
attribute.getClass()
as attribute
type and attribute.getClass().getName()
as attribute
name.value
- the attribute valuepublic B set(java.lang.Object value, java.lang.Object key)
attribute.getClass()
as attribute
type.value
- the attribute valuekey
- the attribute's key, not null
public <T> B set(T attribute, java.lang.Object key, java.lang.Class<? extends T> type)
attribute
- the attribute's valuekey
- the attribute's keytype
- the attribute's typepublic B setAll(AbstractContext context)
context
- the context to be applied, not null.public java.lang.String toString()
toString
in class java.lang.Object