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 Details

    • iriValue

      default Optional<IRI> iriValue()
      Returns:
      for IRI values, the IRI, else an empty Optional
    • literalValue

      default Optional<OWLLiteral> literalValue()
      Returns:
      for literal values, the literal, else an empty Optional
    • anonymousIndividualValue

      default Optional<OWLAnonymousIndividual> 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 executed
      p - predicate to test
      c - consumer to apply
      r - 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 match
      O - return type
      Parameters:
      witness - class for which predicate and function should be executed
      p - predicate to test
      f - function to apply
      s - 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 match
      O - return type
      Parameters:
      witness - class for which predicate and function should be executed
      p - predicate to test
      f - function to apply
      defaultValue - 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

      default void ifLiteral(Consumer<OWLLiteral> literalConsumer)
      Parameters:
      literalConsumer - consumer to run if the value is a literal
    • ifLiteralOrElse

      default void ifLiteralOrElse(Consumer<OWLLiteral> literalConsumer, Runnable elseAction)
      Parameters:
      literalConsumer - consumer to run if the value is a literal
      elseAction - runnable to run if the value iS not a literal
    • ifIri

      default void ifIri(Consumer<IRI> iriConsumer)
      Parameters:
      iriConsumer - consumer to run if the value is an IRI
    • ifIriOrElse

      default void ifIriOrElse(Consumer<IRI> iriConsumer, Runnable elseAction)
      Parameters:
      iriConsumer - consumer to run if the value is an IRI
      elseAction - runnable to run if the value is not an IRI
    • ifAnonymousIndividual

      default void ifAnonymousIndividual(Consumer<OWLAnonymousIndividual> anonConsumer)
      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 individual
      elseAction - runnable to run if the value is not an anonymous individual
    • mapLiteral

      default <T> Optional<T> mapLiteral(Function<OWLLiteral,T> function)
      Type Parameters:
      T - returned type
      Parameters:
      function - function to run if the value is a literal
      Returns:
      mapped value for literals, empty otherwise
    • mapLiteralOrElse

      default <T> T mapLiteralOrElse(Function<OWLLiteral,T> function, T defaultValue)
      Type Parameters:
      T - returned type
      Parameters:
      function - function to run if the value is a literal
      defaultValue - value returned if the value if not a literal
      Returns:
      mapped value for literals, default value for non literals
    • mapLiteralOrElseGet

      default <T> T mapLiteralOrElseGet(Function<OWLLiteral,T> function, Supplier<T> defaultValue)
      Type Parameters:
      T - returned type
      Parameters:
      function - function to run if the value is a literal
      defaultValue - supplier to run if the value is not a literal
      Returns:
      mapped value for literals, supplier result for non literals
    • mapIri

      default <T> Optional<T> mapIri(Function<IRI,T> function)
      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

      default <T> T mapIriOrElse(Function<IRI,T> function, T defaultValue)
      Type Parameters:
      T - return type
      Parameters:
      function - function to run if the value is an IRI
      defaultValue - default value to return if the value is not an IRI
      Returns:
      mapped value for IRIs, default value for non IRIs
    • mapIriOrElseGet

      default <T> T mapIriOrElseGet(Function<IRI,T> function, Supplier<T> defaultValue)
      Type Parameters:
      T - returned type
      Parameters:
      function - function to run if the value is an IRI
      defaultValue - supplier to run if the value is not an IRI
      Returns:
      mapped value for IRIs, supplier result for non IRIs
    • mapAnonymousIndividual

      default <T> Optional<T> mapAnonymousIndividual(Function<OWLAnonymousIndividual,T> function)
      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 individual
      defaultValue - 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 individual
      defaultValue - 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 literals
      iriConsumer - consumer to run for IRIs
      anonConsumer - 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 literals
      iriFunction - function to run for IRIs
      anonFunction - 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)