001package org.hl7.fhir.r4.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.r4 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 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 023 024import java.util.ArrayList; 025import java.util.HashMap; 026import java.util.List; 027import java.util.Map; 028 029import org.hl7.fhir.exceptions.FHIRException; 030 031public class Tuple extends Base { 032 private Map<String, List<Base>> properties = new HashMap<>(); 033 034 @Override 035 public String fhirType() { 036 return "Tuple"; 037 } 038 039 @Override 040 protected void listChildren(List<Property> result) { 041 for (String s : properties.keySet()) { 042 result.add(new Property(s, "Base", null, 0, 1, properties.get(s))); 043 } 044 } 045 046 @Override 047 public String getIdBase() { 048 return null; 049 } 050 051 @Override 052 public void setIdBase(String value) { 053 } 054 055 public void addProperty(String s, List<Base> list) { 056 properties.put(s, list); 057 } 058 059 public Base[] listChildrenByName(String name, boolean checkValid) throws FHIRException { 060 if (name.equals("*")) { 061 List<Property> children = new ArrayList<Property>(); 062 listChildren(children); 063 List<Base> result = new ArrayList<Base>(); 064 for (Property c : children) 065 result.addAll(c.getValues()); 066 return result.toArray(new Base[result.size()]); 067 } else if (properties.containsKey(name)) { 068 return properties.get(name).toArray(new Base[0]); 069 } 070 return getProperty(name.hashCode(), name, checkValid); 071 } 072 073 074}