cdc.mf.model.MfLink Maven / Gradle / Ivy
package cdc.mf.model;
public abstract class MfLink extends MfAbstractBasicElement
{
private boolean reversed = false;
protected MfLink(Builder, ?, ? extends P> builder,
MfElementFeatures features) {
super(builder, features);
}
boolean isReversed() {
return reversed;
}
boolean reverse() {
if (!reversed) {
final MfElementRef extends MfElement> ref = getTargetRef();
if (ref.isValid()) {
((MfAbstractElement) ref.get()).addToReversed(this);
reversed = true;
}
}
return reversed;
}
public P getSource() {
return getParent();
}
public abstract MfElementRef extends MfElement> getTargetRef();
public MfElement getTarget() {
return getTargetRef().get();
}
/**
* Base builder of links.
*
* @author Damien Carbonne
*
* @param The builder type.
* @param The built element type.
* @param The concrete parent type.
*/
public abstract static class Builder,
E extends MfLink super P>,
P extends MfElement>
extends MfAbstractBasicElement.Builder {
protected Builder(P parent) {
super(parent);
}
}
}