blob: 2d44d0ad451c82f9ade082577d8a227a86c09a82 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.context.java;
import org.eclipse.jpt.jpa.core.context.DiscriminatorType;
import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedDiscriminatorColumn;
import org.eclipse.jpt.jpa.core.context.VirtualNamedDiscriminatorColumn;
import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyNamedDiscriminatorColumn;
public abstract class AbstractJavaVirtualNamedDiscriminatorColumn<O extends JavaReadOnlyNamedDiscriminatorColumn.Owner, C extends ReadOnlyNamedDiscriminatorColumn>
extends AbstractJavaVirtualNamedColumn<O, C>
implements VirtualNamedDiscriminatorColumn, JavaReadOnlyNamedDiscriminatorColumn
{
protected Integer specifiedLength;
protected int defaultLength;
protected DiscriminatorType specifiedDiscriminatorType;
protected DiscriminatorType defaultDiscriminatorType;
protected AbstractJavaVirtualNamedDiscriminatorColumn(JavaJpaContextNode parent, O owner) {
super(parent, owner);
}
// ********** synchronize/update **********
@Override
public void update() {
super.update();
this.setSpecifiedDiscriminatorType(this.buildSpecifiedDiscriminatorType());
this.setDefaultDiscriminatorType(this.buildDefaultDiscriminatorType());
this.setSpecifiedLength(this.buildSpecifiedLength());
this.setDefaultLength(this.buildDefaultLength());
}
// ********** discriminator type **********
public DiscriminatorType getDiscriminatorType() {
return (this.specifiedDiscriminatorType != null) ? this.specifiedDiscriminatorType : this.defaultDiscriminatorType;
}
public DiscriminatorType getSpecifiedDiscriminatorType() {
return this.specifiedDiscriminatorType;
}
protected void setSpecifiedDiscriminatorType(DiscriminatorType type) {
DiscriminatorType old = this.specifiedDiscriminatorType;
this.specifiedDiscriminatorType = type;
this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_TYPE_PROPERTY, old, type);
}
protected DiscriminatorType buildSpecifiedDiscriminatorType() {
return this.getOverriddenColumn().getSpecifiedDiscriminatorType();
}
public DiscriminatorType getDefaultDiscriminatorType() {
return this.defaultDiscriminatorType;
}
protected void setDefaultDiscriminatorType(DiscriminatorType type) {
DiscriminatorType old = this.defaultDiscriminatorType;
this.defaultDiscriminatorType = type;
this.firePropertyChanged(DEFAULT_LENGTH_PROPERTY, old, type);
}
protected DiscriminatorType buildDefaultDiscriminatorType() {
return this.owner.getDefaultDiscriminatorType();
}
// ********** length **********
public int getLength() {
return (this.specifiedLength != null) ? this.specifiedLength.intValue() : this.defaultLength;
}
public Integer getSpecifiedLength() {
return this.specifiedLength;
}
protected void setSpecifiedLength(Integer length) {
Integer old = this.specifiedLength;
this.specifiedLength = length;
this.firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, old, length);
}
protected Integer buildSpecifiedLength() {
return this.getOverriddenColumn().getSpecifiedLength();
}
public int getDefaultLength() {
return this.defaultLength;
}
protected void setDefaultLength(int length) {
int old = this.defaultLength;
this.defaultLength = length;
this.firePropertyChanged(DEFAULT_LENGTH_PROPERTY, old, length);
}
protected int buildDefaultLength() {
return this.owner.getDefaultLength();
}
}