001/* 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2023 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.context; 021 022import java.util.ArrayList; 023import java.util.Collections; 024import java.util.List; 025import java.util.Map; 026 027import org.hl7.fhir.instance.model.api.IBase; 028import org.hl7.fhir.instance.model.api.ICompositeType; 029 030import ca.uhn.fhir.model.api.annotation.DatatypeDef; 031 032public class RuntimeExtensionDtDefinition extends RuntimeCompositeDatatypeDefinition { 033 034 private List<BaseRuntimeChildDefinition> myChildren; 035 036 public RuntimeExtensionDtDefinition(DatatypeDef theDef, Class<? extends ICompositeType> theImplementingClass, boolean theStandardType, FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { 037 super(theDef, theImplementingClass, theStandardType, theContext, theClassToElementDefinitions); 038 } 039 040 @Override 041 public List<BaseRuntimeChildDefinition> getChildren() { 042 return myChildren; 043 } 044 045 public List<BaseRuntimeChildDefinition> getChildrenIncludingUrl() { 046 return super.getChildren(); 047 } 048 049 @Override 050 public void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { 051 super.sealAndInitialize(theContext, theClassToElementDefinitions); 052 053 /* 054 * The "url" child is a weird child because it is not parsed and encoded in the normal way, 055 * so we exclude it here 056 */ 057 058 List<BaseRuntimeChildDefinition> superChildren = super.getChildren(); 059 ArrayList<BaseRuntimeChildDefinition> children = new ArrayList<BaseRuntimeChildDefinition>(); 060 for (BaseRuntimeChildDefinition baseRuntimeChildDefinition : superChildren) { 061 if (baseRuntimeChildDefinition.getValidChildNames().contains("url")) { 062 continue; 063 } 064 children.add(baseRuntimeChildDefinition); 065 } 066 067 myChildren = Collections.unmodifiableList(children); 068 } 069 070}