X-Git-Url: https://git.pterodactylus.net/?p=jSite.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Ftodesbaum%2Fjsite%2Fapplication%2Fvalidation%2FIssue.java;fp=src%2Fmain%2Fjava%2Fde%2Ftodesbaum%2Fjsite%2Fapplication%2Fvalidation%2FIssue.java;h=451aabc825c6281d8c75097d557804e2c271dedc;hp=0000000000000000000000000000000000000000;hb=f6658f9e2121cf6f08ff567624cc9b83dcad0eb5;hpb=d01d8e6ceadffe3b8bd2cf9f84f4bbd75cba4752 diff --git a/src/main/java/de/todesbaum/jsite/application/validation/Issue.java b/src/main/java/de/todesbaum/jsite/application/validation/Issue.java new file mode 100644 index 0000000..451aabc --- /dev/null +++ b/src/main/java/de/todesbaum/jsite/application/validation/Issue.java @@ -0,0 +1,64 @@ +package de.todesbaum.jsite.application.validation; + +import static java.lang.String.format; + +import java.util.Arrays; +import java.util.Objects; + +/** + * Container class for a single issue. An issue contains an error key that describes the error, + * and a fatality flag that determines whether the insert has to be aborted (if the flag is + * {@code true}) or if it can still be performed and only a warning should be generated (if the + * flag is {@code false}). + * + * @author David ‘Bombe’ Roden + */ +public class Issue { + + private final String errorKey; + private final boolean fatal; + private final String[] parameters; + + Issue(String errorKey, boolean fatal, String... parameters) { + this.errorKey = errorKey; + this.fatal = fatal; + this.parameters = parameters; + } + + public String getErrorKey() { + return errorKey; + } + + public boolean isFatal() { + return fatal; + } + + public String[] getParameters() { + return parameters; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Issue issue = (Issue) o; + return fatal == issue.fatal && + Objects.equals(errorKey, issue.errorKey) && + Arrays.equals(parameters, issue.parameters); + } + + @Override + public int hashCode() { + return Objects.hash(errorKey, fatal, parameters); + } + + @Override + public String toString() { + return format("Issue{errorKey=\"%s\", fatal=%s, parameters=%s}", errorKey, fatal, Arrays.toString(parameters)); + } + +}