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

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

The newest version!
package cdc.mf.model;

import java.util.EnumSet;
import java.util.Set;

public final class MfElementFeatures {
    public static final MfElementFeatures NONE = builder().build();

    private final Set features;

    private MfElementFeatures(Builder builder) {
        this.features = builder.features;
    }

    public enum Feature {
        /** Set when the element must have a valid name. */
        REQUIRES_NAME,
        /** Set when the element name must be unique among siblings with same class. */
        NAME_UNIQUENESS,
        /** Set when the element must have a valid id. */
        REQUIRES_ID
    }

    public boolean isEnabled(Feature feature) {
        return features.contains(feature);
    }

    public boolean requiresName() {
        return features.contains(Feature.REQUIRES_NAME);
    }

    public boolean nameUniqueness() {
        return features.contains(Feature.NAME_UNIQUENESS);
    }

    public boolean requiresId() {
        return features.contains(Feature.REQUIRES_ID);
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private final Set features = EnumSet.noneOf(Feature.class);

        Builder() {
        }

        public Builder feature(Feature feature) {
            this.features.add(feature);
            return this;
        }

        public MfElementFeatures build() {
            return new MfElementFeatures(this);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy