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.IBase; 028 029import ca.uhn.fhir.model.primitive.StringDt; 030import ca.uhn.fhir.rest.param.StringParam; 031 032/** 033 */ 034@Retention(RetentionPolicy.RUNTIME) 035@Target(value=ElementType.PARAMETER) 036public @interface OperationParam { 037 038 /** 039 * Value for {@link OperationParam#max()} indicating no maximum 040 */ 041 int MAX_UNLIMITED = -1; 042 043 044 /** 045 * Value for {@link OperationParam#max()} indicating that the maximum will be inferred 046 * from the type. If the type is a single parameter type (e.g. <code>StringDt</code>, 047 * <code>TokenParam</code>, <code>IBaseResource</code>) the maximum will be 048 * <code>1</code>. 049 * <p> 050 * If the type is a collection, e.g. 051 * <code>List<StringDt></code> or <code>List<TokenOrListParam></code> 052 * the maximum will be set to <code>*</code>. If the param is a search parameter 053 * "and" type, such as <code>TokenAndListParam</code> the maximum will also be 054 * set to <code>*</code> 055 * </p> 056 * 057 * @since 1.5 058 */ 059 int MAX_DEFAULT = -2; 060 061 /** 062 * The name of the parameter 063 */ 064 String name(); 065 066 /** 067 * The type of the parameter. This will only have effect on <code>@OperationParam</code> 068 * annotations specified as values for {@link Operation#returnParameters()}, otherwise the 069 * value will be ignored. Value should be one of: 070 * <ul> 071 * <li>A resource type, e.g. <code>Patient.class</code></li> 072 * <li>A datatype, e.g. <code>{@link StringDt}.class</code> or </code>CodeableConceptDt.class</code> 073 * <li>A RESTful search parameter type, e.g. <code>{@link StringParam}.class</code> 074 * </ul> 075 */ 076 Class<? extends IBase> type() default IBase.class; 077 078 /** 079 * Optionally specifies the type of the parameter as a string, such as <code>Coding</code> or 080 * <code>base64Binary</code>. This can be useful if you want to use a generic interface type 081 * on the actual method,such as {@link org.hl7.fhir.instance.model.api.IPrimitiveType} or 082 * {@link @org.hl7.fhir.instance.model.api.ICompositeType}. 083 */ 084 String typeName() default ""; 085 086 /** 087 * The minimum number of repetitions allowed for this child (default is 0) 088 */ 089 int min() default 0; 090 091 /** 092 * The maximum number of repetitions allowed for this child. Should be 093 * set to {@link #MAX_UNLIMITED} if there is no limit to the number of 094 * repetitions. See {@link #MAX_DEFAULT} for a description of the default 095 * behaviour. 096 */ 097 int max() default MAX_DEFAULT; 098 099 100}