001package ca.uhn.fhir.context;
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 java.lang.reflect.Field;
024import java.util.Collections;
025import java.util.Set;
026
027import org.hl7.fhir.instance.model.api.IBase;
028
029import ca.uhn.fhir.model.api.annotation.Child;
030import ca.uhn.fhir.model.api.annotation.Description;
031
032public class RuntimeChildExtension extends RuntimeChildAny {
033
034//      private RuntimeChildUndeclaredExtensionDefinition myExtensionElement;
035
036        public RuntimeChildExtension(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation) {
037                super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation);
038        }
039
040        @Override
041        public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
042                return getElementName();
043        }
044
045        @Override
046        public Set<String> getValidChildNames() {
047                return Collections.singleton(getElementName());
048        }
049
050        @Override
051        public BaseRuntimeElementDefinition<?> getChildByName(String theName) {
052                if ("extension".equals(theName) || "modifierExtension".equals(theName)) {
053                        return super.getChildByName("extensionExtension");
054                }
055                return super.getChildByName(theName);
056        }
057        
058//      @Override
059//      public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
060//              if (IBaseExtension.class.isAssignableFrom(theDatatype)) {
061//                      return myExtensionElement;
062//              }
063//              return super.getChildElementDefinitionByDatatype(theDatatype);
064//      }
065//
066//      @Override
067//      void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
068//              super.sealAndInitialize(theContext, theClassToElementDefinitions);
069//              
070//              myExtensionElement = theContext.getRuntimeChildUndeclaredExtensionDefinition();
071//      }
072
073
074}