Class TypedStructureAdapter
- java.lang.Object
-
- net.sf.tweety.logics.commons.syntax.TypedStructureAdapter
-
- All Implemented Interfaces:
java.lang.Comparable<TypedStructureAdapter>
,TypedStructure
public abstract class TypedStructureAdapter extends java.lang.Object implements TypedStructure, java.lang.Comparable<TypedStructureAdapter>
The abstract parent for predicates and functors implementing the TypedStructure interface. This class implements their common functionalities.- Author:
- Matthias Thimm, Tim Janus
-
-
Constructor Summary
Constructors Constructor Description TypedStructureAdapter()
Default-Ctor: Creating empty typed structureTypedStructureAdapter(java.lang.String name)
Initializes a structure of arity zero with the given name;TypedStructureAdapter(java.lang.String name, int arity)
Initializes a structure with the given name and of the given arity.TypedStructureAdapter(java.lang.String name, java.util.List<Sort> arguments)
Initializes a structure with the given name and the given list of argument sorts.
-
Method Summary
Modifier and Type Method Description void
addArgumentType(Sort argType)
Adds the given Sort as argument type to the typed Structureabstract TypedStructure
clone()
Creates a deep copy of this objectint
compareTo(TypedStructureAdapter o)
protected java.util.List<Sort>
copyArgumentTypes()
boolean
equals(java.lang.Object obj)
java.util.List<Sort>
getArgumentTypes()
int
getArity()
java.lang.String
getName()
int
hashCode()
boolean
isComplete()
boolean
isTyped()
Sort
removeArgumentType(int index)
Removes the argument type at the specified indexboolean
removeArgumentType(Sort argType)
Removes the given Sort from the list of argument typesvoid
setName(java.lang.String name)
Changes the name of the Structurejava.lang.String
toString()
-
-
-
Field Detail
-
name
private java.lang.String name
The name of this structure
-
arguments
private java.util.List<Sort> arguments
This list constrains the possible arguments of this structure to the given sorts. Therefore the arity of this structure is the size of the list if the structure isComplete().
-
arity
private int arity
the number of arguments for a complete structure
-
-
Constructor Detail
-
TypedStructureAdapter
public TypedStructureAdapter()
Default-Ctor: Creating empty typed structure
-
TypedStructureAdapter
public TypedStructureAdapter(java.lang.String name)
Initializes a structure of arity zero with the given name;- Parameters:
name
- the name of the structure
-
TypedStructureAdapter
public TypedStructureAdapter(java.lang.String name, int arity)
Initializes a structure with the given name and of the given arity. Every argument gets the sort Sort.THING.- Parameters:
name
- the name of the structurearity
- the arity of this structure
-
TypedStructureAdapter
public TypedStructureAdapter(java.lang.String name, java.util.List<Sort> arguments)
Initializes a structure with the given name and the given list of argument sorts.- Parameters:
name
- the name of the structurearguments
- the sorts of the arguments
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceTypedStructure
- Returns:
- the unique name of the structure
-
setName
public void setName(java.lang.String name)
Description copied from interface:TypedStructure
Changes the name of the Structure- Specified by:
setName
in interfaceTypedStructure
- Parameters:
name
- The new name of the structure
-
getArity
public int getArity()
- Specified by:
getArity
in interfaceTypedStructure
- Returns:
- the arity of this structure
-
getArgumentTypes
public java.util.List<Sort> getArgumentTypes()
- Specified by:
getArgumentTypes
in interfaceTypedStructure
- Returns:
- An unmodifiable list which length equals the arity of the predicate if the structure isComplete().
-
addArgumentType
public void addArgumentType(Sort argType)
Description copied from interface:TypedStructure
Adds the given Sort as argument type to the typed Structure- Specified by:
addArgumentType
in interfaceTypedStructure
- Parameters:
argType
- The Sort descibing the argument type
-
removeArgumentType
public Sort removeArgumentType(int index)
Description copied from interface:TypedStructure
Removes the argument type at the specified index- Specified by:
removeArgumentType
in interfaceTypedStructure
- Parameters:
index
- The index- Returns:
- A reference to the sort that has been remove or null if no sort has been removed.
-
removeArgumentType
public boolean removeArgumentType(Sort argType)
Description copied from interface:TypedStructure
Removes the given Sort from the list of argument types- Specified by:
removeArgumentType
in interfaceTypedStructure
- Parameters:
argType
- The Sort which is removed- Returns:
- true if the Sort exists in the list of argument types and is successfully removed, false otherwise.
-
isTyped
public boolean isTyped()
- Specified by:
isTyped
in interfaceTypedStructure
- Returns:
- true if at least one sort for an argument is not "Thing".
-
isComplete
public boolean isComplete()
- Specified by:
isComplete
in interfaceTypedStructure
- Returns:
- true if the arity of this structure matches the length of it's arguments, false if the arity is bigger than the length of it's arguments.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
copyArgumentTypes
protected java.util.List<Sort> copyArgumentTypes()
-
clone
public abstract TypedStructure clone()
Description copied from interface:TypedStructure
Creates a deep copy of this object- Specified by:
clone
in interfaceTypedStructure
- Overrides:
clone
in classjava.lang.Object
- Returns:
- A deep copy of this object
-
compareTo
public int compareTo(TypedStructureAdapter o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<TypedStructureAdapter>
-
-