Class TermAdapter<T>
java.lang.Object
org.tweetyproject.logics.commons.syntax.TermAdapter<T>
- Type Parameters:
T
- The type of the value saved in the term, this might be a string if the term is a constant or a variable, or it might be an integer if the term is a number term.
- All Implemented Interfaces:
LogicStructure
,Term<T>
- Direct Known Subclasses:
ArithmeticTerm
,FunctionalTerm
,NumberTerm
,StringTerm
Abstract base class implementing the substitute(), getSort(), getTerms(), and
containsTermsOfType() methods in a way it is useful for terms.
- Author:
- Tim Janus, Matthias Thimm
-
Constructor Summary
ConstructorDescriptionTermAdapter
(T value) Default-Ctor: Creates an TermAdapter with the Sort "Thing"TermAdapter
(T value, Sort sort) Ctor: Creates a TermAdapter with the given Sort -
Method Summary
Modifier and TypeMethodDescriptionabstract TermAdapter
<?> clone()
Creates a deep copy of the term<C extends Term<?>>
booleancontainsTermsOfType
(Class<C> cls) Checks if this logical structure contains at least one term of type C.boolean
get()
getSort()
getTerms()
Processes the set containing all terms of type C.int
hashCode()
void
Changes the java-object representation of the term to the given value.Term
<?> substitute
(Term<?> v, Term<?> t) Substitutes all occurrences of term "v" in this term by term "t" and returns the new term.toString()
-
Constructor Details
-
TermAdapter
Default-Ctor: Creates an TermAdapter with the Sort "Thing"- Parameters:
value
- the value of this term
-
TermAdapter
-
-
Method Details
-
getTerms
- Specified by:
getTerms
in interfaceLogicStructure
- Returns:
- a set containing all terms of this logical structure
-
getTerms
Description copied from interface:LogicStructure
Processes the set containing all terms of type C. This method uses the equals method of the given Class and therefore does not add terms which are sub classes of type C to the set.- Specified by:
getTerms
in interfaceLogicStructure
- Type Parameters:
C
- the type of terms- Parameters:
cls
- The Class structure containing type information about the searched term- Returns:
- A set containing all terms of type C of this logical structure
-
containsTermsOfType
Description copied from interface:LogicStructure
Checks if this logical structure contains at least one term of type C. This method is a shortcut for !getTerms(TermImplementation.class).isEmpty().- Specified by:
containsTermsOfType
in interfaceLogicStructure
- Type Parameters:
C
- the type of terms- Parameters:
cls
- The class structure representing the type C of the term.- Returns:
- True if this logical structure contains at least one term of type C or false otherwise.
-
substitute
Description copied from interface:Term
Substitutes all occurrences of term "v" in this term by term "t" and returns the new term.- Specified by:
substitute
in interfaceTerm<T>
- Parameters:
v
- the term to be substituted.t
- the term to substitute.- Returns:
- a term where every occurrence of "v" is replaced by "t".
- Throws:
IllegalArgumentException
- if "v" and "t" are of different sorts (NOTE: this exception is only thrown when "v" actually appears in this formula)
-
getSort
-
hashCode
-
equals
-
clone
Description copied from interface:Term
Creates a deep copy of the term -
toString
-
set
-
get
-