001/*-
002 * #%L
003 * HAPI FHIR Storage api
004 * %%
005 * Copyright (C) 2014 - 2024 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.jpa.api.pid;
021
022import ca.uhn.fhir.i18n.Msg;
023import ca.uhn.fhir.interceptor.model.RequestPartitionId;
024import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
025import jakarta.annotation.Nonnull;
026
027import java.util.Collections;
028import java.util.Date;
029import java.util.List;
030
031/**
032 * An empty resource pid list
033 */
034public class EmptyResourcePidList implements IResourcePidList {
035        @Override
036        public RequestPartitionId getRequestPartitionId() {
037                return null;
038        }
039
040        @Override
041        public Date getLastDate() {
042                return null;
043        }
044
045        @Override
046        public int size() {
047                return 0;
048        }
049
050        @Nonnull
051        @Override
052        public List<TypedResourcePid> getTypedResourcePids() {
053                return Collections.emptyList();
054        }
055
056        @Override
057        public String getResourceType(int i) {
058                throw new ArrayIndexOutOfBoundsException(
059                                Msg.code(2095) + "Attempting to get resource type from an empty resource pid list");
060        }
061
062        @Override
063        public List<IResourcePersistentId> getIds() {
064                return Collections.emptyList();
065        }
066
067        @Override
068        public boolean isEmpty() {
069                return true;
070        }
071
072        @Override
073        public String toString() {
074                return "[empty]";
075        }
076}