All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.structurizr.dsl.CustomViewAnimationStepParser Maven / Gradle / Ivy

The newest version!
package com.structurizr.dsl;

import com.structurizr.model.CustomElement;
import com.structurizr.model.Element;
import com.structurizr.view.CustomView;

import java.util.ArrayList;
import java.util.List;

final class CustomViewAnimationStepParser extends AbstractParser {

    void parse(CustomViewDslContext context, Tokens tokens) {
        // animationStep  [identifier...]

        if (!tokens.includes(1)) {
            throw new RuntimeException("Expected: animationStep  [identifier...]");
        }

        parse(context, context.getCustomView(), tokens, 1);
    }

    void parse(CustomViewAnimationDslContext context, Tokens tokens) {
        //  [identifier...]

        if (!tokens.includes(0)) {
            throw new RuntimeException("Expected:  [identifier...]");
        }

        parse(context, context.getView(), tokens, 0);
    }

    void parse(DslContext context, CustomView view, Tokens tokens, int startIndex) {
        List elements = new ArrayList<>();

        for (int i = startIndex; i < tokens.size(); i++) {
            String elementIdentifier = tokens.get(i);

            Element element = context.getElement(elementIdentifier);
            if (element == null) {
                throw new RuntimeException("The element \"" + elementIdentifier + "\" does not exist");
            }

            if (element instanceof CustomElement) {
                elements.add((CustomElement)element);
            }
        }

        view.addAnimation(elements.toArray(new CustomElement[0]));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy