use of com.structurizr.view.Shape in project dsl by structurizr.
the class ElementStyleParser method parseShape.
void parseShape(ElementStyleDslContext context, Tokens tokens) {
Map<String, Shape> shapes = new HashMap<>();
String shapesAsString = "";
for (Shape shape : Shape.values()) {
shapes.put(shape.toString().toLowerCase(), shape);
shapesAsString += shape;
shapesAsString += "|";
}
shapesAsString = shapesAsString.substring(0, shapesAsString.length() - 1);
ElementStyle style = context.getStyle();
if (tokens.hasMoreThan(FIRST_PROPERTY_INDEX)) {
throw new RuntimeException("Too many tokens, expected: shape <" + shapesAsString + ">");
}
if (tokens.includes(FIRST_PROPERTY_INDEX)) {
String shape = tokens.get(1).toLowerCase();
if (shapes.containsKey(shape)) {
style.setShape(shapes.get(shape));
} else {
throw new RuntimeException("The shape \"" + shape + "\" is not valid");
}
} else {
throw new RuntimeException("Expected: shape <" + shapesAsString + ">");
}
}
Aggregations