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

edu.stanford.protege.webprotege.criteria.NumericValueCriteria 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.*;
import com.google.auto.value.AutoValue;

import javax.annotation.Nonnull;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 11 Jun 2018
 */
@AutoValue
@JsonTypeName("NumericValue")

@JsonPropertyOrder({NumericValueCriteria.PREDICATE, NumericValueCriteria.VALUE})
public abstract class NumericValueCriteria implements LexicalValueCriteria {

    public static final String PREDICATE = "predicate";

    public static final String VALUE = "value";

    @Nonnull
    @JsonProperty(PREDICATE)
    public NumericPredicate getPredicate() {
        return NumericPredicate.valueOf(getName());
    }

    @JsonIgnore
    protected abstract String getName();

    // This weirdness is due to a problem I'm having with serializing embedded enums
    // if the enum isn't reachable in a way other than through a custom field serializer
    public abstract double getValue();



    @Nonnull
    public static NumericValueCriteria get(@Nonnull String name, @JsonProperty(VALUE) double value) {
        return new AutoValue_NumericValueCriteria(name, value);
    }

    @JsonCreator
    @Nonnull
    public static NumericValueCriteria get(@Nonnull @JsonProperty(PREDICATE) NumericPredicate predicate,
                                           @JsonProperty(VALUE) double value) {
        return new AutoValue_NumericValueCriteria(predicate.name(), value);
    }

    @Nonnull
    public static NumericValueCriteria numericValue(@Nonnull NumericPredicate predicate, double value) {
        return get(predicate, value);
    }

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy