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

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

The newest version!
package edu.stanford.protege.webprotege.perspective;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Optional;

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

public abstract class PerspectiveLayout {

    public static final String PERSPECTIVE_ID = "perspectiveId";

    public static final String LAYOUT = "layout";

    @Nonnull
    public static PerspectiveLayout get(@Nonnull PerspectiveId perspectiveId,
                                        @Nonnull Optional layout) {
        return getInternal(perspectiveId, layout.orElse(null));
    }
    @Nonnull
    public static PerspectiveLayout get(@Nonnull PerspectiveId perspectiveId,
                                        @Nonnull Node layout) {
        return getInternal(perspectiveId, layout);
    }

    @Nonnull
    public static PerspectiveLayout get(@Nonnull PerspectiveId perspectiveId) {
        return getInternal(perspectiveId, null);
    }

    @JsonCreator
    @Nonnull
    protected static PerspectiveLayout getInternal(@JsonProperty(PERSPECTIVE_ID) @Nullable PerspectiveId perspectiveId,
                                                   @JsonProperty(LAYOUT) @Nullable Node layout) {
        return new AutoValue_PerspectiveLayout(perspectiveId, layout);
    }

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

    @JsonProperty(LAYOUT)
    @Nullable
    protected abstract Node getLayoutInternal();

    @JsonIgnore
    public Optional getLayout() {
        return Optional.ofNullable(getLayoutInternal());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy