package com.megatim.fdxconsultation.model.enums; import com.fasterxml.jackson.annotation.JsonValue; import com.megatim.fdxcommons.model.search.EnumValue; /** * * @author ASUS */ public enum FonctionAggregationOperateur { EQUALS("="), NOT_EQUALS("<>"), GREATER_THAN(">"), GREATER_OR_EQUALS_THAN(">="), LOWER_THAN("<"), LOWER_OR_EQUALS_THAN("<="), IN("IN"), NOT_IN("NOT IN"), BETWEEN("BETWEEN"), NOT_BETWEEN("NOT BETWEEN"); private final String value; private FonctionAggregationOperateur(String value) { this.value = value; } @JsonValue public String getValue() { return value; } @EnumValue public static FonctionAggregationOperateur fromValeur(String value) { String cleanValue = value.trim().toUpperCase(); cleanValue = cleanValue.replaceAll("\\s+", " ");//remplacer plusieurs chaines vides par une seule chaine vide switch (cleanValue) { case "=": return FonctionAggregationOperateur.EQUALS; case "<>": return FonctionAggregationOperateur.NOT_EQUALS; case ">": return FonctionAggregationOperateur.GREATER_THAN; case ">=": return FonctionAggregationOperateur.GREATER_OR_EQUALS_THAN; case "<": return FonctionAggregationOperateur.LOWER_THAN; case "<=": return FonctionAggregationOperateur.LOWER_OR_EQUALS_THAN; case "IN": return FonctionAggregationOperateur.IN; case "NOT IN": return FonctionAggregationOperateur.NOT_IN; case "BETWEEN": return FonctionAggregationOperateur.BETWEEN; case "NOT BETWEEN": return FonctionAggregationOperateur.NOT_BETWEEN; default: return null; } } }