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