cdc.mf.model.MfClass Maven / Gradle / Ivy
package cdc.mf.model;
import cdc.util.lang.Introspection;
/**
* Class class.
*
* @author Damien Carbonne
*/
public final class MfClass extends MfType
implements MfSpecializationOwner, MfImplementationOwner, MfAbstractItem {
public static final Class PARENT_CLASS =
MfTypeOwner.class;
public static final Class> BUILDER_CLASS =
Introspection.uncheckedCast(Builder.class);
private final boolean isAbstract;
protected MfClass(Builder extends MfTypeOwner> builder) {
super(builder);
this.isAbstract = builder.isAbstract;
addToParent(FEATURES);
addToModel();
}
@Override
public MfClass duplicate(MfTypeOwner tgtParent) {
return tgtParent.cls()
.set(this)
.build();
}
@Override
public boolean isAbstract() {
return isAbstract;
}
@Override
public MfDocumentation.Builder documentation() {
return MfDocumentation.builder(this);
}
@Override
public MfTag.Builder tag() {
return MfTag.builder(this);
}
@Override
public MfDependency.Builder dependency() {
return MfDependency.builder(this);
}
@Override
public MfClass.Builder cls() {
return MfClass.builder(this);
}
@Override
public MfInterface.Builder xface() {
return MfInterface.builder(this);
}
@Override
public MfEnumeration.Builder enumeration() {
return MfEnumeration.builder(this);
}
@Override
public MfSpecialization.Builder specialization() {
return MfSpecialization.builder(this, MfClass.class);
}
@Override
public MfImplementation.Builder implementation() {
return MfImplementation.builder(this);
}
@Override
public MfOperation.Builder operation() {
return MfOperation.builder(this);
}
@Override
public MfProperty.Builder property() {
return MfProperty.builder(this);
}
@Override
public MfAssociation.Builder association() {
return MfAssociation.builder(this);
}
@Override
public MfAggregation.Builder aggregation() {
return MfAggregation.builder(this);
}
@Override
public MfComposition.Builder composition() {
return MfComposition.builder(this);
}
@Override
public MfConstraint.Builder constraint() {
return MfConstraint.builder(this);
}
static Builder
builder(P parent) {
return new Builder<>(parent);
}
/**
* Builder of classes.
*
* @author Damien Carbonne
*
* @param
The concrete parent type.
*/
public static final class Builder
extends MfType.Builder, MfClass, P> {
private boolean isAbstract = false;
protected Builder(P parent) {
super(parent);
}
@Override
public Builder set(MfClass element) {
return super.set(element).isAbstract(element.isAbstract());
}
@Override
public Class getElementClass() {
return MfClass.class;
}
public boolean isAbstract() {
return isAbstract;
}
public Builder isAbstract(boolean isAbstract) {
this.isAbstract = isAbstract;
return self();
}
@Override
public MfClass build() {
return new MfClass(this);
}
}
}