001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.marshall.cbor;
018
019import static java.lang.annotation.ElementType.*;
020import static java.lang.annotation.RetentionPolicy.*;
021
022import java.lang.annotation.*;
023
024import org.apache.juneau.marshall.*;
025
026/**
027 * Annotation for specifying config properties defined in {@link CborSerializer} and {@link CborParser}.
028 *
029 * <p>
030 * Used primarily for specifying bean configuration properties on REST classes and methods.
031 *
032 * <h5 class='section'>See Also:</h5><ul>
033 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/Cbor">CBOR</a>
034 * </ul>
035 */
036@Target({ TYPE, METHOD })
037@Retention(RUNTIME)
038@Inherited
039@ContextApply({ CborConfigAnnotation.SerializerApply.class, CborConfigAnnotation.ParserApply.class })
040public @interface CborConfig {
041
042   /**
043    * Add <js>"_type"</js> properties when needed.
044    *
045    * <p>
046    * If <js>"true"</js>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred
047    * through reflection.
048    *
049    * <ul class='values'>
050    *    <li><js>"true"</js>
051    *    <li><js>"false"</js> (default)
052    * </ul>
053    *
054    * @return The annotation value.
055    */
056   String addBeanTypes() default "";
057
058   /**
059    * Use CBOR semantic tags for dates and other typed values.
060    *
061    * <ul class='values'>
062    *    <li><js>"true"</js>
063    *    <li><js>"false"</js> (default)
064    * </ul>
065    *
066    * @return The annotation value.
067    */
068   String useTags() default "";
069
070   /**
071    * Maximum allowed wire-declared length for CBOR byte/text strings and array/map element counts when parsing.
072    *
073    * <p>
074    * Guards against malformed or adversarial input where a small payload declares a huge length or element count.
075    * Default is <js>"16777216"</js> (16 MiB). A value of <js>"0"</js> or less disables the cap.
076    *
077    * @return The annotation value.
078    */
079   String maxLength() default "";
080
081   /**
082    * Optional rank for this config.
083    *
084    * @return The annotation value.
085    */
086   int rank() default 0;
087}