Interface Descriptor

All Known Implementing Classes:
AbstractDescriptor, EntityDescriptor, FieldDescriptor, ObjectPropertyCollectionDescriptor

public interface Descriptor
Used to specify additional metadata for entities and their attributes.

Descriptors are composed in a hierarchical structure representing the object graph they describe.

  • Method Details

    • getContexts

      Set<URI> getContexts()
      Gets contexts for this descriptor.

      An empty result indicates the default context.

      Note that for saving, there must be at most one context.

      Returns:
      Context URIs
    • getSingleContext

      Optional<URI> getSingleContext()
      Gets the only context specified by this descriptor.

      This method will check whether there is at most one context specified in this descriptor. If there are none (meaning the default should be used), an empty Optional is returned. If there are more than one, an AmbiguousContextException is thrown.

      This method is intended to be used by data modification operations, which require at most one target context to be specified.

      Returns:
      Single entity context wrapped in Optional, empty, if there is none
      Throws:
      AmbiguousContextException - If there are more than one context specified
    • addContext

      Descriptor addContext(URI context)
      Adds the specified context to this descriptor.

      Note that adding the default context removes all the previously added contexts, as they become obsolete.

      Parameters:
      context - Context to add, null indicates default context
      Returns:
      This instance
    • getLanguage

      String getLanguage()
      Gets the language set for this descriptor.
      Returns:
      Language tag (e.g. en, cs), can be null, meaning any language is supported or the language tag has not been set (see hasLanguage())
    • hasLanguage

      boolean hasLanguage()
      Gets information about whether language tag has been set on this descriptor.

      The language tag can be explicitly set to null, meaning any language is supported. This can be used to override PU-level language setting.

      Returns:
      true if a language tag has been set on this descriptor, false otherwise
    • setLanguage

      Descriptor setLanguage(String languageTag)
      Sets language tag of this descriptor.

      Applies to any possible sub-descriptors as well.

      Parameters:
      languageTag - The language tag to use, possibly null, meaning no language preference should be used
      Returns:
      This instance
      See Also:
    • anyLanguage

      Descriptor anyLanguage()
      Configures this descriptor to support any language tag (including no language tags).

      This is useful for overriding previously set language tag expectations (either on PU level or parent descriptor level).

      This does the same as calling setLanguage(String) with null argument, but is more explicit.

      Returns:
      This instance
    • getAttributeDescriptors

      Collection<Descriptor> getAttributeDescriptors()
      Gets attribute descriptors specified in this descriptor.
      Returns:
      Unmodifiable view of attribute descriptors
    • getAttributeDescriptor

      Descriptor getAttributeDescriptor(FieldSpecification<?,?> attribute)
      Gets descriptor for the specified attribute.
      Parameters:
      attribute - Entity attribute, as specified by the application metamodel
      Returns:
      Descriptor
      Throws:
      IllegalArgumentException - If the descriptor is not available
    • getAttributeContexts

      Set<URI> getAttributeContexts(FieldSpecification<?,?> attribute)
      Gets contexts in which the property assertion(s) of the specified attribute are stored.

      If none are specified for the attribute, contexts of this descriptor are returned.

      Note that for saving a property assertion, there must be at most one context.

      Parameters:
      attribute - Entity attribute, as specified by the application model
      Returns:
      Context identifiers
    • getSingleAttributeContext

      Optional<URI> getSingleAttributeContext(FieldSpecification<?,?> attribute)
      Gets the only context specified by this descriptor for the specified attribute.

      If no context is specified (meaning the default context should be used), an empty Optional is returned.

      If more than one context are available for the specified attribute, an AmbiguousContextException is thrown.

      Parameters:
      attribute - Entity attribute, as specified by the application model
      Returns:
      Context identifier
      Throws:
      AmbiguousContextException - If a unique attribute context cannot be determined
      See Also:
    • addAttributeDescriptor

      Descriptor addAttributeDescriptor(FieldSpecification<?,?> attribute, Descriptor descriptor)
      Adds descriptor for the specified attribute.

      If a descriptor already exists for the specified attribute, it is overridden by the new one.

      Parameters:
      attribute - The attribute to set descriptor for
      descriptor - The descriptor to use
      Returns:
      This instance
    • addAttributeContext

      Descriptor addAttributeContext(FieldSpecification<?,?> attribute, URI context)
      Adds repository context for the specified attribute.

      This in effect means creating a descriptor (if it does not already exist) for the specified field and adding the specified context to it.

      Parameters:
      attribute - The attribute to set context for
      context - The context to set
      Returns:
      This instance
      See Also:
    • setAttributeLanguage

      Descriptor setAttributeLanguage(FieldSpecification<?,?> attribute, String languageTag)
      Sets language to be used when working (retrieving, persisting) with values of the specified attribute.

      Note that setting language in this manner will not have any effect on descriptors of the specified attribute previously retrieved from this descriptor.

      Parameters:
      attribute - The attribute concerned
      languageTag - Language tag to use, possibly null
      Returns:
      This instance
    • areAssertionsInSubjectContext

      boolean areAssertionsInSubjectContext()
      Whether property assertion should be stored in the subject's context (default), or whether they should be stored together with the assertion value.

      This applies to object references, literal values are always stored in the specified context.

      Returns:
      Whether property assertion is stored in the subject context
    • overridesAssertionContext

      default boolean overridesAssertionContext()
      Whether this descriptor overrides assertion context.

      Assertions are typically stored in the subject context, even if their target is in a different context (see areAssertionsInSubjectContext()). However, literal values have to be stored in the assertion context only, so descriptors of fields holding literal values can override the default assertion target context to use the field descriptor context for assertion as well.

      Returns:
      Boolean indicating whether assertion context is based on object descriptor
      See Also:
    • includeInferred

      boolean includeInferred()
      Whether to include inferred statements when loading data corresponding to this descriptor.

      Note that this setting is taken into account only for attributes that are declared as possibly containing inferred values (using the Inferred annotation). For explicit attributes, this setting is ignored.

      The setting in this descriptor is applied recursively to all the descriptors it may be composed of, unless a different value is specified explicitly for them.

      Returns:
      Whether to include inferred values for inferred attributes
      See Also:
    • disableInference

      Descriptor disableInference()
      Instructs this descriptor to specify that only asserted statements should be loaded for otherwise inferred attributes.
      Returns:
      This descriptor
      See Also:
    • enableInference

      Descriptor enableInference()
      Instructs this descriptor to specify that both inferred and asserted statements should be loaded for otherwise inferred attributes.

      This is the default setting.

      Returns:
      This descriptor
      See Also:
    • copy

      Descriptor copy()
      Creates a copy of this descriptor.
      Returns:
      New descriptor with identical values
    • unwrap

      default Descriptor unwrap()
      Unwraps this descriptor if it wraps another descriptor (such as in the case of a collection descriptor).

      If there is nothing to unwrap, the descriptor returns itself.

      Returns:
      Unwrapped descriptor