Package com.structurizr.model
Class MessageDigestIdGenerator
java.lang.Object
com.structurizr.model.MessageDigestIdGenerator
- All Implemented Interfaces:
IdGenerator
public class MessageDigestIdGenerator extends java.lang.Object implements IdGenerator
An ID generator that uses a digest function when generating IDs for model elements and relationships.
This allows IDs to be more stable than a sequential number, and allows models to be merged more easily.
-
Constructor Summary
Constructors Constructor Description MessageDigestIdGenerator(java.security.MessageDigest digest, int length) -
Method Summary
Modifier and Type Method Description voidfound(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.StringgenerateId(Element element)Generates an ID for the specified model element.java.lang.StringgenerateId(Relationship relationship)Generates an ID for the specified model relationship.java.lang.StringgenerateId(java.lang.String... terms)static MessageDigestIdGeneratorgetInstance(java.lang.String algorithm)static MessageDigestIdGeneratorgetInstance(java.lang.String algorithm, int length)
-
Constructor Details
-
MessageDigestIdGenerator
public MessageDigestIdGenerator(java.security.MessageDigest digest, int length)
-
-
Method Details
-
getInstance
-
getInstance
-
found
public void found(java.lang.String id)Description copied from interface:IdGeneratorCalled 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:
foundin interfaceIdGenerator- Parameters:
id- the ID that has been found
-
generateId
Description copied from interface:IdGeneratorGenerates an ID for the specified model element.- Specified by:
generateIdin interfaceIdGenerator- Parameters:
element- an Element instance- Returns:
- the ID, as a String
-
generateId
Description copied from interface:IdGeneratorGenerates an ID for the specified model relationship.- Specified by:
generateIdin interfaceIdGenerator- Parameters:
relationship- a Relationship instance- Returns:
- the ID, as a String
-
generateId
public java.lang.String generateId(java.lang.String... terms)
-