001/* 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2023 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.rest.annotation; 021 022import java.lang.annotation.ElementType; 023import java.lang.annotation.Retention; 024import java.lang.annotation.RetentionPolicy; 025import java.lang.annotation.Target; 026 027import org.hl7.fhir.instance.model.api.IBaseResource; 028 029import ca.uhn.fhir.model.api.IResource; 030import ca.uhn.fhir.model.api.TagList; 031import ca.uhn.fhir.model.primitive.IdDt; 032 033/** 034 * RESTful method annotation to be used for the FHIR <a 035 * href="http://hl7.org/implement/standards/fhir/http.html#tags">Tag 036 * Operations</a> which have to do with adding tags. 037 * <ul> 038 * <li> 039 * To add tag(s) <b>to the given resource 040 * instance</b>, this annotation should contain a {@link #type()} attribute 041 * specifying the resource type, and the method should have a parameter of type 042 * {@link IdDt} annotated with the {@link IdParam} annotation, as well as 043 * a parameter of type {@link TagList}. Note that this {@link TagList} parameter 044 * does not need to contain a complete list of tags for the resource, only a list 045 * of tags to be added. Server implementations must not remove tags based on this 046 * operation. 047 * Note that for a 048 * server implementation, the {@link #type()} annotation is optional if the 049 * method is defined in a <a href= 050 * "https://hapifhir.io/hapi-fhir/docs/server_plain/resource_providers.html" 051 * >resource provider</a>, since the type is implied.</li> 052 * <li> 053 * To add tag(s) on the server <b>to the given version of the 054 * resource instance</b>, this annotation should contain a {@link #type()} 055 * attribute specifying the resource type, and the method should have a 056 * parameter of type {@link IdDt} annotated with the {@link VersionIdParam} 057 * annotation, <b>and</b> a parameter of type {@link IdDt} annotated with the 058 * {@link IdParam} annotation, as well as 059 * a parameter of type {@link TagList}. Note that this {@link TagList} parameter 060 * does not need to contain a complete list of tags for the resource, only a list 061 * of tags to be added. Server implementations must not remove tags based on this 062 * operation. 063 * Note that for a server implementation, the 064 * {@link #type()} annotation is optional if the method is defined in a <a href= 065 * "https://hapifhir.io/hapi-fhir/docs/server_plain/resource_providers.html" 066 * >resource provider</a>, since the type is implied.</li> 067 * </ul> 068 */ 069@Target(value= ElementType.METHOD) 070@Retention(value=RetentionPolicy.RUNTIME) 071public @interface AddTags { 072 073 /** 074 * If set to a type other than the default (which is {@link IResource} 075 * , this method is expected to return a TagList containing only tags which 076 * are specific to the given resource type. 077 */ 078 Class<? extends IBaseResource> type() default IBaseResource.class; 079 080 /** 081 * This method allows the return type for this method to be specified in a 082 * non-type-specific way, using the text name of the resource, e.g. "Patient". 083 * 084 * This attribute should be populate, or {@link #type()} should be, but not both. 085 * 086 * @since 5.4.0 087 */ 088 String typeName() default ""; 089}