001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 * http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014package org.atteo.evo.config;
015
016import java.lang.annotation.Documented;
017import java.lang.annotation.ElementType;
018import java.lang.annotation.Retention;
019import java.lang.annotation.RetentionPolicy;
020import java.lang.annotation.Target;
021
022import org.atteo.evo.xmlmerge.CombineChildren;
023import org.atteo.evo.xmlmerge.CombineSelf;
024import org.atteo.evo.xmlmerge.XmlCombiner;
025
026/**
027 * Specifies how to combine XML nodes corresponding to the annotated class
028 * or to the annotated field.
029 *
030 * <p>
031 * The default behavior is {@link CombineSelf#MERGE} for both self and children.
032 * </p>
033 * <p>
034 * For instance the following code will instruct {@link XmlCombiner} to append the entries in the 'append' list:
035 * <pre>
036 * {@code
037 * public class Root {
038 * .   @XmlCombine(children = CombineChildren.APPEND)
039 * .   @XmlElementWrapper(name = "append")
040 * .   @XmlElementRef
041 *     List<Entry> append;
042 * }
043 * }
044 * </pre>
045 * </p>
046 */
047@Documented
048@Target({ ElementType.FIELD, ElementType.TYPE})
049@Retention(RetentionPolicy.RUNTIME)
050public @interface XmlCombine {
051    // Using full name in default value because of a bug in Java 6
052    // http://bugs.sun.com/view_bug.do?bug_id=6512707
053    CombineSelf self() default org.atteo.evo.xmlmerge.CombineSelf.MERGE;
054
055    CombineChildren children() default org.atteo.evo.xmlmerge.CombineChildren.MERGE;
056}