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

org.projectnessie.nessie.cli.grammar.ast.MergeBranchStatement Maven / Gradle / Ivy

There is a newer version: 0.101.3
Show newest version
/* Generated by: CongoCC Parser Generator. Do not edit.
* Generated Code for MergeBranchStatement AST Node type
* by the ASTNode.java.ftl template
*/
package org.projectnessie.nessie.cli.grammar.ast;

import org.projectnessie.nessie.cli.cmdspec.*;
import org.projectnessie.nessie.cli.grammar.*;
import java.util.*;
import static org.projectnessie.nessie.cli.grammar.Token.TokenType.*;


public class MergeBranchStatement extends BaseNode implements MergeBranchCommandSpec {

    @Override
    public String getInCatalog() {
        return stringValueOf("inCatalog");
    }

    @Override
    public String getRefType() {
        Node type = getNamedChild("type");
        return type != null ? type.getSource().toUpperCase() : null;
    }

    @Override
    public String getRef() {
        return stringValueOf("ref");
    }

    @Override
    public String getRefTimestampOrHash() {
        return stringValueOf("at");
    }

    @Override
    public String getInto() {
        return stringValueOf("into");
    }

    @Override
    public String getDefaultMergeBehavior() {
        Node behavior = getNamedChild("defaultMergeBehavior");
        return behavior != null ? behavior.getSource().toUpperCase() : null;
    }

    @Override
    public boolean isDryRun() {
        return getNamedChild("dryRun") != null;
    }

    @Override
    public Map getKeyMergeBehaviors() {
        Map behaviors = new HashMap<>();
        List children = children();
        for (int i = 0; i < children.size(); i++) {
            Node child = children.get(i);
            if (child.getType() == BEHAVIORS) {
                for (i++; i < children.size();) {
                    Node key = children.get(i++);
                    if (children.get(i++).getType() != EQUAL) {
                        throw new IllegalArgumentException("Syntax error, missing '='");
                    }
                    Node value = children.get(i++);
                    behaviors.put(((IdentifierOrLiteral) key).getStringValue(), value.getSource().toUpperCase());
                    if (children.size() == i || children.get(i++).getType() != AND) {
                        break;
                    }
                }
                break;
            }
        }
        return behaviors;
    }

}






© 2015 - 2025 Weber Informatics LLC | Privacy Policy