// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.parser;

/**
 * Common methods for various Parsed* classes.
 * @author arnej27959
 **/
public class ParsedBlock {
    private final String name;
    private final String blockType;

    public ParsedBlock(String name, String blockType) {
        this.name = name;
        this.blockType = blockType;
    }

    public final String name() { return name; }

    protected void verifyThat(boolean check, String msg, Object ... msgDetails) {
        if (check) return;
        var buf = new StringBuilder();
        buf.append(blockType).append(" '").append(name).append("' error: ");
        buf.append(msg);
        for (Object detail : msgDetails) {
            buf.append(" ");
            buf.append(detail.toString());
        }
        throw new IllegalArgumentException(buf.toString());
    }

}


@@ -487,16 +487,74 @@
  name; %7D
+%0A    public final String blockType() %7B return blockType; %7D
 %0A%0A    pr
@@ -989,11 +989,94 @@
 %0A    %7D%0A%0A
+    public String toString() %7B%0A        return blockType + %22 '%22 + name + %22'%22;%0A    %7D%0A
 %7D%0A%0A

add convenience functions