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

cdc.mf.ea.checks.EaRuleDescription Maven / Gradle / Ivy

The newest version!
package cdc.mf.ea.checks;

import cdc.issues.StructuredDescription;
import cdc.util.lang.UnexpectedValueException;
import cdc.util.strings.StringUtils;

public class EaRuleDescription extends StructuredDescription {
    protected EaRuleDescription(Builder builder) {
        super(builder);
    }

    private static String format(String specifier,
                                 Object arg) {
        if ("wrap".equals(specifier)) {
            return "[" + arg.toString() + "]";
        } else {
            throw new UnexpectedValueException("Invalid specifier: " + specifier);
        }
    }

    public static String format(String format,
                                Object... args) {
        return StringUtils.format(format, EaRuleDescription::format, args);
    }

    public static EaRuleDescription.Builder builder() {
        return new EaRuleDescription.Builder();
    }

    public static class Builder extends StructuredDescription.Builder {
        protected Builder() {
            super();
        }

        public Builder define(String format,
                              Object... args) {
            return text(EaRuleDescription.format(format, args));
        }

        @Override
        public EaRuleDescription build() {
            return new EaRuleDescription(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy