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.annotation; 018 019import static java.lang.annotation.ElementType.*; 020import static java.lang.annotation.RetentionPolicy.*; 021 022import java.io.*; 023import java.lang.annotation.*; 024import java.lang.reflect.*; 025import java.util.*; 026 027import org.apache.juneau.*; 028import org.apache.juneau.swap.*; 029 030/** 031 * Annotation for specifying config properties defined in {@link BeanContext} and {@link BeanTraverseContext}. 032 * 033 * <p> 034 * Used primarily for specifying bean configuration properties on REST classes and methods. 035 * 036 * <h5 class='section'>See Also:</h5><ul> 037 * </ul> 038 */ 039@Target({TYPE,METHOD}) 040@Retention(RUNTIME) 041@Inherited 042@ContextApply(BeanConfigAnnotation.Applier.class) 043public @interface BeanConfig { 044 045 /** 046 * Optional rank for this config. 047 * 048 * <p> 049 * Can be used to override default ordering and application of config annotations. 050 * 051 * @return The annotation value. 052 */ 053 int rank() default 0; 054 055 //----------------------------------------------------------------------------------------------------------------- 056 // BeanContext 057 //----------------------------------------------------------------------------------------------------------------- 058 059 /** 060 * Minimum bean class visibility. 061 * 062 * <p> 063 * Classes are not considered beans unless they meet the minimum visibility requirements. 064 * 065 * <p> 066 * For example, if the visibility is <c>PUBLIC</c> and the bean class is <jk>protected</jk>, then the class 067 * will not be interpreted as a bean class and be serialized as a string. 068 * <br>Use this setting to reduce the visibility requirement. 069 * 070 * <ul class='values'> 071 * <li><js>"PUBLIC"</js> (default) 072 * <li><js>"PROTECTED"</js> 073 * <li><js>"DEFAULT"</js> 074 * <li><js>"PRIVATE"</js> 075 * </ul> 076 * 077 * <h5 class='section'>Notes:</h5><ul> 078 * <li class='note'> 079 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 080 * </ul> 081 * 082 * <h5 class='section'>See Also:</h5><ul> 083 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beanClassVisibility(Visibility)} 084 * </ul> 085 * 086 * @return The annotation value. 087 */ 088 String beanClassVisibility() default ""; 089 090 /** 091 * Minimum bean constructor visibility. 092 * 093 * <p> 094 * Only look for constructors with the specified minimum visibility. 095 * 096 * <p> 097 * This setting affects the logic for finding no-arg constructors for bean. 098 * <br>Normally, only <jk>public</jk> no-arg constructors are used. 099 * <br>Use this setting if you want to reduce the visibility requirement. 100 * 101 * <ul class='values'> 102 * <li><js>"PUBLIC"</js> (default) 103 * <li><js>"PROTECTED"</js> 104 * <li><js>"DEFAULT"</js> 105 * <li><js>"PRIVATE"</js> 106 * </ul> 107 * 108 * <h5 class='section'>Notes:</h5><ul> 109 * <li class='note'> 110 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 111 * </ul> 112 * 113 * <h5 class='section'>See Also:</h5><ul> 114 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beanConstructorVisibility(Visibility)} 115 * </ul> 116 * 117 * @return The annotation value. 118 */ 119 String beanConstructorVisibility() default ""; 120 121 /** 122 * Minimum bean field visibility. 123 * 124 * <p> 125 * Only look for bean fields with the specified minimum visibility. 126 * 127 * <p> 128 * This affects which fields on a bean class are considered bean properties. 129 * <br>Normally only <jk>public</jk> fields are considered. 130 * <br>Use this setting if you want to reduce the visibility requirement. 131 * 132 * <ul class='values'> 133 * <li><js>"PUBLIC"</js> (default) 134 * <li><js>"PROTECTED"</js> 135 * <li><js>"DEFAULT"</js> 136 * <li><js>"PRIVATE"</js> 137 * </ul> 138 * 139 * <h5 class='section'>Notes:</h5><ul> 140 * <li class='note'> 141 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 142 * </ul> 143 * 144 * <h5 class='section'>See Also:</h5><ul> 145 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beanFieldVisibility(Visibility)} 146 * </ul> 147 * 148 * @return The annotation value. 149 */ 150 String beanFieldVisibility() default ""; 151 152 /** 153 * BeanMap.put() returns old property value. 154 * 155 * <p> 156 * If <js>"true"</js>, then the {@link BeanMap#put(String,Object) BeanMap.put()} method will return old property 157 * values. 158 * <br>Otherwise, it returns <jk>null</jk>. 159 * 160 * <ul class='values'> 161 * <li><js>"true"</js> 162 * <li><js>"false"</js> (default because it introduces a slight performance penalty during serialization) 163 * </ul> 164 * 165 * <h5 class='section'>Notes:</h5><ul> 166 * <li class='note'> 167 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 168 * </ul> 169 * 170 * <h5 class='section'>See Also:</h5><ul> 171 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beanMapPutReturnsOldValue()} 172 * </ul> 173 * 174 * @return The annotation value. 175 */ 176 String beanMapPutReturnsOldValue() default ""; 177 178 /** 179 * Minimum bean method visibility. 180 * 181 * <p> 182 * Only look for bean methods with the specified minimum visibility. 183 * 184 * <p> 185 * This affects which methods are detected as getters and setters on a bean class. 186 * <br>Normally only <jk>public</jk> getters and setters are considered. 187 * <br>Use this setting if you want to reduce the visibility requirement. 188 * 189 * <ul class='values'> 190 * <li><js>"PUBLIC"</js> (default) 191 * <li><js>"PROTECTED"</js> 192 * <li><js>"DEFAULT"</js> 193 * <li><js>"PRIVATE"</js> 194 * </ul> 195 * 196 * <h5 class='section'>Notes:</h5><ul> 197 * <li class='note'> 198 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 199 * </ul> 200 * 201 * <h5 class='section'>See Also:</h5><ul> 202 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beanMethodVisibility(Visibility)} 203 * </ul> 204 * 205 * @return The annotation value. 206 */ 207 String beanMethodVisibility() default ""; 208 209 /** 210 * Beans require no-arg constructors. 211 * 212 * <p> 213 * If <js>"true"</js>, a Java class must implement a default no-arg constructor to be considered a bean. 214 * <br>Otherwise, the bean will be serialized as a string using the {@link Object#toString()} method. 215 * 216 * <ul class='values'> 217 * <li><js>"true"</js> 218 * <li><js>"false"</js> (default) 219 * </ul> 220 * 221 * <h5 class='section'>Notes:</h5><ul> 222 * <li class='note'> 223 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 224 * <li class='note'> 225 * The {@link Bean @Bean} annotation can be used on a class to override this setting when <js>"true"</js>. 226 * </ul> 227 * 228 * <h5 class='section'>See Also:</h5><ul> 229 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beansRequireDefaultConstructor()} 230 * </ul> 231 * 232 * @return The annotation value. 233 */ 234 String beansRequireDefaultConstructor() default ""; 235 236 /** 237 * Beans require Serializable interface. 238 * 239 * <p> 240 * If <js>"true"</js>, a Java class must implement the {@link Serializable} interface to be considered a bean. 241 * <br>Otherwise, the bean will be serialized as a string using the {@link Object#toString()} method. 242 * 243 * <ul class='values'> 244 * <li><js>"true"</js> 245 * <li><js>"false"</js> (default) 246 * </ul> 247 * 248 * <h5 class='section'>Notes:</h5><ul> 249 * <li class='note'> 250 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 251 * <li class='note'> 252 * The {@link Bean @Bean} annotation can be used on a class to override this setting when <js>"true"</js>. 253 * </ul> 254 * 255 * <h5 class='section'>See Also:</h5><ul> 256 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beansRequireSerializable()} 257 * </ul> 258 * 259 * @return The annotation value. 260 */ 261 String beansRequireSerializable() default ""; 262 263 /** 264 * Beans require setters for getters. 265 * 266 * <p> 267 * If <js>"true"</js>, only getters that have equivalent setters will be considered as properties on a bean. 268 * <br>Otherwise, they will be ignored. 269 * 270 * <ul class='values'> 271 * <li><js>"true"</js> 272 * <li><js>"false"</js> (default) 273 * </ul> 274 * 275 * <h5 class='section'>Notes:</h5><ul> 276 * <li class='note'> 277 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 278 * </ul> 279 * 280 * <h5 class='section'>See Also:</h5><ul> 281 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beansRequireSettersForGetters()} 282 * </ul> 283 * 284 * @return The annotation value. 285 */ 286 String beansRequireSettersForGetters() default ""; 287 288 /** 289 * Beans don't require at least one property. 290 * 291 * <p> 292 * If <js>"true"</js>, then a Java class doesn't need to contain at least 1 property to be considered a bean. 293 * <br>Otherwise, the bean will be serialized as a string using the {@link Object#toString()} method. 294 * 295 * <ul class='values'> 296 * <li><js>"true"</js> 297 * <li><js>"false"</js> (default) 298 * </ul> 299 * 300 * <h5 class='section'>Notes:</h5><ul> 301 * <li class='note'> 302 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 303 * </ul> 304 * 305 * <h5 class='section'>See Also:</h5><ul> 306 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#disableBeansRequireSomeProperties()} 307 * </ul> 308 * 309 * @return The annotation value. 310 */ 311 String disableBeansRequireSomeProperties() default ""; 312 313 /** 314 * Bean type property name. 315 * 316 * <p> 317 * This specifies the name of the bean property used to store the dictionary name of a bean type so that the 318 * parser knows the data type to reconstruct. 319 * 320 * <h5 class='section'>Notes:</h5><ul> 321 * <li class='note'> 322 * Default value: <js>"_type"</js>. 323 * <li class='note'> 324 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 325 * </ul> 326 327 * <h5 class='section'>See Also:</h5><ul> 328 * <li class='ja'>{@link Bean#typePropertyName()} 329 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#typePropertyName(String)} 330 * </ul> 331 * 332 * @return The annotation value. 333 */ 334 String typePropertyName() default ""; 335 336 /** 337 * Debug mode. 338 * 339 * <p> 340 * Enables the following additional information during serialization: 341 * <ul class='spaced-list'> 342 * <li> 343 * When bean getters throws exceptions, the exception includes the object stack information 344 * in order to determine how that method was invoked. 345 * <li> 346 * Enables {@link org.apache.juneau.BeanTraverseContext.Builder#detectRecursions()}. 347 * </ul> 348 * 349 * <p> 350 * Enables the following additional information during parsing: 351 * <ul class='spaced-list'> 352 * <li> 353 * When bean setters throws exceptions, the exception includes the object stack information 354 * in order to determine how that method was invoked. 355 * </ul> 356 * 357 * <ul class='values'> 358 * <li><js>"true"</js> 359 * <li><js>"false"</js> (default) 360 * </ul> 361 * 362 * <h5 class='section'>Notes:</h5><ul> 363 * <li class='note'> 364 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 365 * </ul> 366 * 367 * <h5 class='section'>See Also:</h5><ul> 368 * <li class='jm'>{@link org.apache.juneau.Context.Builder#debug()} 369 * </ul> 370 * 371 * @return The annotation value. 372 */ 373 String debug() default ""; 374 375 /** 376 * Bean dictionary. 377 * 378 * <p> 379 * The list of classes that make up the bean dictionary in this bean context. 380 * 381 * <p> 382 * A dictionary is a name/class mapping used to find class types during parsing when they cannot be inferred 383 * through reflection. 384 * <br>The names are defined through the {@link Bean#typeName() @Bean(typeName)} annotation defined on the bean class. 385 * <br>For example, if a class <c>Foo</c> has a type-name of <js>"myfoo"</js>, then it would end up serialized 386 * as <js>"{_type:'myfoo',...}"</js>. 387 * 388 * <p> 389 * This setting tells the parsers which classes to look for when resolving <js>"_type"</js> attributes. 390 * 391 * <h5 class='section'>See Also:</h5><ul> 392 * <li class='ja'>{@link Bean#dictionary()} 393 * <li class='ja'>{@link Beanp#dictionary()} 394 * <li class='ja'>{@link BeanConfig#dictionary_replace()} 395 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beanDictionary(Class...)} 396 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/BeanDictionaryBasics">Bean Dictionary Basics</a> 397 * </ul> 398 * 399 * @return The annotation value. 400 */ 401 Class<?>[] dictionary() default {}; 402 403 /** 404 * Replace bean dictionary. 405 * 406 * <p> 407 * Same as {@link #dictionary()} but replaces any existing value. 408 * 409 * <h5 class='section'>See Also:</h5><ul> 410 * <li class='ja'>{@link Bean#dictionary()} 411 * <li class='ja'>{@link Beanp#dictionary()} 412 * <li class='ja'>{@link BeanConfig#dictionary()} 413 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#beanDictionary(Class...)} 414 * </ul> 415 * 416 * @return The annotation value. 417 */ 418 Class<?>[] dictionary_replace() default {}; 419 420 /** 421 * Find fluent setters. 422 * 423 * <p> 424 * When enabled, fluent setters are detected on beans. 425 * 426 * <p> 427 * Fluent setters must have the following attributes: 428 * <ul> 429 * <li>Public. 430 * <li>Not static. 431 * <li>Take in one parameter. 432 * <li>Return the bean itself. 433 * </ul> 434 * 435 * <ul class='values'> 436 * <li><js>"true"</js> 437 * <li><js>"false"</js> (default) 438 * </ul> 439 * 440 * <h5 class='section'>Notes:</h5><ul> 441 * <li class='note'> 442 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 443 * </ul> 444 * 445 * <h5 class='section'>See Also:</h5><ul> 446 * <li class='ja'>{@link Bean#findFluentSetters()} 447 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#findFluentSetters()} 448 * </ul> 449 * 450 * @return The annotation value. 451 */ 452 String findFluentSetters() default ""; 453 454 /** 455 * Ignore invocation errors on getters. 456 * 457 * <p> 458 * If <js>"true"</js>, errors thrown when calling bean getter methods will silently be ignored. 459 * <br>Otherwise, a {@code BeanRuntimeException} is thrown. 460 * 461 * <ul class='values'> 462 * <li><js>"true"</js> 463 * <li><js>"false"</js> (default) 464 * </ul> 465 * 466 * <h5 class='section'>Notes:</h5><ul> 467 * <li class='note'> 468 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 469 * </ul> 470 * 471 * <h5 class='section'>See Also:</h5><ul> 472 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#ignoreInvocationExceptionsOnGetters()} 473 * </ul> 474 * 475 * @return The annotation value. 476 */ 477 String ignoreInvocationExceptionsOnGetters() default ""; 478 479 /** 480 * Ignore invocation errors on setters. 481 * 482 * <p> 483 * If <js>"true"</js>, errors thrown when calling bean setter methods will silently be ignored. 484 * <br>Otherwise, a {@code BeanRuntimeException} is thrown. 485 * 486 * <ul class='values'> 487 * <li><js>"true"</js> 488 * <li><js>"false"</js> (default) 489 * </ul> 490 * 491 * <h5 class='section'>Notes:</h5><ul> 492 * <li class='note'> 493 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 494 * </ul> 495 * 496 * <h5 class='section'>See Also:</h5><ul> 497 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#ignoreInvocationExceptionsOnSetters()} 498 * </ul> 499 * 500 * @return The annotation value. 501 */ 502 String ignoreInvocationExceptionsOnSetters() default ""; 503 504 /** 505 * Don't silently ignore missing setters. 506 * 507 * <p> 508 * If <js>"true"</js>, trying to set a value on a bean property without a setter will throw a {@code BeanRuntimeException}. 509 * <br>Otherwise it will be sliently ignored. 510 * 511 * <ul class='values'> 512 * <li><js>"true"</js> 513 * <li><js>"false"</js> (default) 514 * </ul> 515 * 516 * <h5 class='section'>Notes:</h5><ul> 517 * <li class='note'> 518 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 519 * </ul> 520 * 521 * <h5 class='section'>See Also:</h5><ul> 522 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#disableIgnoreMissingSetters()} 523 * </ul> 524 * 525 * @return The annotation value. 526 */ 527 String disableIgnoreMissingSetters() default ""; 528 529 /** 530 * Don't ignore transient fields. 531 * 532 * <p> 533 * If <jk>true</jk>, methods and fields marked as <jk>transient</jk> will not be ignored as bean properties. 534 * 535 * <ul class='values'> 536 * <li><js>"true"</js> 537 * <li><js>"false"</js> (default) 538 * </ul> 539 * 540 * <h5 class='section'>Notes:</h5><ul> 541 * <li class='note'> 542 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 543 * </ul> 544 * 545 * <h5 class='section'>See Also:</h5><ul> 546 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#disableIgnoreTransientFields()} 547 * </ul> 548 * 549 * @return The annotation value. 550 */ 551 String disableIgnoreTransientFields() default ""; 552 553 /** 554 * Ignore unknown properties. 555 * 556 * <p> 557 * If <js>"true"</js>, trying to set a value on a non-existent bean property will silently be ignored. 558 * <br>Otherwise, a {@code RuntimeException} is thrown. 559 * 560 * <ul class='values'> 561 * <li><js>"true"</js> 562 * <li><js>"false"</js> (default) 563 * </ul> 564 * 565 * <h5 class='section'>Notes:</h5><ul> 566 * <li class='note'> 567 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 568 * </ul> 569 * 570 * <h5 class='section'>See Also:</h5><ul> 571 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#ignoreUnknownBeanProperties()} 572 * </ul> 573 * 574 * @return The annotation value. 575 */ 576 String ignoreUnknownBeanProperties() default ""; 577 578 /** 579 * Ignore unknown enum values. 580 * 581 * <p> 582 * If <js>"true"</js>, unknown enum values are set to <jk>null</jk> instead of throwing an exception. 583 * 584 * <ul class='values'> 585 * <li><js>"true"</js> 586 * <li><js>"false"</js> (default) 587 * </ul> 588 * 589 * <h5 class='section'>Notes:</h5><ul> 590 * <li class='note'> 591 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 592 * </ul> 593 * 594 * <h5 class='section'>See Also:</h5><ul> 595 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#ignoreUnknownEnumValues()} 596 * </ul> 597 * 598 * @return The annotation value. 599 */ 600 String ignoreUnknownEnumValues() default ""; 601 602 /** 603 * Don't ignore unknown properties with null values. 604 * 605 * <p> 606 * If <js>"true"</js>, trying to set a <jk>null</jk> value on a non-existent bean property will throw a {@code BeanRuntimeException}. 607 * Otherwise it will be silently ignored. 608 * 609 * <ul class='values'> 610 * <li><js>"true"</js> 611 * <li><js>"false"</js> (default) 612 * </ul> 613 * 614 * <h5 class='section'>Notes:</h5><ul> 615 * <li class='note'> 616 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 617 * </ul> 618 * 619 * <h5 class='section'>See Also:</h5><ul> 620 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#disableIgnoreUnknownNullBeanProperties()} 621 * </ul> 622 * 623 * @return The annotation value. 624 */ 625 String disableIgnoreUnknownNullBeanProperties() default ""; 626 627 /** 628 * Identifies a set of interfaces. 629 * 630 * <p> 631 * When specified, only the list of properties defined on the interface class will be used during serialization 632 * of implementation classes. Additional properties on subclasses will be ignored. 633 * 634 * <p class='bjava'> 635 * <jc>// Parent class or interface</jc> 636 * <jk>public abstract class</jk> A { 637 * <jk>public</jk> String <jf>foo</jf> = <js>"foo"</js>; 638 * } 639 * 640 * <jc>// Sub class</jc> 641 * <jk>public class</jk> A1 <jk>extends</jk> A { 642 * <jk>public</jk> String <jf>bar</jf> = <js>"bar"</js>; 643 * } 644 * 645 * <jc>// Apply it to a config</jc> 646 * <ja>@BeanConfig</ja>( 647 * interfaces={ 648 * A.<jk>class</jk> 649 * } 650 * ) 651 * </p> 652 * 653 * <p> 654 * This annotation can be used on the parent class so that it filters to all child classes, or can be set 655 * individually on the child classes. 656 * 657 * <h5 class='section'>Notes:</h5><ul> 658 * <li class='note'>The {@link Bean#interfaceClass() @Bean(interfaceClass)} annotation is the equivalent annotation-based solution. 659 * </ul> 660 * 661 * @return The annotation value. 662 */ 663 Class<?>[] interfaces() default {}; 664 665 /** 666 * Locale. 667 * 668 * <p> 669 * Specifies the default locale for serializer and parser sessions. 670 * 671 * <h5 class='section'>Notes:</h5><ul> 672 * <li class='note'> 673 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 674 * </ul> 675 * 676 * <h5 class='section'>See Also:</h5><ul> 677 * <li class='jm'>{@link org.apache.juneau.BeanSession.Builder#locale(Locale)} 678 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#locale(Locale)} 679 * </ul> 680 * 681 * @return The annotation value. 682 */ 683 String locale() default ""; 684 685 /** 686 * Media type. 687 * 688 * <p> 689 * Specifies the default media type value for serializer and parser sessions. 690 * 691 * <h5 class='section'>Notes:</h5><ul> 692 * <li class='note'> 693 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 694 * </ul> 695 * 696 * <h5 class='section'>See Also:</h5><ul> 697 * <li class='jm'>{@link org.apache.juneau.BeanSession.Builder#mediaType(MediaType)} 698 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#mediaType(MediaType)} 699 * </ul> 700 * 701 * @return The annotation value. 702 */ 703 String mediaType() default ""; 704 705 /** 706 * Bean class exclusions. 707 * 708 * <p> 709 * List of classes that should not be treated as beans even if they appear to be bean-like. 710 * <br>Not-bean classes are converted to <c>Strings</c> during serialization. 711 * 712 * <h5 class='section'>Notes:</h5><ul> 713 * <li class='note'> 714 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 715 * </ul> 716 * 717 * <h5 class='section'>See Also:</h5><ul> 718 * <li class='ja'>{@link BeanIgnore} 719 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#notBeanClasses(Class...)} 720 * </ul> 721 * 722 * @return The annotation value. 723 */ 724 Class<?>[] notBeanClasses() default {}; 725 726 /** 727 * Replace classes that should not be considered beans. 728 * 729 * <p> 730 * Same as {@link #notBeanClasses()} but replaces any existing value. 731 * 732 * <h5 class='section'>See Also:</h5><ul> 733 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#notBeanClasses(Class...)} 734 * </ul> 735 * 736 * @return The annotation value. 737 */ 738 Class<?>[] notBeanClasses_replace() default {}; 739 740 /** 741 * Bean package exclusions. 742 * 743 * <p> 744 * When specified, the current list of ignore packages are appended to. 745 * 746 * <p> 747 * Any classes within these packages will be serialized to strings using {@link Object#toString()}. 748 * 749 * <p> 750 * Note that you can specify suffix patterns to include all subpackages. 751 * 752 * <h5 class='section'>Notes:</h5><ul> 753 * <li class='note'> 754 * The default value excludes the following packages: 755 * <ul class='compact'> 756 * <li class='jp'><c>java.lang</c> 757 * <li class='jp'><c>java.lang.annotation</c> 758 * <li class='jp'><c>java.lang.ref</c> 759 * <li class='jp'><c>java.lang.reflect</c> 760 * <li class='jp'><c>java.io</c> 761 * <li class='jp'><c>java.net</c> 762 * <li class='jp'><c>java.nio.*</c> 763 * <li class='jp'><c>java.util.*</c> 764 * </ul> 765 * <li class='note'> 766 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 767 * </ul> 768 * 769 * <h5 class='section'>See Also:</h5><ul> 770 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#notBeanPackages(String...)} 771 * </ul> 772 * 773 * @return The annotation value. 774 */ 775 String[] notBeanPackages() default {}; 776 777 /** 778 * Replace packages whose classes should not be considered beans. 779 * 780 * <p> 781 * Same as {@link #notBeanPackages()} but replaces any existing value. 782 * 783 * <h5 class='section'>See Also:</h5><ul> 784 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#notBeanPackages(String...)} 785 * </ul> 786 * 787 * @return The annotation value. 788 */ 789 String[] notBeanPackages_replace() default {}; 790 791 /** 792 * Bean property namer. 793 * 794 * <p> 795 * The class to use for calculating bean property names. 796 * 797 * <p> 798 * Predefined classes: 799 * <ul> 800 * <li>{@link BasicPropertyNamer} (default) 801 * <li>{@link PropertyNamerDLC} - Dashed-lower-case names. 802 * <li>{@link PropertyNamerULC} - Dashed-upper-case names. 803 * </ul> 804 * 805 * <h5 class='section'>See Also:</h5><ul> 806 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#propertyNamer(Class)} 807 * </ul> 808 * 809 * @return The annotation value. 810 */ 811 Class<? extends PropertyNamer> propertyNamer() default PropertyNamer.Void.class; 812 813 /** 814 * Sort bean properties. 815 * 816 * <p> 817 * When <jk>true</jk>, all bean properties will be serialized and access in alphabetical order. 818 * <br>Otherwise, the natural order of the bean properties is used which is dependent on the JVM vendor. 819 * <br>On IBM JVMs, the bean properties are ordered based on their ordering in the Java file. 820 * <br>On Oracle JVMs, the bean properties are not ordered (which follows the official JVM specs). 821 * 822 * <p> 823 * This property is disabled by default so that IBM JVM users don't have to use {@link Bean @Bean} annotations 824 * to force bean properties to be in a particular order and can just alter the order of the fields/methods 825 * in the Java file. 826 * 827 * <ul class='values'> 828 * <li><js>"true"</js> 829 * <li><js>"false"</js> (default) 830 * </ul> 831 * 832 * <h5 class='section'>Notes:</h5><ul> 833 * <li> 834 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 835 * </ul> 836 * 837 * <h5 class='section'>See Also:</h5><ul> 838 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#sortProperties()} 839 * </ul> 840 * 841 * @return The annotation value. 842 */ 843 String sortProperties() default ""; 844 845 /** 846 * Java object swaps. 847 * 848 * <p> 849 * Swaps are used to "swap out" non-serializable classes with serializable equivalents during serialization, 850 * and "swap in" the non-serializable class during parsing. 851 * 852 * <p> 853 * An example of a swap would be a <c>Calendar</c> object that gets swapped out for an ISO8601 string. 854 * 855 * <p> 856 * Multiple swaps can be associated with a single class. 857 * <br>When multiple swaps are applicable to the same class, the media type pattern defined by 858 * {@link ObjectSwap#forMediaTypes()} or {@link Swap#mediaTypes() @Swap(mediaTypes)} are used to come up with the best match. 859 * 860 * <h5 class='section'>See Also:</h5><ul> 861 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#swaps(Class...)} 862 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/SwapBasics">Swap Basics</a> 863 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/PerMediaTypeSwaps">Per-media-type Swaps</a> 864 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/OneWaySwaps">One-way Swaps</a> 865 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/SwapAnnotation">@Swap Annotation</a> 866 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/AutoSwaps">Auto-detected swaps</a> 867 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/SurrogateClasses">Surrogate Classes</a> 868 * </ul> 869 * 870 * @return The annotation value. 871 */ 872 Class<?>[] swaps() default {}; 873 874 /** 875 * Replace Java object swap classes. 876 * 877 * <p> 878 * Same as {@link #swaps()} but replaces any existing value. 879 * 880 * <h5 class='section'>See Also:</h5><ul> 881 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#swaps(Class...)} 882 * </ul> 883 * 884 * @return The annotation value. 885 */ 886 Class<?>[] swaps_replace() default {}; 887 888 /** 889 * Time zone. 890 * 891 * <p> 892 * Specifies the default timezone for serializer and parser sessions. 893 * 894 * <h5 class='section'>Notes:</h5><ul> 895 * <li class='note'> 896 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 897 * </ul> 898 * 899 * <h5 class='section'>See Also:</h5><ul> 900 * <li class='jm'>{@link org.apache.juneau.BeanSession.Builder#timeZone(TimeZone)} 901 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#timeZone(TimeZone)} 902 * </ul> 903 * 904 * @return The annotation value. 905 */ 906 String timeZone() default ""; 907 908 /** 909 * Use enum names. 910 * 911 * <p> 912 * When enabled, enums are always serialized by name, not using {@link Object#toString()}. 913 * 914 * <ul class='values'> 915 * <li><js>"true"</js> 916 * <li><js>"false"</js> (default) 917 * </ul> 918 * 919 * <h5 class='section'>Notes:</h5><ul> 920 * <li class='note'> 921 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 922 * </ul> 923 * 924 * <h5 class='section'>See Also:</h5><ul> 925 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#useEnumNames()} 926 * </ul> 927 * 928 * @return The annotation value. 929 */ 930 String useEnumNames() default ""; 931 932 /** 933 * Don't use interface proxies. 934 * 935 * <p> 936 * Disables the feature where interfaces will be instantiated as proxy classes through the use of an 937 * {@link InvocationHandler} if there is no other way of instantiating them. 938 * <br>Setting this to <js>"true"</js> causes this to be a {@link BeanRuntimeException}. 939 * 940 * <ul class='values'> 941 * <li><js>"true"</js> 942 * <li><js>"false"</js> (default) 943 * </ul> 944 * 945 * <h5 class='section'>Notes:</h5><ul> 946 * <li class='note'> 947 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 948 * </ul> 949 * 950 * <h5 class='section'>See Also:</h5><ul> 951 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#disableInterfaceProxies()} 952 * </ul> 953 * 954 * @return The annotation value. 955 */ 956 String disableInterfaceProxies() default ""; 957 958 /** 959 * Use Java Introspector. 960 * 961 * <p> 962 * Using the built-in Java bean introspector will not pick up fields or non-standard getters/setters. 963 * <br>Most {@link Bean @Bean} annotations will be ignored. 964 * 965 * <ul class='values'> 966 * <li><js>"true"</js> 967 * <li><js>"false"</js> (default) 968 * </ul> 969 * 970 * <h5 class='section'>Notes:</h5><ul> 971 * <li class='note'> 972 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 973 * </ul> 974 * 975 * <h5 class='section'>See Also:</h5><ul> 976 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#useJavaBeanIntrospector()} 977 * </ul> 978 * 979 * @return The annotation value. 980 */ 981 String useJavaBeanIntrospector() default ""; 982}