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.toml;
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 TomlSerializer} and {@link TomlParser}.
028 *
029 * <p>
030 * Used primarily for specifying bean configuration properties on REST classes and methods.
031 *
032 * <h5 class='section'>Example:</h5>
033 * <p class='bjava'>
034 *    <ja>@TomlConfig</ja>(sortKeys=<js>"true"</js>, inlineTableThreshold=<js>"5"</js>, nullValue=<js>"~"</js>)
035 *    <jk>public class</jk> MyRestClass {}
036 * </p>
037 */
038@Target({ TYPE, METHOD })
039@Retention(RUNTIME)
040@Inherited
041@ContextApply({ TomlConfigAnnotation.SerializerApply.class, TomlConfigAnnotation.ParserApply.class })
042public @interface TomlConfig {
043
044   /**
045    * String written for null values; the parser treats values matching this string as null.
046    *
047    * <p>
048    * An empty value (the default) leaves the builder default of <js>"&lt;NULL&gt;"</js> in place.
049    * Applied to both {@link TomlSerializer} and {@link TomlParser}.
050    *
051    * <h5 class='section'>Notes:</h5><ul>
052    *    <li class='note'>
053    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
054    * </ul>
055    *
056    * <h5 class='section'>See Also:</h5><ul>
057    *    <li class='jm'>{@link TomlSerializer.Builder#nullValue(String)}
058    *    <li class='jm'>{@link TomlParser.Builder#nullValue(String)}
059    * </ul>
060    *
061    * @return The annotation value.
062    */
063   String nullValue() default "";
064
065   /**
066    * Maximum number of properties for a table to be written in inline-table format.
067    *
068    * <p>
069    * An empty value (the default) leaves the builder default in place.
070    *
071    * <h5 class='section'>Notes:</h5><ul>
072    *    <li class='note'>
073    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
074    * </ul>
075    *
076    * <h5 class='section'>See Also:</h5><ul>
077    *    <li class='jm'>{@link TomlSerializer.Builder#inlineTableThreshold(int)}
078    * </ul>
079    *
080    * @return The annotation value.
081    */
082   String inlineTableThreshold() default "";
083
084   /**
085    * Use inline tables when possible.
086    *
087    * <ul class='values'>
088    *    <li><js>"true"</js>
089    *    <li><js>"false"</js>
090    * </ul>
091    *
092    * <h5 class='section'>Notes:</h5><ul>
093    *    <li class='note'>
094    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
095    * </ul>
096    *
097    * <h5 class='section'>See Also:</h5><ul>
098    *    <li class='jm'>{@link TomlSerializer.Builder#useInlineTables(boolean)}
099    * </ul>
100    *
101    * @return The annotation value.
102    */
103   String useInlineTables() default "";
104
105   /**
106    * Sort keys alphabetically in output.
107    *
108    * <ul class='values'>
109    *    <li><js>"true"</js>
110    *    <li><js>"false"</js>
111    * </ul>
112    *
113    * <h5 class='section'>Notes:</h5><ul>
114    *    <li class='note'>
115    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
116    * </ul>
117    *
118    * <h5 class='section'>See Also:</h5><ul>
119    *    <li class='jm'>{@link TomlSerializer.Builder#sortKeys(boolean)}
120    * </ul>
121    *
122    * @return The annotation value.
123    */
124   String sortKeys() default "";
125
126   /**
127    * Optional rank for this config.
128    *
129    * <p>
130    * Can be used to override default ordering and application of config annotations.
131    *
132    * @return The annotation value.
133    */
134   int rank() default 0;
135}