001package org.hl7.fhir.r4.model; 002 003import java.util.ArrayList; 004import java.util.HashMap; 005import java.util.List; 006import java.util.Map; 007 008import org.hl7.fhir.exceptions.FHIRException; 009 010public class Tuple extends Base { 011 private Map<String, List<Base>> properties = new HashMap<>(); 012 013 @Override 014 public String fhirType() { 015 return "Tuple"; 016 } 017 018 @Override 019 protected void listChildren(List<Property> result) { 020 for (String s : properties.keySet()) { 021 result.add(new Property(s, "Base", null, 0, 1, properties.get(s))); 022 } 023 } 024 025 @Override 026 public String getIdBase() { 027 return null; 028 } 029 030 @Override 031 public void setIdBase(String value) { 032 } 033 034 public void addProperty(String s, List<Base> list) { 035 properties.put(s, list); 036 } 037 038 public Base[] listChildrenByName(String name, boolean checkValid) throws FHIRException { 039 if (name.equals("*")) { 040 List<Property> children = new ArrayList<Property>(); 041 listChildren(children); 042 List<Base> result = new ArrayList<Base>(); 043 for (Property c : children) 044 result.addAll(c.getValues()); 045 return result.toArray(new Base[result.size()]); 046 } else if (properties.containsKey(name)) { 047 return properties.get(name).toArray(new Base[0]); 048 } 049 return getProperty(name.hashCode(), name, checkValid); 050 } 051 052 053}