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.csv.annotation; 018 019import static java.lang.annotation.ElementType.*; 020import static java.lang.annotation.RetentionPolicy.*; 021 022import java.lang.annotation.*; 023 024import org.apache.juneau.annotation.*; 025import org.apache.juneau.csv.*; 026 027/** 028 * Annotation that can be applied to classes, fields, and methods to tweak how they are handled by {@link CsvSerializer} and {@link CsvParser}. 029 * 030 * <p> 031 * Can be used in the following locations: 032 * <ul> 033 * <li>Marshalled classes/methods/fields. 034 * <li><ja>@Rest</ja>-annotated classes and <ja>@RestOp</ja>-annotated methods when an {@link #on()} value is specified. 035 * </ul> 036 * 037 * <h5 class='section'>See Also:</h5><ul> 038 039 * </ul> 040 */ 041@Documented 042@Target({TYPE,FIELD,METHOD}) 043@Retention(RUNTIME) 044@Inherited 045@Repeatable(CsvAnnotation.Array.class) 046@ContextApply(CsvAnnotation.Apply.class) 047public @interface Csv { 048 049 /** 050 * Optional description for the exposed API. 051 * 052 * @return The annotation value. 053 * @since 9.2.0 054 */ 055 String[] description() default {}; 056 057 /** 058 * Dynamically apply this annotation to the specified classes/methods/fields. 059 * 060 * <p> 061 * Used in conjunction with {@link org.apache.juneau.BeanContext.Builder#applyAnnotations(Class...)} to dynamically apply an annotation to an existing class/method/field. 062 * It is ignored when the annotation is applied directly to classes/methods/fields. 063 * 064 * <h5 class='section'>Valid patterns:</h5> 065 * <ul class='spaced-list'> 066 * <li>Classes: 067 * <ul> 068 * <li>Fully qualified: 069 * <ul> 070 * <li><js>"com.foo.MyClass"</js> 071 * </ul> 072 * <li>Fully qualified inner class: 073 * <ul> 074 * <li><js>"com.foo.MyClass$Inner1$Inner2"</js> 075 * </ul> 076 * <li>Simple: 077 * <ul> 078 * <li><js>"MyClass"</js> 079 * </ul> 080 * <li>Simple inner: 081 * <ul> 082 * <li><js>"MyClass$Inner1$Inner2"</js> 083 * <li><js>"Inner1$Inner2"</js> 084 * <li><js>"Inner2"</js> 085 * </ul> 086 * </ul> 087 * <li>Methods: 088 * <ul> 089 * <li>Fully qualified with args: 090 * <ul> 091 * <li><js>"com.foo.MyClass.myMethod(String,int)"</js> 092 * <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js> 093 * <li><js>"com.foo.MyClass.myMethod()"</js> 094 * </ul> 095 * <li>Fully qualified: 096 * <ul> 097 * <li><js>"com.foo.MyClass.myMethod"</js> 098 * </ul> 099 * <li>Simple with args: 100 * <ul> 101 * <li><js>"MyClass.myMethod(String,int)"</js> 102 * <li><js>"MyClass.myMethod(java.lang.String,int)"</js> 103 * <li><js>"MyClass.myMethod()"</js> 104 * </ul> 105 * <li>Simple: 106 * <ul> 107 * <li><js>"MyClass.myMethod"</js> 108 * </ul> 109 * <li>Simple inner class: 110 * <ul> 111 * <li><js>"MyClass$Inner1$Inner2.myMethod"</js> 112 * <li><js>"Inner1$Inner2.myMethod"</js> 113 * <li><js>"Inner2.myMethod"</js> 114 * </ul> 115 * </ul> 116 * <li>Fields: 117 * <ul> 118 * <li>Fully qualified: 119 * <ul> 120 * <li><js>"com.foo.MyClass.myField"</js> 121 * </ul> 122 * <li>Simple: 123 * <ul> 124 * <li><js>"MyClass.myField"</js> 125 * </ul> 126 * <li>Simple inner class: 127 * <ul> 128 * <li><js>"MyClass$Inner1$Inner2.myField"</js> 129 * <li><js>"Inner1$Inner2.myField"</js> 130 * <li><js>"Inner2.myField"</js> 131 * </ul> 132 * </ul> 133 * <li>A comma-delimited list of anything on this list. 134 * </ul> 135 * 136\ * <h5 class='section'>See Also:</h5><ul> 137 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 138 * </ul> 139 * 140 * @return The annotation value. 141 */ 142 String[] on() default {}; 143 144 /** 145 * Dynamically apply this annotation to the specified classes. 146 * 147 * <p> 148 * Identical to {@link #on()} except allows you to specify class objects instead of a strings. 149 * 150 * <h5 class='section'>See Also:</h5><ul> 151 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 152 * </ul> 153 * 154 * @return The annotation value. 155 */ 156 Class<?>[] onClass() default {}; 157}