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 - 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.util.ArrayList;
024import java.util.List;
025
026import ca.uhn.fhir.model.api.IDatatype;
027import ca.uhn.fhir.model.api.IResource;
028import ca.uhn.fhir.model.api.annotation.Child;
029import ca.uhn.fhir.model.api.annotation.DatatypeDef;
030import ca.uhn.fhir.model.base.composite.BaseContainedDt;
031
032@DatatypeDef(name = "contained")
033public class ContainedDt extends BaseContainedDt {
034
035        @Child(name = "resource", type = IResource.class, order = 0, min = 0, max = Child.MAX_UNLIMITED)
036        private List<IResource> myContainedResources;
037
038        @Override
039        public List<IResource> getContainedResources() {
040                if (myContainedResources == null) {
041                        myContainedResources = new ArrayList<IResource>();
042                }
043                return myContainedResources;
044        }
045
046        public void setContainedResources(List<IResource> theContainedResources) {
047                myContainedResources = theContainedResources;
048        }
049
050        @Override
051        public boolean isEmpty() {
052                return myContainedResources == null || myContainedResources.size() == 0;
053        }
054
055        @Override
056        public Object getUserData(String theName) {
057                throw new UnsupportedOperationException();
058        }
059
060        @Override
061        public void setUserData(String theName, Object theValue) {
062                throw new UnsupportedOperationException();
063        }
064
065}