Coverage Report - org.simpleframework.xml.ElementUnion
 
Classes in this File Line Coverage Branch Coverage Complexity
ElementUnion
N/A
N/A
0
 
 1  
 /*
 2  
  * ElementUnion.java March 2011
 3  
  *
 4  
  * Copyright (C) 2011, 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>ElementUnion</code> annotation is used to describe fields 
 26  
  * and methods that can dynamically match a schema class. Each union
 27  
  * can have a number of different XML class schemas matched based on
 28  
  * an XML element name or the instance type. This provides a means
 29  
  * of expressing a logical OR. By annotating a field or method as a
 30  
  * union it can take multiple forms. For example.
 31  
  * <pre>
 32  
  * 
 33  
  *    &#64;ElementUnion({
 34  
  *       &#64;Element(name="circle", type=Circle.class),
 35  
  *       &#64;Element(name="square", type=Square.class)       
 36  
  *    })
 37  
  *    private Shape shape;
 38  
  *    
 39  
  * </pre>
 40  
  * For the above definition the <code>Shape</code> field can take
 41  
  * be any of the declared types. On deserialization the name of the
 42  
  * element will determine the type that is instantiated and the XML
 43  
  * structure to be consumed. For serialization the instance type will
 44  
  * determine the name of the element the object will serialized as. 
 45  
  * This provides a useful means of consume more complicated sources. 
 46  
  * 
 47  
  * @author Niall Gallagher
 48  
  * 
 49  
  * @see org.simpleframework.xml.Element
 50  
  */
 51  
 @Retention(RetentionPolicy.RUNTIME)
 52  
 public @interface ElementUnion {
 53  
    
 54  
    /**
 55  
     * This provides the <code>Element</code> annotations that have 
 56  
     * been defined for this union. Each element describes the XML
 57  
     * class schema to use and the name of the XML element. This 
 58  
     * allows the serialization process to determine which elements
 59  
     * map to the defined types. Also, the types define how the XML
 60  
     * is generated for a given instance.     
 61  
     * 
 62  
     * @return the elements defined for the union declaration
 63  
     */
 64  
    Element[] value();
 65  
 }