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

sdmxdl.Component Maven / Gradle / Ivy

The newest version!
package sdmxdl;

import lombok.NonNull;
import nbbrd.design.SealedType;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Collections;
import java.util.Map;

/**
 * Abstract component of a DataStructure.
 */
@SealedType({
        Dimension.class,
        Attribute.class
})
public abstract class Component implements HasName {

    public abstract @NonNull String getId();

    public abstract @Nullable Codelist getCodelist();

    /**
     * Check if this component has a codelist.
     *
     * @return true if codelist, false otherwise
     */
    public final boolean isCoded() {
        return getCodelist() != null;
    }

    public final @NonNull Map getCodes() {
        Codelist codelist = getCodelist();
        return codelist != null ? codelist.getCodes() : Collections.emptyMap();
    }

    public static abstract class Builder> {

        @NonNull
        public abstract B id(@NonNull String id);

        public abstract @NonNull B codelist(@NonNull Codelist codelist);

        @NonNull
        public abstract B name(@NonNull String name);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy