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

edu.stanford.protege.webprotege.perspective.PerspectiveDescriptor Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package edu.stanford.protege.webprotege.perspective;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import edu.stanford.protege.webprotege.common.LanguageMap;

import javax.annotation.Nonnull;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 2020-08-31
 */
@AutoValue

public abstract class PerspectiveDescriptor {

    public static final String PERSPECTIVE_ID = "perspectiveId";

    public static final String LABEL = "label";

    public static final String FAVORITE = "favorite";

    @JsonCreator
    @Nonnull
    public static PerspectiveDescriptor get(@JsonProperty(PERSPECTIVE_ID) @Nonnull PerspectiveId perspectiveId,
                                            @JsonProperty(LABEL) @Nonnull LanguageMap newLabel,
                                            @JsonProperty(FAVORITE) boolean favorite) {
        return new AutoValue_PerspectiveDescriptor(perspectiveId, newLabel, favorite);
    }


    @JsonProperty(PERSPECTIVE_ID)
    @Nonnull
    public abstract PerspectiveId getPerspectiveId();

    @JsonProperty(LABEL)
    @Nonnull
    public abstract LanguageMap getLabel();

    @JsonProperty(FAVORITE)
    public abstract boolean isFavorite();

    @Nonnull
    public PerspectiveDescriptor withFavorite(boolean favorite) {
        if(favorite == isFavorite()) {
            return this;
        }
        return PerspectiveDescriptor.get(getPerspectiveId(), getLabel(), favorite);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy