001package org.hl7.fhir.r4.model;
002
003import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
004
005
006/*
007Copyright (c) 2011+, HL7, Inc
008All rights reserved.
009
010Redistribution and use in source and binary forms, with or without modification, 
011are permitted provided that the following conditions are met:
012
013 * Redistributions of source code must retain the above copyright notice, this 
014   list of conditions and the following disclaimer.
015 * Redistributions in binary form must reproduce the above copyright notice, 
016   this list of conditions and the following disclaimer in the documentation 
017   and/or other materials provided with the distribution.
018 * Neither the name of HL7 nor the names of its contributors may be used to 
019   endorse or promote products derived from this software without specific 
020   prior written permission.
021
022THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031POSSIBILITY OF SUCH DAMAGE.
032
033*/
034
035/**
036 * Helper class to help manage generic enumerated types
037 */
038public interface EnumFactory<T extends Enum<?>> extends IBaseEnumFactory<T> {
039
040        /**
041         * Read an enumeration value from the string that represents it on the XML or JSON
042         * @param codeString the value found in the XML or JSON
043         * @return the enumeration value
044         * @throws Exception is the value is not known
045         */
046  public T fromCode(String codeString) throws IllegalArgumentException;
047  
048  /**
049   * Get the XML/JSON representation for an enumerated value
050   * @param code - the enumeration value
051   * @return the XML/JSON representation
052   */
053  public String toCode(T code);
054
055  /**
056   * Get the system URI for an enumerated value
057   * @param code - the enumeration value
058   * @return the XML/JSON representation
059   */
060  public String toSystem(T code);
061
062}