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

io.github.jeddict.jpa.spec.CollectionTable Maven / Gradle / Ivy

Go to download

Jeddict is an open source Jakarta EE application development platform that accelerates developers productivity and simplifies development tasks of creating complex entity relationship models.

There is a newer version: 6.3.1
Show newest version
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.01.21 at 01:52:19 PM IST
//
package io.github.jeddict.jpa.spec;

import io.github.jeddict.jpa.spec.validator.column.ForeignKeyValidator;
import io.github.jeddict.jpa.spec.validator.table.CollectionTableValidator;
import io.github.jeddict.source.AnnotatedMember;
import io.github.jeddict.source.AnnotationExplorer;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import static java.util.stream.Collectors.toCollection;
import static java.util.stream.Collectors.toList;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.eclipse.persistence.internal.jpa.metadata.tables.CollectionTableMetadata;

/**
 *
 *
 * @Target({METHOD, FIELD}) @Retention(RUNTIME) public @interface
 * CollectionTable { String name() default ""; String catalog() default "";
 * String schema() default ""; JoinColumn[] joinColumns() default {};
 * UniqueConstraint[] uniqueConstraints() default {}; Index[] indexes() default
 * {}; }
 *
 *
 *
 * 

* Java class for collection-table complex type. * *

* The following schema fragment specifies the expected content contained within * this class. * *

 * <complexType name="collection-table">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <sequence>
 *           <element name="join-column" type="{http://xmlns.jcp.org/xml/ns/persistence/orm}join-column" maxOccurs="unbounded" minOccurs="0"/>
 *           <element name="foreign-key" type="{http://xmlns.jcp.org/xml/ns/persistence/orm}foreign-key" minOccurs="0"/>
 *         </sequence>
 *         <element name="unique-constraint" type="{http://xmlns.jcp.org/xml/ns/persistence/orm}unique-constraint" maxOccurs="unbounded" minOccurs="0"/>
 *         <element name="index" type="{http://xmlns.jcp.org/xml/ns/persistence/orm}index" maxOccurs="unbounded" minOccurs="0"/>
 *       </sequence>
 *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       <attribute name="catalog" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       <attribute name="schema" type="{http://www.w3.org/2001/XMLSchema}string" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "collection-table", propOrder = { "joinColumn", "foreignKey" }) @XmlJavaTypeAdapter(value = CollectionTableValidator.class) public class CollectionTable extends Table { @XmlElement(name = "join-column") protected List joinColumn; @XmlElement(name = "fk") protected ForeignKey foreignKey; public static CollectionTable load(AnnotatedMember member) { CollectionTable collectionTable = null; Optional collectionTableOpt = member.getAnnotation(jakarta.persistence.CollectionTable.class); if (collectionTableOpt.isPresent()) { collectionTable = new CollectionTable(); AnnotationExplorer annotation = collectionTableOpt.get(); annotation.getString("name").ifPresent(collectionTable::setName); annotation.getString("catalog").ifPresent(collectionTable::setCatalog); annotation.getString("schema").ifPresent(collectionTable::setSchema); collectionTable.joinColumn = annotation.getAnnotationList("joinColumns") .map(JoinColumn::load) .collect(toList()); collectionTable.uniqueConstraint = annotation.getAnnotationList("uniqueConstraints") .map(UniqueConstraint::load) .collect(toCollection(LinkedHashSet::new)); collectionTable.index = annotation.getAnnotationList("indexes") .map(Index::load) .collect(toList()); annotation.getAnnotation("foreignKey").map(ForeignKey::load).ifPresent(collectionTable::setForeignKey); } return collectionTable; } /** * Gets the value of the joinColumn property. * *

* This accessor method returns a reference to the live list, not a * snapshot. Therefore any modification you make to the returned list will * be present inside the JAXB object. This is why there is not a * set method for the joinColumn property. * *

* For example, to add a new item, do as follows: *

     *    getJoinColumn().add(newItem);
     * 
* * *

* Objects of the following type(s) are allowed in the list * {@link JoinColumn } * * */ public List getJoinColumn() { if (joinColumn == null) { joinColumn = new ArrayList<>(); } return this.joinColumn; } /** * Gets the value of the foreignKey property. * * @return possible object is {@link ForeignKey } * */ public ForeignKey getForeignKey() { if(foreignKey==null){ foreignKey = new ForeignKey(); } return foreignKey; } /** * Sets the value of the foreignKey property. * * @param value allowed object is {@link ForeignKey } * */ public void setForeignKey(ForeignKey value) { this.foreignKey = value; } @Override public CollectionTableMetadata getAccessor() { CollectionTableMetadata accessor = new CollectionTableMetadata(); super.getAccessor(accessor); accessor.setJoinColumns(getJoinColumn().stream().map(JoinColumn::getAccessor).collect(toList())); if (ForeignKeyValidator.isNotEmpty(foreignKey)) { accessor.setForeignKey(foreignKey.getAccessor()); } return accessor; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy