com.togethersoft.openapi.model.extension
Interface UniqueNameProvider

All Known Subinterfaces:
EntityUniqueNameProvider, ReferenceCollectionUniqueNameProvider
All Known Implementing Classes:
ChildrenProviderAdapter

public interface UniqueNameProvider
extends DeleteProvider

Provider implementing this interface takes a responsibility to decide
if some model element should be instantiated. Methods of this interface
are called from the model when it is going either to explicitly create new
element (for example, when some model client has invoked
Entity.createChildNode() method or to find possibly existing
but not yet instantiated element (when model client invokes
Model.findElement(). Implementation should return either unique
name or just an acceptance that the element exists in the universe.

Note, that no provider should implement this interface without implementing
EntityUniqueNameProvider or ReferenceCollectionUniqueNameProvider.

Author:
TogetherSoft

Method Summary
 booleancanCreateUniqueName(Entity parent, String shapeType)
          Provider should return true in this method if it can
create an element whose parent is parent and shape type is
shapeType.
 StringcreateUniqueName(Entity parent, String shapeType)
          Provider should return unique name of the new element whose
parent is parent and shape type is shapeType.
 booleanisApplicable(String uniqueName)
          Provider should return true from this method if it accepts
that element with the given uniqueName exists in the universe
Provider should not care if the element is instantiated or not.

Methods inherited from interface com.togethersoft.openapi.model.extension.DeleteProvider
canDelete, delete, isApplicable, isDeleted

Method Detail

canCreateUniqueName

public boolean canCreateUniqueName(Entity parent, String shapeType)

Provider should return true in this method if it can
create an element whose parent is parent and shape type is
shapeType.


The result of collaborative execution of this method for multiple
unique name providers registered in the model is true if
one of them has returned true. Moreover, if one of
providers has returned true from this method, the rest are
not iterated.

result true if provider can create unique name.

createUniqueName

public String createUniqueName(Entity parent, String shapeType)

Provider should return unique name of the new element whose
parent is parent and shape type is shapeType.
It is responsibility of provider to support uniqueness of the returned
value in the scope of model where provider is registered.


Model guarantees that this method will be invoked only if
canCreateUniqueName() with the same parameters has returned
true


The result of collaborative execution of this method for multiple
unique name providers registered in the model is the value returned by
the first provider who has returned true from
canCreateUniqueName() and returned non-null value
from this method.

Returns: Unique name of the new element.

isApplicable

public boolean isApplicable(String uniqueName)

Provider should return true from this method if it accepts
that element with the given uniqueName exists in the universe
Provider should not care if the element is instantiated or not.
If provider returns true then element will be instantiated
inside the model.


If element with the given uniqueName does not exist then
provider should return false.


The result of collaborative execution of this method for multiple
unique name providers registered in the model is true if
one of them has returned true. Moreover, if one of
providers has returned true from this method, the rest are
not iterated.