com.easyinnova.implementation_checker.ValidationResult Maven / Gradle / Ivy
Show all versions of tiffimplementationchecker Show documentation
/**
* ValidationResult.java
This program is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any later version; or,
* at your choice, under the terms of the Mozilla Public License, v. 2.0. SPDX GPL-3.0+ or MPL-2.0+.
*
This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License and the Mozilla Public License for more details.
* You should have received a copy of the GNU General Public License and the Mozilla Public
* License along with this program. If not, see http://www.gnu.org/licenses/
* and at http://mozilla.org/MPL/2.0 .
NB: for the
* © statement, include Easy Innova SL or other company/Person contributing the code.
©
* 2015 Easy Innova, SL
*
* @author Víctor Muñoz Sola
* @version 1.0
* @since 23/7/2015
*/
package com.easyinnova.implementation_checker;
import com.easyinnova.implementation_checker.rules.RuleResult;
import java.util.ArrayList;
import java.util.List;
/**
* Created by easy on 29/03/2016.
*/
public class ValidationResult {
private List result;
/**
* Instantiates a new Validation result.
*/
public ValidationResult() {
result = new ArrayList<>();
}
/**
* Add rule.
*
* @param ruleResult the rule result
*/
public void add(RuleResult ruleResult) {
result.add(ruleResult);
}
/**
* Gets result.
*
* @return the result
*/
public List getResult() {
return result;
}
/**
* Gets passed.
*
* @return the passed rules
*/
public List getPassed() {
List passed = new ArrayList<>();
for (RuleResult res : result) {
if (res.ok()) {
passed.add(res);
}
}
return passed;
}
/**
* Gets errors.
*
* @return the errors
*/
public List getErrors() {
List errors = new ArrayList<>();
for (RuleResult res : result) {
if (!res.ok() && !res.getWarning() && !res.getInfo()) {
errors.add(res);
}
}
return errors;
}
/**
* Gets warnings.
*
* @return the warnings
*/
public List getWarnings(boolean infos) {
List errors = new ArrayList<>();
for (RuleResult res : result) {
if (!res.ok()) {
if (res.getWarning()) errors.add(res);
else if (infos && res.getInfo()) errors.add(res);
}
}
return errors;
}
/**
* Gets infos.
*
* @return the infos
*/
public List getInfos() {
List errors = new ArrayList<>();
for (RuleResult res : result) {
if (!res.ok() && res.getInfo()) {
errors.add(res);
}
}
return errors;
}
}