-
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a pluggable way to deal with duplicate components being identif…
…ied.
- Loading branch information
1 parent
9a8f314
commit fd3fd68
Showing
8 changed files
with
100 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
structurizr-analysis/src/com/structurizr/analysis/DuplicateComponentException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.structurizr.analysis; | ||
|
||
public class DuplicateComponentException extends RuntimeException { | ||
|
||
DuplicateComponentException(String message) { | ||
super(message); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
structurizr-analysis/src/com/structurizr/analysis/DuplicateComponentStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.structurizr.analysis; | ||
|
||
import com.structurizr.model.Component; | ||
|
||
/** | ||
* Defines a strategy that should be called when a duplicate component is found. | ||
*/ | ||
public interface DuplicateComponentStrategy { | ||
|
||
/** | ||
* Called when a duplicate component is found. | ||
* | ||
* @param component the existing Component object | ||
* @param name the new component name | ||
* @param type the new component type | ||
* @param description the new description | ||
* @param technology the new technology | ||
* | ||
* @return a Component instance, or null if a new component should not be created | ||
*/ | ||
Component duplicateComponentFound(Component component, String name, String type, String description, String technology); | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...urizr-analysis/src/com/structurizr/analysis/ThrowExceptionDuplicateComponentStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.structurizr.analysis; | ||
|
||
import com.structurizr.model.Component; | ||
|
||
/** | ||
* Throws an exception when a duplicate component is found. | ||
*/ | ||
public class ThrowExceptionDuplicateComponentStrategy implements DuplicateComponentStrategy { | ||
|
||
@Override | ||
public Component duplicateComponentFound(Component component, String name, String type, String description, String technology) { | ||
throw new DuplicateComponentException(String.format( | ||
"A component named \"%s\" already exists in the container named \"%s\".", | ||
component.getName(), | ||
component.getContainer().getName())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters