001/** 002 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 003 * This file is part of the LDP4j Project: 004 * http://www.ldp4j.org/ 005 * 006 * Center for Open Middleware 007 * http://www.centeropenmiddleware.com/ 008 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 009 * Copyright (C) 2014-2016 Center for Open Middleware. 010 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 011 * Licensed under the Apache License, Version 2.0 (the "License"); 012 * you may not use this file except in compliance with the License. 013 * You may obtain a copy of the License at 014 * 015 * http://www.apache.org/licenses/LICENSE-2.0 016 * 017 * Unless required by applicable law or agreed to in writing, software 018 * distributed under the License is distributed on an "AS IS" BASIS, 019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 020 * See the License for the specific language governing permissions and 021 * limitations under the License. 022 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 023 * Artifact : org.ldp4j.framework:ldp4j-application-api:0.2.1 024 * Bundle : ldp4j-application-api-0.2.1.jar 025 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 026 */ 027package org.ldp4j.application.vocabulary; 028 029import java.io.Serializable; 030 031 032/** 033 * The class represents the terms of a vocabulary. The class includes different 034 * mechanisms for identifying the term as well as utility methods for 035 * transforming the term into different types. 036 * 037 * @version 1.0 038 * @since 1.0.0 039 * @author Miguel Esteban Gutiérrez 040 * @see Vocabulary 041 */ 042public interface Term extends Comparable<Term>, Serializable { 043 044 /** 045 * Returns the ordinal of this term (its position in its vocabulary 046 * declaration, where the initial constant is assigned an ordinal of zero). 047 * 048 * @return the ordinal of this term 049 */ 050 int ordinal(); 051 052 /** 053 * Returns the name of this term constant, exactly as declared in its 054 * vocabulary declaration. 055 * 056 * <b>Most programmers should use the {@link #toString} method in preference 057 * to this one, as the toString method may return a more user-friendly 058 * name.</b> This method is designed primarily for use in specialized 059 * situations where correctness depends on getting the exact name, which 060 * will not vary from release to release. 061 * 062 * @return the name of this term 063 */ 064 String name(); 065 066 /** 067 * Returns the simple name of the entity of the vocabulary identified by 068 * this term constant. 069 */ 070 String entityName(); 071 072 /** 073 * Returns the qualified name of the entity of the vocabulary identified by 074 * this term constant. 075 */ 076 String qualifiedEntityName(); 077 078 /** 079 * Returns the Vocabulary object corresponding to this term constant's 080 * vocabulary type. Two term constants e1 and e2 are of the same vocabulary 081 * type if and only if 082 * {@code e1.getDeclaringVocabulary() == e2.getDeclaringVocabulary()}. 083 * 084 * @return the Vocabulary object corresponding to this term constant's 085 * vocabulary type 086 */ 087 Vocabulary getDeclaringVocabulary(); 088 089 /** 090 * Transform the term to an instance of the specified type. 091 * 092 * @param type 093 * The type to which the term is to be transformed to. 094 * @return An instance of the specified type that represents this term. 095 * @throws UnsupportedOperationException 096 * if the term cannot be transformed to the specified type. 097 */ 098 <T> T as(Class<? extends T> type); 099 100}