Package com.structurizr.model
Class NormalizedNameIdGenerator
java.lang.Object
com.structurizr.model.NormalizedNameIdGenerator
- All Implemented Interfaces:
IdGenerator
public class NormalizedNameIdGenerator extends java.lang.Object implements IdGenerator
An ID generator that uses the element name to generate IDs for model elements and relationships.
The canonical name will be normalized by removing any characters other than letters and numbers.
-
Constructor Summary
Constructors Constructor Description NormalizedNameIdGenerator()
Creates a new ID generator, where element IDs are based upon the canonical name of the element.NormalizedNameIdGenerator(boolean canonical)
Creates a new ID generator. -
Method Summary
Modifier and Type Method Description void
found(java.lang.String id)
Called when loading/deserializing a model, to indicate that the specified ID has been found (and shouldn't be reused when generating new IDs).java.lang.String
generateId(Element element)
Generates an ID for the specified model element.java.lang.String
generateId(Relationship relationship)
Generates an ID for the specified model relationship.
-
Constructor Details
-
NormalizedNameIdGenerator
public NormalizedNameIdGenerator()Creates a new ID generator, where element IDs are based upon the canonical name of the element. -
NormalizedNameIdGenerator
public NormalizedNameIdGenerator(boolean canonical)Creates a new ID generator.- Parameters:
canonical
-true
will use theElement.getCanonicalName()
,false
will useElement.getName()
-
-
Method Details
-
found
public void found(java.lang.String id)Description copied from interface:IdGenerator
Called when loading/deserializing a model, to indicate that the specified ID has been found (and shouldn't be reused when generating new IDs).- Specified by:
found
in interfaceIdGenerator
- Parameters:
id
- the ID that has been found
-
generateId
Description copied from interface:IdGenerator
Generates an ID for the specified model element.- Specified by:
generateId
in interfaceIdGenerator
- Parameters:
element
- an Element instance- Returns:
- the ID, as a String
-
generateId
Description copied from interface:IdGenerator
Generates an ID for the specified model relationship.- Specified by:
generateId
in interfaceIdGenerator
- Parameters:
relationship
- a Relationship instance- Returns:
- the ID, as a String
-