001package ca.uhn.fhir.model.dstu2.composite; 002 003/* 004 * #%L 005 * HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) 006 * %% 007 * Copyright (C) 2014 - 2022 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 ca.uhn.fhir.i18n.Msg; 024import java.util.ArrayList; 025import java.util.List; 026 027import ca.uhn.fhir.model.api.IDatatype; 028import ca.uhn.fhir.model.api.IResource; 029import ca.uhn.fhir.model.api.annotation.Child; 030import ca.uhn.fhir.model.api.annotation.DatatypeDef; 031import ca.uhn.fhir.model.base.composite.BaseContainedDt; 032 033@DatatypeDef(name = "contained") 034public class ContainedDt extends BaseContainedDt { 035 036 @Child(name = "resource", type = IResource.class, order = 0, min = 0, max = Child.MAX_UNLIMITED) 037 private List<IResource> myContainedResources; 038 039 @Override 040 public List<IResource> getContainedResources() { 041 if (myContainedResources == null) { 042 myContainedResources = new ArrayList<IResource>(); 043 } 044 return myContainedResources; 045 } 046 047 public void setContainedResources(List<IResource> theContainedResources) { 048 myContainedResources = theContainedResources; 049 } 050 051 @Override 052 public boolean isEmpty() { 053 return myContainedResources == null || myContainedResources.size() == 0; 054 } 055 056 @Override 057 public Object getUserData(String theName) { 058 throw new UnsupportedOperationException(Msg.code(580)); 059 } 060 061 @Override 062 public void setUserData(String theName, Object theValue) { 063 throw new UnsupportedOperationException(Msg.code(581)); 064 } 065 066}