All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdc.mf.model.MfAnnotation Maven / Gradle / Ivy

The newest version!
package cdc.mf.model;

import cdc.util.lang.Checks;
import cdc.util.lang.Introspection;

public final class MfAnnotation extends MfLink {
    public static final Class PARENT_CLASS =
            MfAnnotationOwner.class;
    public static final Class> BUILDER_CLASS =
            Introspection.uncheckedCast(Builder.class);
    public static final MfElementFeatures FEATURES =
            MfElementFeatures.NONE;

    private final MfElementRef targetRef;

    protected MfAnnotation(Builder builder) {
        super(builder,
              FEATURES);

        this.targetRef = Checks.isNotNull(builder.targetRef, MfNames.TARGET_REF);

        addToParent(FEATURES);
        addToModel();
    }

    @Override
    public MfAnnotation duplicate(MfAnnotationOwner tgtParent) {
        return tgtParent.annotation().set(this).build();
    }

    @Override
    public MfAnnotationOwner getSource() {
        return getParent();
    }

    @Override
    public MfElementRef getTargetRef() {
        return targetRef;
    }

    public MfElement getAnnotated() {
        return getTarget();
    }

    public MfElementRef getAnnotatedRef() {
        return getTargetRef();
    }

    @Override
    public MfDocumentation.Builder documentation() {
        return MfDocumentation.builder(this);
    }

    @Override
    public MfTag.Builder tag() {
        return MfTag.builder(this);
    }

    static 

Builder

builder(P parent) { return new Builder<>(parent); } /** * Builder of annotations. * * @author Damien Carbonne * * @param

The concrete parent type. */ public static final class Builder

extends MfLink.Builder, MfAnnotation, P> { private MfElementRef targetRef; protected Builder(P parent) { super(parent); } @Override public Builder

set(MfAnnotation element) { return super.set(element).targetRef(toLazy(element.getTargetRef())); } @Override public Class getElementClass() { return MfAnnotation.class; } public MfElementRef getTargetRef() { return targetRef; } public Builder

targetRef(MfElementRef targetRef) { this.targetRef = targetRef; return self(); } public Builder

target(MfElement target) { this.targetRef = MfElementRef.of(target); return self(); } public Builder

targetId(String targetId) { return targetRef(MfElementRef.of(getModel(), MfElement.class, targetId)); } @Override public MfAnnotation build() { return new MfAnnotation(this); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy