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

com.github.ldeitos.validation.Severity Maven / Gradle / Ivy

Go to download

Extension for BeanValidation API Core. Content interfaces, qualifiers and constraints definitions. This version is Java 17 and JakartaEE 10 compatible.

The newest version!
package com.github.ldeitos.validation;

import static com.github.ldeitos.validation.ConstraintSeverity.alert;
import static com.github.ldeitos.validation.ConstraintSeverity.defaultValue;
import static com.github.ldeitos.validation.ConstraintSeverity.error;
import static com.github.ldeitos.validation.ConstraintSeverity.fatal;
import static com.github.ldeitos.validation.ConstraintSeverity.info;
import static com.github.ldeitos.validation.ConstraintSeverity.warn;

/**
 * Possibles severity level to be generated by ExtendedValidation engine.
 *
 * @author Leandro Deitos
 *
 */
public enum Severity {
	/**
	 * Error severity.
	 */
	ERROR(error()),

	/**
	 * Alert severity.
	 */
	ALERT(alert()),

	/**
	 * Info severity.
	 */
	INFO(info()),

	/**
	 * Warn severity.
	 */
	WARN(warn()),

	/**
	 * Fatal severity.
	 */
	FATAL(fatal());

	private Class cSeverity;

	private Severity(Class constraintSeverity) {
		cSeverity = constraintSeverity;
	}

	Class getConstraintSeverity() {
		return cSeverity;
	}

	/**
	 * @param constraintSeveritiry
	 *            {@link ConstraintSeverity} to recover {@link Severity}
	 *            equivalent.
	 * @return {@link Severity} item recovered by {@link ConstraintSeverity}. 
* Case {@link ConstraintSeverity} does't have a equivalent * {@link Severity}, {@link #ERROR} is a default return. */ public static Severity fromConstraintSeverity(Class constraintSeveritiry) { Severity retorno = null; for (Severity value : values()) { if (value.getConstraintSeverity().equals(constraintSeveritiry)) { retorno = value; break; } } if (retorno == null) { retorno = fromConstraintSeverity(defaultValue()); } return retorno; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy