001package ca.uhn.fhir.model.api;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2021 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import org.hl7.fhir.instance.model.api.IBaseDatatype;
024
025import java.util.List;
026
027public interface ISupportsUndeclaredExtensions extends IElement {
028        
029        /**
030         * Returns a list containing all undeclared non-modifier extensions. The returned list
031         * is mutable, so it may be modified (e.g. to add or remove an extension).
032         */
033        List<ExtensionDt> getUndeclaredExtensions();
034
035        /**
036         * Returns an <b>immutable</b> list containing all undeclared extensions (modifier and non-modifier) by extension URL
037         * 
038         * @see #getUndeclaredExtensions() To return a mutable list which may be used to remove extensions
039         */
040        List<ExtensionDt> getUndeclaredExtensionsByUrl(String theUrl);
041
042        /**
043         * Returns an <b>immutable</b> list containing all extensions (modifier and non-modifier).
044         * 
045         * @see #getUndeclaredExtensions() To return a mutable list which may be used to remove undeclared non-modifier extensions
046         * @see #getUndeclaredModifierExtensions() To return a mutable list which may be used to remove undeclared modifier extensions
047         */
048        List<ExtensionDt> getAllUndeclaredExtensions();
049
050        /**
051         * Returns a list containing all undeclared modifier extensions. The returned list
052         * is mutable, so it may be modified (e.g. to add or remove an extension).
053         */
054        List<ExtensionDt> getUndeclaredModifierExtensions();
055        
056        /**
057         * Adds an extension to this object. This extension should have the
058         * following properties set:
059         * <ul>
060         * <li>{@link ExtensionDt#setModifier(boolean) Is Modifier}</li>
061         * <li>{@link ExtensionDt#setUrl(String) URL}</li>
062         * <li>And one of:
063         * <ul>
064         * <li>{@link ExtensionDt#setValue(IBaseDatatype) A datatype value}</li>
065         * <li>{@link #addUndeclaredExtension(ExtensionDt) Further sub-extensions}</li>
066         * </ul>
067         * </ul> 
068         * 
069         * @param theExtension The extension to add. Can not be null.
070         */
071        void addUndeclaredExtension(ExtensionDt theExtension);
072        
073        /**
074         * Adds an extension to this object
075         * 
076         * @see #getUndeclaredExtensions() To return a mutable list which may be used to remove extensions
077         */
078        ExtensionDt addUndeclaredExtension(boolean theIsModifier, String theUrl, IBaseDatatype theValue);
079
080        /**
081         * Adds an extension to this object. This method is intended for use when
082         * an extension is being added which will contain child extensions, as opposed to
083         * a datatype.
084         * 
085         * @see #getUndeclaredExtensions() To return a mutable list which may be used to remove extensions
086         */
087        ExtensionDt addUndeclaredExtension(boolean theIsModifier, String theUrl);
088
089}