Modifier and Type | Field and Description |
---|---|
static CollisionPolicy<?> |
FAIL_ON_COLLISION
Predefined collision policy throwing a DRException on a name collision.
|
static NamingPolicy<?> |
NO_DEFAULT_NAME
Predefined name generation policy throwing an exception.
|
static CollisionPolicy<?> |
RENAME_SEQUENTIALLY
Predefined collision policy retrying the name binding with a new name.
|
static CollisionPolicy<?> |
REPLACE_ON_COLLISION
Predefined collision policy replacing the existing entry on a name collision.
|
Constructor and Description |
---|
NamespaceBuilder()
Creates a new mutable namespace with collisions causing an error
and no default name generation.
|
NamespaceBuilder(CollisionPolicy<T> onCollision)
Creates a new mutable namespace with the specified collision
policy and no default name generation.
|
NamespaceBuilder(CollisionPolicy<T> onCollision,
NamingPolicy<T> defaultNaming)
Creates a new mutable namespace with the specified collision and name
generation policies.
|
NamespaceBuilder(NamingPolicy<T> defaultNaming)
Creates a new mutable namespace with collisions causing an error
and the specified name generation policy.
|
Modifier and Type | Method and Description |
---|---|
String |
add(String name,
T entry)
Adds an entry to the name space, associated with the given name.
|
String |
add(T entry)
Add an entry to the namespace.
|
void |
addAll(Namespace<T> entries)
Add all entries from a namespace into this namespace.
|
void |
clear()
Removes all entries from the namespace.
|
T |
get(int i)
Gets the entry at the specified index.
|
T |
get(String name)
Gets the entry associated with the specified namefrom the namespace.
|
NameBinding<T> |
getBinding(int i)
Gets the name-entry association at the specified index.
|
List<NameBinding<T>> |
getBindings()
Gets a collection of all the name-entry associations.
|
String |
getName(int i)
Gets the name associated with entry at the specified
index.
|
String[] |
getNames()
Gets all names registered in the namespace.
|
int |
indexOf(String name)
Gets the index of the entry associated with the
given name.
|
boolean |
isEmpty()
Indicates whether the namespace is empty.
|
Iterator<T> |
iterator() |
Set<String> |
nameSet()
Get an unmodifiable collection of all names.
|
T |
remove(String name)
Removes an entry from the namespace.
|
static <T> NamespaceBuilder<T> |
sequencedNamespace()
Gets a mutable namespace with no default naming policy.
|
static <T> NamespaceBuilder<T> |
sequencedNamespace(NamingPolicy<T> defaultNaming)
Gets a mutable namespace using the specified default naming policy.
|
void |
setListener(BindListener<T> listener)
Attaches a listener for namespace entry assignment events.
|
int |
size()
Retrieves the number of elements in the namespace.
|
Namespace<T> |
toNamespace()
Constructs the currently defined namespace.
|
String |
toString() |
static <T> NamespaceBuilder<T> |
uniqueNamespace()
Gets a mutable namespace with no default naming policy.
|
static <T> NamespaceBuilder<T> |
uniqueNamespace(NamingPolicy<T> defaultNaming)
Gets a mutable namespace using the specified default naming policy.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static final CollisionPolicy<?> FAIL_ON_COLLISION
public static final CollisionPolicy<?> REPLACE_ON_COLLISION
public static final CollisionPolicy<?> RENAME_SEQUENTIALLY
public static final NamingPolicy<?> NO_DEFAULT_NAME
add(Object)
method will always fail.public NamespaceBuilder()
public NamespaceBuilder(CollisionPolicy<T> onCollision)
onCollision
- the collision policy to use in the namespacepublic NamespaceBuilder(NamingPolicy<T> defaultNaming)
defaultNaming
- the name generation strategy to use in the namespacepublic NamespaceBuilder(CollisionPolicy<T> onCollision, NamingPolicy<T> defaultNaming)
onCollision
- the collision policy to use in the namespacedefaultNaming
- the name generation strategy to use in the namespacepublic static <T> NamespaceBuilder<T> uniqueNamespace()
FAIL_ON_COLLISION
.T
- the type of elements in the namespacepublic static <T> NamespaceBuilder<T> uniqueNamespace(NamingPolicy<T> defaultNaming)
FAIL_ON_COLLISION
.T
- the type of elements in the namespacedefaultNaming
- the naming policy to use when adding elements
without a namepublic static <T> NamespaceBuilder<T> sequencedNamespace()
RENAME_SEQUENTIALLY
.T
- the type of elements in the namespacepublic static <T> NamespaceBuilder<T> sequencedNamespace(NamingPolicy<T> defaultNaming)
RENAME_SEQUENTIALLY
.T
- the type of elements in the namespacedefaultNaming
- the naming policy to use when adding elements
without a namepublic void setListener(BindListener<T> listener)
listener
- the listener to attachpublic final int size()
public final boolean isEmpty()
size() == 0
.true
if empty, false
otherwisepublic String add(T entry)
entry
- the value to add to the namespaceDRException
- if one of the namespace policies is violatedpublic String add(String name, T entry)
name
- the name to associate with the entryentry
- the value to add to the namespaceDRException
- if one of the namespace policies is violatedpublic void addAll(Namespace<T> entries)
entries
- source of namespace entries to addDRException
- if one of the namespace policies is violated.
No guarantee is made about the contents of the namespace if this
occurs.public void clear()
public T get(int i)
i
- index of the element to retrieveIndexOutOfBoundsException
- if
i < 0 || i >= size()
public NameBinding<T> getBinding(int i)
i
- index of the element to retrieveIndexOutOfBoundsException
- if
i < 0 || i >= size()
public int indexOf(String name)
name
- the name of the entry to find-1
if
no entry with the given name existspublic T get(String name)
name
- the name of the entry to findnull
if there is no such entrypublic T remove(String name)
name
- the name of the entry to removenull
if there is no such entrypublic String getName(int i)
i
- index of the element name to retrieveIndexOutOfBoundsException
- if
i < 0 || i >= size()
public String[] getNames()
public Set<String> nameSet()
public List<NameBinding<T>> getBindings()
public Namespace<T> toNamespace()
Copyright © 2020 Actian Corporation. All rights reserved.