-
-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d6cda2
commit 98371df
Showing
15 changed files
with
525 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ signing.secretKeyRingFile=/some/path | |
ossrhUsername=username | ||
ossrhPassword=password | ||
|
||
version=3.2.1 | ||
version=4.0.0 |
66 changes: 66 additions & 0 deletions
66
structurizr-dsl/src/main/java/com/structurizr/dsl/Archetype.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,66 @@ | ||
package com.structurizr.dsl; | ||
|
||
import com.structurizr.util.StringUtils; | ||
import com.structurizr.util.TagUtils; | ||
|
||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
final class Archetype { | ||
|
||
private final String name; | ||
private final String type; | ||
private String description; | ||
private String technology; | ||
private final Set<String> tags = new LinkedHashSet<>(); | ||
|
||
Archetype(String name, String type) { | ||
if (StringUtils.isNullOrEmpty(name)) { | ||
name = type; | ||
} | ||
|
||
this.name = name.toLowerCase(); | ||
this.type = type; | ||
} | ||
|
||
String getName() { | ||
return name; | ||
} | ||
|
||
String getType() { | ||
return type; | ||
} | ||
|
||
String getDescription() { | ||
return description; | ||
} | ||
|
||
void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
String getTechnology() { | ||
return technology; | ||
} | ||
|
||
void setTechnology(String technology) { | ||
this.technology = technology; | ||
} | ||
|
||
void addTags(String... tags) { | ||
if (tags == null) { | ||
return; | ||
} | ||
|
||
for (String tag : tags) { | ||
if (tag != null) { | ||
this.tags.add(tag.trim()); | ||
} | ||
} | ||
} | ||
|
||
Set<String> getTags() { | ||
return new LinkedHashSet<>(tags); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
structurizr-dsl/src/main/java/com/structurizr/dsl/ArchetypeDslContext.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,15 @@ | ||
package com.structurizr.dsl; | ||
|
||
abstract class ArchetypeDslContext extends DslContext { | ||
|
||
private final Archetype archetype; | ||
|
||
ArchetypeDslContext(Archetype archetype) { | ||
this.archetype = archetype; | ||
} | ||
|
||
Archetype getArchetype() { | ||
return archetype; | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
structurizr-dsl/src/main/java/com/structurizr/dsl/ArchetypeParser.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,62 @@ | ||
package com.structurizr.dsl; | ||
|
||
final class ArchetypeParser extends AbstractParser { | ||
|
||
private final static int NAME_INDEX = 1; | ||
private final static int VALUE_INDEX = 1; | ||
|
||
void parseTag(ArchetypeDslContext context, Tokens tokens) { | ||
// tag <tag> | ||
if (tokens.hasMoreThan(VALUE_INDEX)) { | ||
throw new RuntimeException("Too many tokens, expected: tag <tag>"); | ||
} | ||
|
||
if (!tokens.includes(NAME_INDEX)) { | ||
throw new RuntimeException("Expected: tag <tag>"); | ||
} | ||
|
||
String tag = tokens.get(VALUE_INDEX); | ||
context.getArchetype().addTags(tag); | ||
} | ||
|
||
void parseTags(ArchetypeDslContext context, Tokens tokens) { | ||
// tags <tags> [tags] | ||
if (!tokens.includes(NAME_INDEX)) { | ||
throw new RuntimeException("Expected: tags <tags> [tags]"); | ||
} | ||
|
||
for (int i = NAME_INDEX; i < tokens.size(); i++) { | ||
String tags = tokens.get(i); | ||
context.getArchetype().addTags(tags.split(",")); | ||
} | ||
} | ||
|
||
void parseDescription(ArchetypeDslContext context, Tokens tokens) { | ||
// description <description> | ||
if (tokens.hasMoreThan(VALUE_INDEX)) { | ||
throw new RuntimeException("Too many tokens, expected: description <description>"); | ||
} | ||
|
||
if (!tokens.includes(NAME_INDEX)) { | ||
throw new RuntimeException("Expected: description <description>"); | ||
} | ||
|
||
String description = tokens.get(VALUE_INDEX); | ||
context.getArchetype().setDescription(description); | ||
} | ||
|
||
void parseTechnology(ArchetypeDslContext context, Tokens tokens) { | ||
// technology <technology> | ||
if (tokens.hasMoreThan(VALUE_INDEX)) { | ||
throw new RuntimeException("Too many tokens, expected: technology <technology>"); | ||
} | ||
|
||
if (!tokens.includes(NAME_INDEX)) { | ||
throw new RuntimeException("Expected: technology <technology>"); | ||
} | ||
|
||
String technology = tokens.get(VALUE_INDEX); | ||
context.getArchetype().setTechnology(technology); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
structurizr-dsl/src/main/java/com/structurizr/dsl/ArchetypesDslContext.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,14 @@ | ||
package com.structurizr.dsl; | ||
|
||
final class ArchetypesDslContext extends DslContext { | ||
|
||
ArchetypesDslContext() { | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[] { | ||
}; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
structurizr-dsl/src/main/java/com/structurizr/dsl/ComponentArchetypeDslContext.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,19 @@ | ||
package com.structurizr.dsl; | ||
|
||
final class ComponentArchetypeDslContext extends ArchetypeDslContext { | ||
|
||
ComponentArchetypeDslContext(Archetype archetype) { | ||
super(archetype); | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[] { | ||
StructurizrDslTokens.DESCRIPTION_TOKEN, | ||
StructurizrDslTokens.TECHNOLOGY_TOKEN, | ||
StructurizrDslTokens.TAG_TOKEN, | ||
StructurizrDslTokens.TAGS_TOKEN, | ||
}; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
structurizr-dsl/src/main/java/com/structurizr/dsl/ContainerArchetypeDslContext.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,19 @@ | ||
package com.structurizr.dsl; | ||
|
||
final class ContainerArchetypeDslContext extends ArchetypeDslContext { | ||
|
||
ContainerArchetypeDslContext(Archetype archetype) { | ||
super(archetype); | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[] { | ||
StructurizrDslTokens.DESCRIPTION_TOKEN, | ||
StructurizrDslTokens.TECHNOLOGY_TOKEN, | ||
StructurizrDslTokens.TAG_TOKEN, | ||
StructurizrDslTokens.TAGS_TOKEN, | ||
}; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
structurizr-dsl/src/main/java/com/structurizr/dsl/DeploymentNodeArchetypeDslContext.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,19 @@ | ||
package com.structurizr.dsl; | ||
|
||
final class DeploymentNodeArchetypeDslContext extends ArchetypeDslContext { | ||
|
||
DeploymentNodeArchetypeDslContext(Archetype archetype) { | ||
super(archetype); | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[] { | ||
StructurizrDslTokens.DESCRIPTION_TOKEN, | ||
StructurizrDslTokens.TECHNOLOGY_TOKEN, | ||
StructurizrDslTokens.TAG_TOKEN, | ||
StructurizrDslTokens.TAGS_TOKEN, | ||
}; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
structurizr-dsl/src/main/java/com/structurizr/dsl/InfrastructureNodeArchetypeDslContext.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,19 @@ | ||
package com.structurizr.dsl; | ||
|
||
final class InfrastructureNodeArchetypeDslContext extends ArchetypeDslContext { | ||
|
||
InfrastructureNodeArchetypeDslContext(Archetype archetype) { | ||
super(archetype); | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[] { | ||
StructurizrDslTokens.DESCRIPTION_TOKEN, | ||
StructurizrDslTokens.TECHNOLOGY_TOKEN, | ||
StructurizrDslTokens.TAG_TOKEN, | ||
StructurizrDslTokens.TAGS_TOKEN, | ||
}; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
structurizr-dsl/src/main/java/com/structurizr/dsl/PersonArchetypeDslContext.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.dsl; | ||
|
||
final class PersonArchetypeDslContext extends ArchetypeDslContext { | ||
|
||
PersonArchetypeDslContext(Archetype archetype) { | ||
super(archetype); | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[] { | ||
StructurizrDslTokens.DESCRIPTION_TOKEN, | ||
StructurizrDslTokens.TAG_TOKEN, | ||
StructurizrDslTokens.TAGS_TOKEN, | ||
}; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
structurizr-dsl/src/main/java/com/structurizr/dsl/SoftwareSystemArchetypeDslContext.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.dsl; | ||
|
||
final class SoftwareSystemArchetypeDslContext extends ArchetypeDslContext { | ||
|
||
SoftwareSystemArchetypeDslContext(Archetype archetype) { | ||
super(archetype); | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[] { | ||
StructurizrDslTokens.DESCRIPTION_TOKEN, | ||
StructurizrDslTokens.TAG_TOKEN, | ||
StructurizrDslTokens.TAGS_TOKEN, | ||
}; | ||
} | ||
|
||
} |
Oops, something went wrong.