001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.msgpack.annotation;
014
015import static java.lang.annotation.ElementType.*;
016import static java.lang.annotation.RetentionPolicy.*;
017
018import java.lang.annotation.*;
019
020import org.apache.juneau.annotation.*;
021import org.apache.juneau.msgpack.*;
022import org.apache.juneau.serializer.*;
023
024/**
025 * Annotation for specifying config properties defined in {@link MsgPackSerializer} and {@link MsgPackParser}.
026 *
027 * <p>
028 * Used primarily for specifying bean configuration properties on REST classes and methods.
029 */
030@Documented
031@Target({TYPE,METHOD})
032@Retention(RUNTIME)
033@Inherited
034@PropertyStoreApply(MsgPackConfigApply.class)
035public @interface MsgPackConfig {
036
037   /**
038    * Optional rank for this config.
039    *
040    * <p>
041    * Can be used to override default ordering and application of config annotations.
042    */
043   int rank() default 0;
044
045   //-------------------------------------------------------------------------------------------------------------------
046   // MsgPackCommon
047   //-------------------------------------------------------------------------------------------------------------------
048
049   /**
050    * Dynamically applies {@link MsgPack @MsgPack} annotations to specified classes/methods/fields.
051    *
052    * <p>
053    * Provides an alternate approach for applying annotations using {@link MsgPack#on() @MsgPack.on} to specify the names
054    * to apply the annotation to.
055    *
056    * <ul class='seealso'>
057    *    <li class='link'>{@doc DynamicallyAppliedAnnotations}
058    * </ul>
059    */
060   MsgPack[] applyMsgPack() default {};
061
062   //-------------------------------------------------------------------------------------------------------------------
063   // MsgPackSerializer
064   //-------------------------------------------------------------------------------------------------------------------
065
066   /**
067    * Configuration property:  Add <js>"_type"</js> properties when needed.
068    *
069    * <p>
070    * If <js>"true"</js>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred
071    * through reflection.
072    *
073    * <p>
074    * When present, this value overrides the {@link Serializer#SERIALIZER_addBeanTypes} setting and is
075    * provided to customize the behavior of specific serializers in a {@link SerializerGroup}.
076    *
077    * <ul class='notes'>
078    *    <li>
079    *       Possible values:
080    *       <ul>
081    *          <li><js>"true"</js>
082    *          <li><js>"false"</js> (default)
083    *       </ul>
084    *    <li>
085    *       Supports {@doc DefaultVarResolver} (e.g. <js>"$C{myConfigVar}"</js>).
086    * </ul>
087    *
088    * <ul class='seealso'>
089    *    <li class='jf'>{@link MsgPackSerializer#MSGPACK_addBeanTypes}
090    * </ul>
091    */
092   String addBeanTypes() default "";
093}