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

net.objecthunter.exp4j.ValidationResult Maven / Gradle / Ivy

There is a newer version: 4.15.102
Show newest version
/* 
* Copyright 2014 Frank Asseg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. 
*/
package net.objecthunter.exp4j;

import java.util.List;

/**
 * Contains the validation result for a given {@link Expression}
 */
public class ValidationResult {
    private final boolean valid;
    private final List errors;

    /**
     * Create a new instance
     * @param valid Whether the validation of the expression was successful
     * @param errors The list of errors returned if the validation was unsuccessful
     */
    public ValidationResult(boolean valid, List errors) {
        this.valid = valid;
        this.errors = errors;
    }

    /**
     * Check if an expression has been validated successfully
     * @return true if the validation was successful, false otherwise
     */
    public boolean isValid() {
        return valid;
    }

    /**
     * Get the list of errors describing the issues while validating the expression
     * @return The List of errors
     */
    public List getErrors() {
        return errors;
    }

    /**
     * A static class representing a successful validation result
     */
    public static final ValidationResult SUCCESS = new ValidationResult(true, null);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy