Package org.oristool.util
Class Featurizable<E extends Feature>
java.lang.Object
org.oristool.util.Featurizable<E>
- Type Parameters:
E
- the type of allowed features
- Direct Known Subclasses:
InhibitorArc
,PetriNet
,Place
,Postcondition
,Precondition
,State
,Succession
,Transition
Base implementation of a generic featurizable element.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFeature
(E feature) Adds a feature to this featurizable object.<F extends E>
FgetFeature
(Class<F> typeToken) Returns the feature associated with this object for a given type.Returns the collection of features associated with this object.<F extends E>
booleanhasFeature
(Class<F> typeToken) Returns true if this object has a feature with the given type.<F extends E>
voidremoveFeature
(Class<F> typeToken) Removes the feature with the given type from this object.toString()
-
Field Details
-
features
-
-
Constructor Details
-
Featurizable
public Featurizable()
-
-
Method Details
-
addFeature
Adds a feature to this featurizable object.- Parameters:
feature
- the feature to be added- Throws:
IllegalArgumentException
- if another feature of the same type is already present
-
getFeatures
Returns the collection of features associated with this object.- Returns:
- a collection of features
-
getFeature
Returns the feature associated with this object for a given type.- Type Parameters:
F
- type of the feature- Parameters:
typeToken
- type of feature to be returned- Returns:
- instance of the associated feature, or
null
if not present
-
hasFeature
Returns true if this object has a feature with the given type.- Type Parameters:
F
- type of the feature- Parameters:
typeToken
- type of feature to be checked- Returns:
- true if the feature is present
-
removeFeature
Removes the feature with the given type from this object.- Type Parameters:
F
- type of the feature- Parameters:
typeToken
- type of the feature to be removed
-
toString
-