Coverage Report - org.simpleframework.xml.ElementMapUnion
 
Classes in this File Line Coverage Branch Coverage Complexity
ElementMapUnion
N/A
N/A
0
 
 1  
 /*
 2  
  * ElementMapUnion.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>ElementMapUnion</code> annotation is used to describe a 
 26  
  * field or method 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. Here a map of element 
 29  
  * map annotations can be declared. Each annotation expresses the types
 30  
  * the map can accept. Taking the declaration below, if the annotation 
 31  
  * is inline, the map can take a number of varying types all determined
 32  
  * from the XML element name.
 33  
  * <pre>
 34  
  * 
 35  
  *    &#64;ElementMapUnion({
 36  
  *       &#64;ElementMap(entry="x", inline=true, valueType=X.class),
 37  
  *       &#64;ElementMap(entry="y", inline=true, valueType=Y.class),
 38  
  *       &#64;ElementMap(entry="z", inline=true, valueType=Z.class)               
 39  
  *    })
 40  
  *    private Map&lt;String, Code&gt; codes;
 41  
  *    
 42  
  * </pre>
 43  
  * For the above definition the map field can take any of the declared
 44  
  * types. On deserialization the name of the element will determine the
 45  
  * type that is instantiated and inserted in to the map. When the map
 46  
  * is serialized the list entry instance type will determine the name 
 47  
  * of the element the instance will serialized as. This provides a 
 48  
  * useful means of consume more complicated sources. 
 49  
  * 
 50  
  * @author Niall Gallagher
 51  
  * 
 52  
  * @see org.simpleframework.xml.ElementMap
 53  
  */
 54  
 @Retention(RetentionPolicy.RUNTIME)
 55  
 public @interface ElementMapUnion {
 56  
    
 57  
    /**
 58  
     * This provides the <code>ElementMap</code> annotations that have 
 59  
     * been defined for this union. Each element map describes the 
 60  
     * XML class schema to use and the name of the XML element. This 
 61  
     * allows the serialization process to determine which elements
 62  
     * map to the defined types. Also, the types define how the XML
 63  
     * is generated for a given instance.     
 64  
     * 
 65  
     * @return the element maps defined for the union declaration
 66  
     */ 
 67  
    ElementMap[] value();
 68  
 }