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

edu.stanford.protege.webprotege.entity.OWLClassData Maven / Gradle / Ivy

There is a newer version: 0.9.6-WHO
Show newest version
package edu.stanford.protege.webprotege.entity;

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 com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import edu.stanford.protege.webprotege.common.DictionaryLanguage;
import edu.stanford.protege.webprotege.common.ShortForm;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLEntityVisitorEx;
import uk.ac.manchester.cs.owl.owlapi.OWLClassImpl;

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

/**
 * Author: Matthew Horridge
* Stanford University
* Bio-Medical Informatics Research Group
* Date: 28/11/2012 */ @AutoValue @JsonTypeName("ClassData") public abstract class OWLClassData extends OWLEntityData { public static OWLClassData get(@Nonnull OWLClass cls, @Nonnull ImmutableMap shortForms) { return get(cls, shortForms, false); } public static OWLClassData get(@Nonnull OWLClass cls, @Nonnull ImmutableMap shortForms, boolean deprecated) { return get(cls, toShortFormList(shortForms), deprecated); } public static OWLClassData get(@JsonProperty("entity") @Nonnull OWLClass cls, @JsonProperty("shortForms") @Nonnull ImmutableList shortForms, @JsonProperty("deprecated") boolean deprecated) { return new AutoValue_OWLClassData(shortForms, deprecated, cls); } /** * For deserialization from JSON only * @param iri The lexical representation of the IRI * @param shortForms A nullable list of short forms * @param deprecated * @return */ @JsonCreator protected static OWLClassData get(@JsonProperty("iri") @Nonnull String iri, @JsonProperty(value = "shortForms") @Nullable ImmutableList shortForms, @JsonProperty("deprecated") boolean deprecated) { return new AutoValue_OWLClassData(Objects.requireNonNullElse(shortForms, ImmutableList.of()), deprecated, new OWLClassImpl(IRI.create(iri))); } @JsonIgnore @Override public OWLClass getEntity() { return getObject(); } /** * For more compact JSON Serialization */ @JsonProperty("iri") protected String getIri() { return getEntity().getIRI().toString(); } @Nonnull @Override public abstract OWLClass getObject(); @JsonIgnore @Override public PrimitiveType getType() { return PrimitiveType.CLASS; } @Override public R accept(OWLPrimitiveDataVisitor visitor) throws E { return visitor.visit(this); } @Override public R accept(OWLEntityVisitorEx visitor, R defaultValue) { return visitor.visit(getEntity()); } @Override public R accept(OWLEntityDataVisitorEx visitor) { return visitor.visit(this); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy