001package ca.cdr.api.validator.enm; 002 003/* 004 * #%L 005 * Smile CDR - CDR 006 * %% 007 * Copyright (C) 2016 - 2024 Smile CDR, Inc. 008 * %% 009 * All rights reserved. 010 * #L% 011 */ 012 013import java.util.Collections; 014import java.util.HashMap; 015import java.util.Map; 016 017/** 018 * Indicates validation results in response headers, tags, audit logs, and transaction logs. 019 */ 020public enum RequestValidatingResultEnum { 021 022 /** 023 * Do not sort! Ordinals matter. 024 */ 025 026 /** 027 * Request Validation is disabled. 028 */ 029 NO_VALIDATION("no_validation"), 030 031 /** 032 * A given resource has passed validation. 033 */ 034 VALIDATION_PASSED("validation_passed"), 035 036 /** 037 * A given resource has failed validation with warning(s). 038 */ 039 VALIDATION_PASSED_WITH_WARNING("validation_passed_with_warning"), 040 041 /** 042 * A given resource has failed validation with error(s). 043 */ 044 VALIDATION_FAILED_WITH_ERROR("validation_failed_with_error"); 045 046 private static Map<String, RequestValidatingResultEnum> ourValues; 047 private String myCode; 048 049 private RequestValidatingResultEnum(String theCode) { 050 myCode = theCode; 051 } 052 053 public String getCode() { 054 return myCode; 055 } 056 057 public static RequestValidatingResultEnum fromCode(String theCode) { 058 if (ourValues == null) { 059 HashMap<String, RequestValidatingResultEnum> values = new HashMap<String, RequestValidatingResultEnum>(); 060 for (RequestValidatingResultEnum next : values()) { 061 values.put(next.getCode(), next); 062 } 063 ourValues = Collections.unmodifiableMap(values); 064 } 065 return ourValues.get(theCode); 066 } 067}