blob: 891820f557e7f98d38ad0b482f33541e4645005d [file] [log] [blame]
/**
* Copyright (C) - Loetz GmbH&Co.KG, 69115 Heidelberg, Germany
*
* This source was created by OSBP Softwarefactory Wizard!
*
* OSBP is (C) - Loetz GmbH&Co.KG, 69115 Heidelberg, Germany
*
* ================================================================
*
* @file $HeadURL$
* @version $Revision$
* @date $Date$
* @author $Author$
*/
package org.osbp.mysmartshop.entities;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.Valid;
import org.eclipse.osbp.dsl.common.datatypes.IEntity;
import org.eclipse.osbp.runtime.common.annotations.Dispose;
@Entity
@Table(name = "DTO_TEST_PARENT")
@SuppressWarnings("all")
public class DtoTestParent extends BaseUUID implements IEntity {
@Column(name = "STRING")
private String string;
@JoinColumn(name = "CONTAINMENT_CHILDS_ID")
@OneToMany(mappedBy = "container", cascade = CascadeType.ALL, orphanRemoval = true)
@Valid
private List<DtoTestChildContainment> containmentChilds;
@JoinColumn(name = "CROSS_REF_CHILDS_ID")
@OneToMany(mappedBy = "container", cascade = { CascadeType.DETACH,
CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
private List<DtoTestChildCrossRef> crossRefChilds;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CROSS_REF_CHILD_ID")
private DtoTestChildCrossRef crossRefChild;
@Embedded
@AttributeOverrides(value = @AttributeOverride(name = "foo", column = @Column(name = "BEANX_FOO")))
@AssociationOverrides(value = @AssociationOverride(name = "crossRefChild", joinColumns = @JoinColumn(name = "BEANX_CROSSREFCHILD")))
@Column(name = "BEANX")
@Valid
private DtoTestBean beanx;
/**
* INTERNAL:
*
* @param selector
* @return
*/
public Consumer<?> internalGetRawConsumer(String selector) {
switch (selector) {
case "setId":
return (Consumer<String>) this::setId;
case "addToContainmentChilds":
return (Consumer<DtoTestChildContainment>) this::internalAddToContainmentChilds;
case "removeFromContainmentChilds":
return (Consumer<DtoTestChildContainment>) this::internalRemoveFromContainmentChilds;
case "addToCrossRefChilds":
return (Consumer<DtoTestChildCrossRef>) this::internalAddToCrossRefChilds;
case "removeFromCrossRefChilds":
return (Consumer<DtoTestChildCrossRef>) this::internalRemoveFromCrossRefChilds;
default:
return super.internalGetRawConsumer(selector);
}
}
/**
* INTERNAL:
*
* @param selector
* @return
*/
public Supplier<?> internalGetRawSupplier(String selector) {
switch (selector) {
case "getId":
return (Supplier<String>) this::getId;
default:
return super.internalGetRawSupplier(selector);
}
}
/**
* Checks whether the object is disposed.
*
* @throws RuntimeException
* if the object is disposed.
*/
private void checkDisposed() {
if (isDisposed()) {
throw new RuntimeException("Object already disposed: " + this);
}
}
/**
* Calling dispose will destroy that instance. The internal state will be
* set to 'disposed' and methods of that object must not be used anymore.
* Each call will result in runtime exceptions.<br>
* If this object keeps composition containments, these will be disposed
* too. So the whole composition containment tree will be disposed on
* calling this method.
*/
@Dispose
public void dispose() {
if (isDisposed()) {
return;
}
try {
// Dispose all the composition references.
if (this.containmentChilds != null) {
for (DtoTestChildContainment dtoTestChildContainment : this.containmentChilds) {
dtoTestChildContainment.dispose();
}
this.containmentChilds = null;
}
} finally {
super.dispose();
}
}
/**
* @return Returns the string property or <code>null</code> if not present.
*/
public String getString() {
checkDisposed();
return this.string;
}
/**
* Sets the string property to this instance.
*/
public void setString(final String string) {
checkDisposed();
this.string = string;
}
/**
* @return Returns an unmodifiable list of containmentChilds.
*/
public List<DtoTestChildContainment> getContainmentChilds() {
checkDisposed();
return Collections.unmodifiableList(internalGetContainmentChilds());
}
/**
* Sets the given containmentChilds to the object. Currently contained
* containmentChilds instances will be removed.
*
* @param containmentChilds
* the list of new instances
*/
public void setContainmentChilds(
final List<DtoTestChildContainment> containmentChilds) {
// remove the old dtoTestChildContainment
for (DtoTestChildContainment oldElement : new ArrayList<DtoTestChildContainment>(
this.internalGetContainmentChilds())) {
removeFromContainmentChilds(oldElement);
}
// add the new dtoTestChildContainment
for (DtoTestChildContainment newElement : containmentChilds) {
addToContainmentChilds(newElement);
}
}
/**
* Returns the list of <code>DtoTestChildContainment</code>s thereby lazy
* initializing it.
*/
private List<DtoTestChildContainment> internalGetContainmentChilds() {
if (this.containmentChilds == null) {
this.containmentChilds = new ArrayList<DtoTestChildContainment>();
}
return this.containmentChilds;
}
/**
* Adds the given dtoTestChildContainment to this object.
* <p>
* Since the reference is a composition reference, the opposite reference
* (DtoTestChildContainment.container) of the dtoTestChildContainment will
* be handled automatically and no further coding is required to keep them
* in sync. See
* {@link DtoTestChildContainment#setContainer(DtoTestChildContainment)}.
*
*/
public void addToContainmentChilds(
final DtoTestChildContainment dtoTestChildContainment) {
checkDisposed();
dtoTestChildContainment.setContainer(this);
}
/**
* Removes the given dtoTestChildContainment from this object.
* <p>
* Since the reference is a cascading reference, the opposite reference
* (DtoTestChildContainment.container) of the dtoTestChildContainment will
* be handled automatically and no further coding is required to keep them
* in sync. See
* {@link DtoTestChildContainment#setContainer(DtoTestChildContainment)}.
*
*/
public void removeFromContainmentChilds(
final DtoTestChildContainment dtoTestChildContainment) {
checkDisposed();
dtoTestChildContainment.setContainer(null);
}
/**
* For internal use only!
*/
public void internalAddToContainmentChilds(
final DtoTestChildContainment dtoTestChildContainment) {
internalGetContainmentChilds().add(dtoTestChildContainment);
}
/**
* For internal use only!
*/
public void internalRemoveFromContainmentChilds(
final DtoTestChildContainment dtoTestChildContainment) {
internalGetContainmentChilds().remove(dtoTestChildContainment);
}
/**
* @return Returns an unmodifiable list of crossRefChilds.
*/
public List<DtoTestChildCrossRef> getCrossRefChilds() {
checkDisposed();
return Collections.unmodifiableList(internalGetCrossRefChilds());
}
/**
* Sets the given crossRefChilds to the object. Currently contained
* crossRefChilds instances will be removed.
*
* @param crossRefChilds
* the list of new instances
*/
public void setCrossRefChilds(
final List<DtoTestChildCrossRef> crossRefChilds) {
// remove the old dtoTestChildCrossRef
for (DtoTestChildCrossRef oldElement : new ArrayList<DtoTestChildCrossRef>(
this.internalGetCrossRefChilds())) {
removeFromCrossRefChilds(oldElement);
}
// add the new dtoTestChildCrossRef
for (DtoTestChildCrossRef newElement : crossRefChilds) {
addToCrossRefChilds(newElement);
}
}
/**
* Returns the list of <code>DtoTestChildCrossRef</code>s thereby lazy
* initializing it.
*/
private List<DtoTestChildCrossRef> internalGetCrossRefChilds() {
if (this.crossRefChilds == null) {
this.crossRefChilds = new ArrayList<DtoTestChildCrossRef>();
}
return this.crossRefChilds;
}
/**
* Adds the given dtoTestChildCrossRef to this object.
* <p>
* Since the reference is a composition reference, the opposite reference
* (DtoTestChildCrossRef.container) of the dtoTestChildCrossRef will be
* handled automatically and no further coding is required to keep them in
* sync. See {@link DtoTestChildCrossRef#setContainer(DtoTestChildCrossRef)}.
*
*/
public void addToCrossRefChilds(
final DtoTestChildCrossRef dtoTestChildCrossRef) {
checkDisposed();
dtoTestChildCrossRef.setContainer(this);
}
/**
* Removes the given dtoTestChildCrossRef from this object.
* <p>
*
*/
public void removeFromCrossRefChilds(
final DtoTestChildCrossRef dtoTestChildCrossRef) {
checkDisposed();
dtoTestChildCrossRef.setContainer(null);
}
/**
* For internal use only!
*/
public void internalAddToCrossRefChilds(
final DtoTestChildCrossRef dtoTestChildCrossRef) {
internalGetCrossRefChilds().add(dtoTestChildCrossRef);
}
/**
* For internal use only!
*/
public void internalRemoveFromCrossRefChilds(
final DtoTestChildCrossRef dtoTestChildCrossRef) {
internalGetCrossRefChilds().remove(dtoTestChildCrossRef);
}
/**
* @return Returns the crossRefChild property or <code>null</code> if not
* present.
*/
public DtoTestChildCrossRef getCrossRefChild() {
checkDisposed();
return this.crossRefChild;
}
/**
* Sets the crossRefChild property to this instance.
*/
public void setCrossRefChild(final DtoTestChildCrossRef crossRefChild) {
checkDisposed();
this.crossRefChild = crossRefChild;
}
/**
* @return Returns the beanx property or <code>null</code> if not present.
*/
public DtoTestBean getBeanx() {
checkDisposed();
return this.beanx;
}
/**
* Sets the beanx property to this instance.
*/
public void setBeanx(final DtoTestBean beanx) {
checkDisposed();
this.beanx = beanx;
}
}