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

org.droitateddb.validation.ValidationResult Maven / Gradle / Ivy

Go to download

droitatedDB is a lightweight framework, which frees you from the burden of dealing with Androids SQLite database directly if you don't want to and let's you access it directly if you have to.

There is a newer version: 0.1.10
Show newest version
package org.droitateddb.validation;

/**
 * The result of a validation
 *
 * @author Falk Appel
 * @author Alexander Frank
 */
public class ValidationResult {
    private final boolean valid;
    private final int errorCode;
    private final String errorMessage;

    private ValidationResult(boolean valid, int errorCode, String errorMessage) {
        this.valid = valid;
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public boolean isValid() {
        return valid;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public static ValidationResult valid() {
        return new ValidationResult(true, 0, "");
    }

    public static ValidationResult invalid(int errorCode, String error) {
        return new ValidationResult(false, errorCode, error);
    }

    @Override
    public String toString() {
        if (valid) {
            return "valid";
        } else {
            return "(" + errorCode + ") " + errorMessage;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy