View Javadoc
1   package ca.uhn.fhir.rest.api;
2   
3   import java.util.HashMap;
4   
5   import org.apache.commons.lang3.Validate;
6   
7   /*
8    * #%L
9    * HAPI FHIR - Core Library
10   * %%
11   * Copyright (C) 2014 - 2018 University Health Network
12   * %%
13   * Licensed under the Apache License, Version 2.0 (the "License");
14   * you may not use this file except in compliance with the License.
15   * You may obtain a copy of the License at
16   * 
17   *      http://www.apache.org/licenses/LICENSE-2.0
18   * 
19   * Unless required by applicable law or agreed to in writing, software
20   * distributed under the License is distributed on an "AS IS" BASIS,
21   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22   * See the License for the specific language governing permissions and
23   * limitations under the License.
24   * #L%
25   */
26  
27  /**
28   * Validation mode parameter for the $validate operation (DSTU2+ only) 
29   */
30  public enum ValidationModeEnum {
31  	/**
32  	 * 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)
33  	 */
34  	CREATE("create"),
35  	
36  	/**
37  	 * 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)
38  	 */
39  	UPDATE("update"),
40  
41  	/**
42  	 * The server ignores the content, and checks that the nominated resource is allowed to be deleted (e.g. checking referential integrity rules)
43  	 */
44  	DELETE("delete");
45  
46  	private static HashMap<String, ValidationModeEnum> myCodeToValue;
47  	private String myCode;
48  
49  	static {
50  		myCodeToValue = new HashMap<String, ValidationModeEnum>();
51  		for (ValidationModeEnum next : values()) {
52  			myCodeToValue.put(next.getCode(), next);
53  		}
54  	}
55  	
56  	public static ValidationModeEnum forCode(String theCode) {
57  		Validate.notBlank(theCode, "theCode must not be blank");
58  		return myCodeToValue.get(theCode);
59  	}
60  	
61  	public String getCode() {
62  		return myCode;
63  	}
64  
65  	private ValidationModeEnum(String theCode) {
66  		myCode = theCode;
67  	}
68  	
69  //	@Override
70  //	public boolean isEmpty() {
71  //		return false;
72  //	}
73  }