Coverage Report - org.simpleframework.xml.Default
 
Classes in this File Line Coverage Branch Coverage Complexity
Default
N/A
N/A
0
 
 1  
 /*
 2  
  * Default.java January 2010
 3  
  *
 4  
  * Copyright (C) 2010, Niall Gallagher <niallg@users.sf.net>
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 15  
  * implied. See the License for the specific language governing 
 16  
  * permissions and limitations under the License.
 17  
  */
 18  
 
 19  
 package org.simpleframework.xml;
 20  
 
 21  
 import java.lang.annotation.Retention;
 22  
 import java.lang.annotation.RetentionPolicy;
 23  
 
 24  
 /**
 25  
  * The <code>Default</code> annotation is used to specify that all
 26  
  * fields or methods should be serialized in a default manner. This
 27  
  * basically allows an objects fields or properties to be serialized
 28  
  * without the need to annotate them. This has advantages if the
 29  
  * format of the serialized object is not important, as it allows
 30  
  * the object to be serialized with a minimal use of annotations.
 31  
  * <pre>
 32  
  * 
 33  
  *    &#64;Root
 34  
  *    &#64;Default(DefaultType.FIELD)
 35  
  *    public class Example {
 36  
  *       ...
 37  
  *    }
 38  
  * 
 39  
  * </pre>
 40  
  * Defaults can be applied to either fields or property methods. If
 41  
  * this annotation is applied to a class, certain fields or methods
 42  
  * can be ignored using the <code>Transient</code> annotation. If a
 43  
  * member is marked as transient then it will not be serialized. The
 44  
  * defaults are applied only to those members that are not otherwise
 45  
  * annotated with an XML annotation.
 46  
  * 
 47  
  * @author Niall Gallagher
 48  
  * 
 49  
  * @see org.simpleframework.xml.Transient
 50  
  */
 51  
 @Retention(RetentionPolicy.RUNTIME)
 52  
 public @interface Default {
 53  
    
 54  
    /**
 55  
     * This method is used to return the type of default that is to
 56  
     * be applied to the class. Defaults can be applied to either
 57  
     * fields or property methods. Any member with an XML annotation
 58  
     * will not be treated as a default. 
 59  
     * 
 60  
     * @return this returns the type of defaults to be applied
 61  
     */
 62  
    DefaultType value() default DefaultType.FIELD;
 63  
    
 64  
    /**
 65  
     * This is used to determine if the generated annotations are
 66  
     * required or not. By default generated parameters are required.
 67  
     * Setting this to false means that null values are accepted
 68  
     * by all defaulted fields or methods depending on the type.
 69  
     * 
 70  
     * @return this is used to determine if defaults are required
 71  
     */
 72  
    boolean required() default true;
 73  
 }