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

edu.stanford.protege.webprotege.criteria.EntityAnnotationCriteria Maven / Gradle / Ivy

There is a newer version: 0.9.2
Show newest version
package edu.stanford.protege.webprotege.criteria;

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

import javax.annotation.Nonnull;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 11 Jun 2018
 */
@AutoValue

@JsonTypeName("EntityAnnotation")
public abstract class EntityAnnotationCriteria implements EntityMatchCriteria {

    private static final String ANNOTATION = "annotation";

    private static final String PRESENCE = "presence";

    @JsonProperty(ANNOTATION)
    @Nonnull
    public abstract AnnotationCriteria getAnnotationCriteria();

    @JsonIgnore
    protected abstract int getAnnotationPresenceOrdinal();

    @JsonProperty(PRESENCE)
    @Nonnull
    public AnnotationPresence getAnnotationPresence() {
        return AnnotationPresence.values()[getAnnotationPresenceOrdinal()];
    }

    @Override
    public  R accept(RootCriteriaVisitor visitor) {
        return visitor.visit(this);
    }

    @JsonCreator
    @Nonnull
    public static EntityAnnotationCriteria get(@Nonnull @JsonProperty(ANNOTATION) AnnotationCriteria criteria,
                                               @Nonnull @JsonProperty(PRESENCE) AnnotationPresence presence) {
        return new AutoValue_EntityAnnotationCriteria(criteria, presence.ordinal());
    }

    @Nonnull
    public static EntityAnnotationCriteria get(@Nonnull @JsonProperty("annotation") AnnotationCriteria criteria) {
        return new AutoValue_EntityAnnotationCriteria(criteria, AnnotationPresence.AT_LEAST_ONE.ordinal());
    }

    public static EntityAnnotationCriteria get(@Nonnull AnnotationPropertyCriteria propertyCriteria,
                                               @Nonnull AnnotationValueCriteria valueCriteria) {
        return get(AnnotationComponentsCriteria.get(propertyCriteria, valueCriteria));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy