Package org.semanticweb.owlapi.model
Interface HasAnnotationValue
- All Known Subinterfaces:
OWLAnnotation
,OWLAnnotationAssertionAxiom
,OWLAnnotationValue
,OWLAnonymousIndividual
,OWLLiteral
- All Known Implementing Classes:
IRI
,OWLAnnotationAssertionAxiomImpl
,OWLAnnotationImpl
,OWLAnnotationImplNotAnnotated
,OWLAnonymousIndividualImpl
,OWLLiteralImpl
,OWLLiteralImplBoolean
,OWLLiteralImplDouble
,OWLLiteralImplFloat
,OWLLiteralImplInteger
,OWLLiteralImplLong
,OWLLiteralImplNoCompression
,OWLLiteralImplPlain
,OWLLiteralImplString
public interface HasAnnotationValue
Convenience interface for classes that have an annotation value referred - i.e., annotation
assertion axioms, annotations and annotation values. The annotation value referred is the main
annotation value, nested annotations or annotations on axioms are excluded.
The purpose of these methods is providing stream friendly shortcuts to operate on literals, iris
and anonymous individuals used as values for annotations.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<OWLAnonymousIndividual>
default void
ifAnonymousIndividual
(Consumer<OWLAnonymousIndividual> anonConsumer) default void
ifAnonymousIndividualOrElse
(Consumer<OWLAnonymousIndividual> anonConsumer, Runnable elseAction) default void
default void
ifIriOrElse
(Consumer<IRI> iriConsumer, Runnable elseAction) default void
ifLiteral
(Consumer<OWLLiteral> literalConsumer) default void
ifLiteralOrElse
(Consumer<OWLLiteral> literalConsumer, Runnable elseAction) default void
ifValue
(Consumer<OWLLiteral> literalConsumer, Consumer<IRI> iriConsumer, Consumer<OWLAnonymousIndividual> anonConsumer) iriValue()
default Optional<OWLLiteral>
default <T extends OWLAnnotationValue,
O>
OApply the function if and only if the annotation value is of the specified type and the predicate evaluates to true; the alternative supplier is executed if the predicate does not match or the type does not match (only once if both conditions do not match).default <T extends OWLAnnotationValue,
O>
OApply the function if and only if the annotation value is of the specified type and the predicate evaluates to true; the default value is returned if the predicate does not match or the type does not match.default <T> Optional<T>
mapAnonymousIndividual
(Function<OWLAnonymousIndividual, T> function) default <T> T
mapAnonymousIndividualOrElse
(Function<OWLAnonymousIndividual, T> function, T defaultValue) default <T> T
mapAnonymousIndividualOrElseGet
(Function<OWLAnonymousIndividual, T> function, Supplier<T> defaultValue) default <T> Optional<T>
default <T> T
mapIriOrElse
(Function<IRI, T> function, T defaultValue) default <T> T
mapIriOrElseGet
(Function<IRI, T> function, Supplier<T> defaultValue) default <T> Optional<T>
mapLiteral
(Function<OWLLiteral, T> function) default <T> T
mapLiteralOrElse
(Function<OWLLiteral, T> function, T defaultValue) default <T> T
mapLiteralOrElseGet
(Function<OWLLiteral, T> function, Supplier<T> defaultValue) default <T> Optional<T>
mapValue
(Function<OWLLiteral, T> literalFunction, Function<IRI, T> iriFunction, Function<OWLAnonymousIndividual, T> anonFunction) default <T extends OWLAnnotationValue>
voidExecute the consumer if and only if the annotation value is of the specified type and the predicate evaluates to true; the alternative runnable is executed if the predicate does not match or the type does not match (only once if both conditions do not match).
-
Method Details
-
iriValue
- Returns:
- for IRI values, the IRI, else an empty Optional
-
literalValue
- Returns:
- for literal values, the literal, else an empty Optional
-
anonymousIndividualValue
- Returns:
- for anonymous individual values, the individual, else an empty Optional
-
annotationValue
OWLAnnotationValue annotationValue()- Returns:
- the annotation value itself; this method allows OWLAnnotationAssertionAxiom and OWLAnnotation to use the default methods rather than replicate the methods. For OWLAnnotationValue instances, the value returned is the object itself.
-
when
default <T extends OWLAnnotationValue> void when(Class<T> witness, Predicate<T> p, Consumer<T> c, Runnable r) Execute the consumer if and only if the annotation value is of the specified type and the predicate evaluates to true; the alternative runnable is executed if the predicate does not match or the type does not match (only once if both conditions do not match).- Type Parameters:
T
- type- Parameters:
witness
- class for which predicate and consumer should be executedp
- predicate to testc
- consumer to applyr
- runnable to execute if the predicate does not match or the annotation type does not match
-
map
default <T extends OWLAnnotationValue,O> O map(Class<T> witness, Predicate<T> p, Function<T, O> f, Supplier<O> s) Apply the function if and only if the annotation value is of the specified type and the predicate evaluates to true; the alternative supplier is executed if the predicate does not match or the type does not match (only once if both conditions do not match).- Type Parameters:
T
- type to matchO
- return type- Parameters:
witness
- class for which predicate and function should be executedp
- predicate to testf
- function to applys
- supplier to execute if the predicate does not match or the annotation type does not match- Returns:
- function result or supplier result, depending on predicate evaluation
-
map
default <T extends OWLAnnotationValue,O> O map(Class<T> witness, Predicate<T> p, Function<T, O> f, O defaultValue) Apply the function if and only if the annotation value is of the specified type and the predicate evaluates to true; the default value is returned if the predicate does not match or the type does not match.- Type Parameters:
T
- type to matchO
- return type- Parameters:
witness
- class for which predicate and function should be executedp
- predicate to testf
- function to applydefaultValue
- default value to return if the predicate does not match or the annotation type does not match- Returns:
- function result or default value, depending on predicate evaluation
-
ifLiteral
- Parameters:
literalConsumer
- consumer to run if the value is a literal
-
ifLiteralOrElse
- Parameters:
literalConsumer
- consumer to run if the value is a literalelseAction
- runnable to run if the value iS not a literal
-
ifIri
- Parameters:
iriConsumer
- consumer to run if the value is an IRI
-
ifIriOrElse
- Parameters:
iriConsumer
- consumer to run if the value is an IRIelseAction
- runnable to run if the value is not an IRI
-
ifAnonymousIndividual
- Parameters:
anonConsumer
- consumer to run if the value is an anonymous individual
-
ifAnonymousIndividualOrElse
default void ifAnonymousIndividualOrElse(Consumer<OWLAnonymousIndividual> anonConsumer, Runnable elseAction) - Parameters:
anonConsumer
- consumer to run if the value is an anonymous individualelseAction
- runnable to run if the value is not an anonymous individual
-
mapLiteral
- Type Parameters:
T
- returned type- Parameters:
function
- function to run if the value is a literal- Returns:
- mapped value for literals, empty otherwise
-
mapLiteralOrElse
- Type Parameters:
T
- returned type- Parameters:
function
- function to run if the value is a literaldefaultValue
- value returned if the value if not a literal- Returns:
- mapped value for literals, default value for non literals
-
mapLiteralOrElseGet
- Type Parameters:
T
- returned type- Parameters:
function
- function to run if the value is a literaldefaultValue
- supplier to run if the value is not a literal- Returns:
- mapped value for literals, supplier result for non literals
-
mapIri
- Type Parameters:
T
- returned type- Parameters:
function
- function to run if the value is an IRI- Returns:
- mapped value for IRIs, empty for non IRIs
-
mapIriOrElse
- Type Parameters:
T
- return type- Parameters:
function
- function to run if the value is an IRIdefaultValue
- default value to return if the value is not an IRI- Returns:
- mapped value for IRIs, default value for non IRIs
-
mapIriOrElseGet
- Type Parameters:
T
- returned type- Parameters:
function
- function to run if the value is an IRIdefaultValue
- supplier to run if the value is not an IRI- Returns:
- mapped value for IRIs, supplier result for non IRIs
-
mapAnonymousIndividual
- Type Parameters:
T
- returned type- Parameters:
function
- function to run if the value is an anonymous individual- Returns:
- mapped value for anonymous individuals, empty for non individuals
-
mapAnonymousIndividualOrElse
default <T> T mapAnonymousIndividualOrElse(Function<OWLAnonymousIndividual, T> function, T defaultValue) - Type Parameters:
T
- returned type- Parameters:
function
- function to run if the value is an anonymous individualdefaultValue
- default value to if the value is not an anonymous individual- Returns:
- mapped value for anonymous individuals, default value for non individuals
-
mapAnonymousIndividualOrElseGet
default <T> T mapAnonymousIndividualOrElseGet(Function<OWLAnonymousIndividual, T> function, Supplier<T> defaultValue) - Type Parameters:
T
- returned type- Parameters:
function
- function to run if the value is an anonymous individualdefaultValue
- supplier to run if the value is not an anonymous individual- Returns:
- mapped value for anonymous individuals, supplier result for non individuals
-
ifValue
default void ifValue(Consumer<OWLLiteral> literalConsumer, Consumer<IRI> iriConsumer, Consumer<OWLAnonymousIndividual> anonConsumer) - Parameters:
literalConsumer
- consumer to run for literalsiriConsumer
- consumer to run for IRIsanonConsumer
- consumer to run for anonymous individuals
-
mapValue
default <T> Optional<T> mapValue(Function<OWLLiteral, T> literalFunction, Function<IRI, T> iriFunction, Function<OWLAnonymousIndividual, T> anonFunction) - Type Parameters:
T
- returned type- Parameters:
literalFunction
- function to run for literalsiriFunction
- function to run for IRIsanonFunction
- function to run for anonymous individuals- Returns:
- mapped value, or empty if none matches (currently there will be always one matching function, but the creation of a new OWLAnnotationValue subinterface would change that)
-