All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jakarta.xml.bind.annotation.XmlSeeAlso Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
/*
 * Copyright (c) 2006, 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0, which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package jakarta.xml.bind.annotation;

import jakarta.xml.bind.JAXBContext;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;

/**
 * Instructs JAXB to also bind other classes when binding this class.
 *
 * 

* Java makes it impractical/impossible to list all sub-classes of * a given class. This often gets in a way of JAXB users, as it JAXB * cannot automatically list up the classes that need to be known * to {@link JAXBContext}. * *

* For example, with the following class definitions: * *

 * class Animal {}
 * class Dog extends Animal {}
 * class Cat extends Animal {}
 * 
* *

* The user would be required to create {@link JAXBContext} as * {@code JAXBContext.newInstance(Dog.class,Cat.class)} * ({@code Animal} will be automatically picked up since {@code Dog} * and {@code Cat} refers to it.) * *

* {@link XmlSeeAlso} annotation would allow you to write: *

 * @XmlSeeAlso({Dog.class,Cat.class})
 * class Animal {}
 * class Dog extends Animal {}
 * class Cat extends Animal {}
 * 
* *

* This would allow you to do {@code JAXBContext.newInstance(Animal.class)}. * By the help of this annotation, JAXB implementations will be able to * correctly bind {@code Dog} and {@code Cat}. * * @author Kohsuke Kawaguchi * @since 1.6, JAXB 2.1 */ @Target({ElementType.TYPE}) @Retention(RUNTIME) public @interface XmlSeeAlso { Class[] value(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy