001/*
002 * Copyright 2021 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.dwc.terms;
017
018import org.gbif.dwc.terms.jackson.TermDeserializer;
019import org.gbif.dwc.terms.jackson.TermKeyDeserializer;
020import org.gbif.dwc.terms.jackson.TermKeySerializer;
021import org.gbif.dwc.terms.jackson.TermSerializer;
022
023import java.io.Serializable;
024import java.net.URI;
025
026import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
027import com.fasterxml.jackson.databind.annotation.JsonSerialize;
028
029@JsonSerialize(using = TermSerializer.class, keyUsing = TermKeySerializer.class)
030@JsonDeserialize(using = TermDeserializer.class, keyUsing = TermKeyDeserializer.class)
031public interface Term extends Serializable {
032
033  /**
034   * A unique standard prefix representing the namespace.
035   * For example dwc.
036   */
037  String prefix();
038
039  /**
040   * The namespace the terms are in.
041   * Default implementations here expect the namespace to end with a slash.
042   */
043  URI namespace();
044
045  /**
046   * The simple term name without any namespace or paths.
047   * For example scientificName.
048   */
049  String simpleName();
050
051  /**
052   * The simple term name prefixed by a short unique namespace abbreviation.
053   * For example dwc:scientificName.
054   */
055  default String prefixedName() {
056    return prefix() + ":" + simpleName();
057  }
058
059  /**
060   * The full qualified term uri including the namespace.
061   * For example http://rs.tdwg.org/dwc/terms/scientificName.
062   */
063  default String qualifiedName() {
064    return namespace() + simpleName();
065  }
066
067  /**
068   * Informs if a term is generally used as a class term, i.e. defining rowTypes not properties.
069   * For example VernacularName, Taxon or Occurrence
070   * @return true if the term is defining a class instead of a property, e.g. Taxon
071   */
072  boolean isClass();
073
074}