001package ca.uhn.fhir.rest.api; 002 003import java.util.HashMap; 004 005import org.apache.commons.lang3.Validate; 006 007/* 008 * #%L 009 * HAPI FHIR - Core Library 010 * %% 011 * Copyright (C) 2014 - 2021 Smile CDR, Inc. 012 * %% 013 * Licensed under the Apache License, Version 2.0 (the "License"); 014 * you may not use this file except in compliance with the License. 015 * You may obtain a copy of the License at 016 * 017 * http://www.apache.org/licenses/LICENSE-2.0 018 * 019 * Unless required by applicable law or agreed to in writing, software 020 * distributed under the License is distributed on an "AS IS" BASIS, 021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 022 * See the License for the specific language governing permissions and 023 * limitations under the License. 024 * #L% 025 */ 026 027/** 028 * Validation mode parameter for the $validate operation (DSTU2+ only) 029 */ 030public enum ValidationModeEnum { 031 /** 032 * The server checks the content, and then checks that the content would be acceptable as a create (e.g. that the content would not validate any uniqueness constraints) 033 */ 034 CREATE("create"), 035 036 /** 037 * The server checks the content, and then checks that it would accept it as an update against the nominated specific resource (e.g. that there are no changes to immutable fields the server does not allow to change, and checking version integrity if appropriate) 038 */ 039 UPDATE("update"), 040 041 /** 042 * The server ignores the content, and checks that the nominated resource is allowed to be deleted (e.g. checking referential integrity rules) 043 */ 044 DELETE("delete"); 045 046 private static HashMap<String, ValidationModeEnum> myCodeToValue; 047 private String myCode; 048 049 static { 050 myCodeToValue = new HashMap<String, ValidationModeEnum>(); 051 for (ValidationModeEnum next : values()) { 052 myCodeToValue.put(next.getCode(), next); 053 } 054 } 055 056 public static ValidationModeEnum forCode(String theCode) { 057 Validate.notBlank(theCode, "theCode must not be blank"); 058 return myCodeToValue.get(theCode); 059 } 060 061 public String getCode() { 062 return myCode; 063 } 064 065 private ValidationModeEnum(String theCode) { 066 myCode = theCode; 067 } 068 069// @Override 070// public boolean isEmpty() { 071// return false; 072// } 073}