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

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

The newest version!
package cdc.mf.model;

import java.util.Collection;
import java.util.Locale;
import java.util.Set;

import cdc.util.lang.Introspection;
import cdc.util.strings.StringUtils;

/**
 * Documentation class.
 *
 * @author Damien Carbonne
 */
public final class MfDocumentation extends MfAbstractChildElement
        implements MfTagOwner, MfDependencyOwner, MfStereotypesItem {
    public static final Class PARENT_CLASS =
            MfElement.class;
    public static final Class> BUILDER_CLASS =
            Introspection.uncheckedCast(Builder.class);
    public static final MfElementFeatures FEATURES =
            MfElementFeatures.NONE;

    private final Locale language;
    private final String text;

    MfDocumentation(Builder builder) {
        super(builder,
              FEATURES);
        this.language = builder.language;
        this.text = builder.text;

        addToParent(FEATURES);
        addToModel();
    }

    @Override
    public MfDocumentation duplicate(MfElement tgtParent) {
        return tgtParent.documentation()
                        .set(this)
                        .build();
    }

    @Override
    public Set getStereotypes() {
        return super.getStereotypes();
    }

    public Locale getLanguage() {
        return language;
    }

    public String getText() {
        return text;
    }

    @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);
    }

    static 

Builder

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

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

extends MfAbstractChildElement.Builder, MfDocumentation, P> { private Locale language; private String text; protected Builder(P parent) { super(parent); } @Override public Builder

set(MfDocumentation element) { return super.set(element).language(element.getLanguage()) .text(element.getText()); } @Override public Class getElementClass() { return MfDocumentation.class; } @Override public Set getStereotypes() { return super.getStereotypes(); } @Override public Builder

stereotype(String stereotype) { return super.stereotype(stereotype); } @Override public Builder

stereotypes(String... stereotypes) { return super.stereotypes(stereotypes); } @Override public Builder

stereotypes(Collection stereotypes) { return super.stereotypes(stereotypes); } public Locale getLanguage() { return language; } public Builder

language(Locale language) { this.language = language; return self(); } public Builder

language(String language) { if (StringUtils.isNullOrEmpty(language)) { this.language = null; } else { this.language = Locale.forLanguageTag(language); } return self(); } public String getText() { return text; } public Builder

text(String text) { this.text = text; return self(); } @Override public MfDocumentation build() { return new MfDocumentation(this); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy