org.hibernate.envers.boot.model.Key Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-envers Show documentation
Show all versions of hibernate-envers Show documentation
Hibernate's entity version (audit/history) support
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.envers.boot.model;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmKeyType;
/**
* Contract for declaring a column name of a foreign key.
*
* @author Chris Cranford
*/
public class Key implements ColumnContainer, Bindable, Cloneable {
private final List columns;
public Key() {
this.columns = new ArrayList<>();
}
public Key(Key key) {
this.columns = new ArrayList<>();
for ( Column column : key.columns ) {
this.columns.add( new Column( column ) );
}
}
@Override
public List getColumns() {
return columns;
}
@Override
public void addColumn(Column column) {
this.columns.add( column );
}
@Override
public Key deepCopy() {
return new Key( this );
}
@Override
public JaxbHbmKeyType build() {
final JaxbHbmKeyType key = new JaxbHbmKeyType();
for ( Column column : columns ) {
key.getColumn().add( column.build() );
}
return key;
}
}