Class AbstractDescriptor
- All Implemented Interfaces:
Descriptor
- Direct Known Subclasses:
EntityDescriptor
,FieldDescriptor
The descriptor hierarchy is a classical Composite pattern.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AbstractDescriptor
(boolean assertionsInSubjectContext) protected
AbstractDescriptor
(URI context) protected
AbstractDescriptor
(URI context, boolean assertionsInSubjectContext) protected
AbstractDescriptor
(Set<URI> contexts, boolean assertionsInSubjectContext, String language, boolean hasLanguage, boolean includeInferred) -
Method Summary
Modifier and TypeMethodDescriptionaddContext
(URI context) Adds the specified context to this descriptor.Configures this descriptor to support any language tag (including no language tags).boolean
Whether property assertion should be stored in the subject's context (default), or whether they should be stored together with the assertion value.Instructs this descriptor to specify that only asserted statements should be loaded for otherwise inferred attributes.Instructs this descriptor to specify that both inferred and asserted statements should be loaded for otherwise inferred attributes.boolean
protected boolean
equals
(Object other, Map<AbstractDescriptor.VisitedPair, Boolean> visited) protected boolean
equalsImpl
(Object o) Gets contexts for this descriptor.Gets the language set for this descriptor.getSingleAttributeContext
(FieldSpecification<?, ?> attribute) Gets the only context specified by this descriptor for the specified attribute.Gets the only context specified by this descriptor.int
hashCode()
protected int
protected int
boolean
Gets information about whether language tag has been set on this descriptor.boolean
Whether to include inferred statements when loading data corresponding to this descriptor.protected void
setIncludeInferred
(boolean includeInferred) setLanguage
(String languageTag) Sets language tag of this descriptor.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface cz.cvut.kbss.jopa.model.descriptors.Descriptor
addAttributeContext, addAttributeDescriptor, copy, getAttributeContexts, getAttributeDescriptor, getAttributeDescriptors, overridesAssertionContext, setAttributeLanguage, unwrap
-
Field Details
-
contexts
-
assertionsInSubjectContext
protected final boolean assertionsInSubjectContext
-
-
Constructor Details
-
AbstractDescriptor
protected AbstractDescriptor() -
AbstractDescriptor
protected AbstractDescriptor(boolean assertionsInSubjectContext) -
AbstractDescriptor
-
AbstractDescriptor
-
AbstractDescriptor
-
-
Method Details
-
getContexts
Description copied from interface:Descriptor
Gets contexts for this descriptor.An empty result indicates the default context.
Note that for saving, there must be at most one context.
- Specified by:
getContexts
in interfaceDescriptor
- Returns:
- Context URIs
-
getSingleContext
Description copied from interface:Descriptor
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, anAmbiguousContextException
is thrown.This method is intended to be used by data modification operations, which require at most one target context to be specified.
- Specified by:
getSingleContext
in interfaceDescriptor
- Returns:
- Single entity context wrapped in
Optional
, empty, if there is none
-
addContext
Description copied from interface:Descriptor
Adds the specified context to this descriptor.Note that adding the default context removes all the previously added contexts, as they become obsolete.
- Specified by:
addContext
in interfaceDescriptor
- Parameters:
context
- Context to add,null
indicates default context- Returns:
- This instance
-
getSingleAttributeContext
Description copied from interface:Descriptor
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.- Specified by:
getSingleAttributeContext
in interfaceDescriptor
- Parameters:
attribute
- Entity attribute, as specified by the application model- Returns:
- Context identifier
- See Also:
-
getLanguage
Description copied from interface:Descriptor
Gets the language set for this descriptor.- Specified by:
getLanguage
in interfaceDescriptor
- Returns:
- Language tag (e.g. en, cs), can be
null
, meaning any language is supported or the language tag has not been set (seeDescriptor.hasLanguage()
)
-
hasLanguage
public boolean hasLanguage()Description copied from interface:Descriptor
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.- Specified by:
hasLanguage
in interfaceDescriptor
- Returns:
true
if a language tag has been set on this descriptor,false
otherwise
-
setLanguage
Description copied from interface:Descriptor
Sets language tag of this descriptor.Applies to any possible sub-descriptors as well.
- Specified by:
setLanguage
in interfaceDescriptor
- Parameters:
languageTag
- The language tag to use, possiblynull
, meaning no language preference should be used- Returns:
- This instance
- See Also:
-
anyLanguage
Description copied from interface:Descriptor
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
Descriptor.setLanguage(String)
withnull
argument, but is more explicit.- Specified by:
anyLanguage
in interfaceDescriptor
- Returns:
- This instance
-
areAssertionsInSubjectContext
public boolean areAssertionsInSubjectContext()Description copied from interface:Descriptor
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.
- Specified by:
areAssertionsInSubjectContext
in interfaceDescriptor
- Returns:
- Whether property assertion is stored in the subject context
-
includeInferred
public boolean includeInferred()Description copied from interface:Descriptor
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.
- Specified by:
includeInferred
in interfaceDescriptor
- Returns:
- Whether to include inferred values for inferred attributes
- See Also:
-
disableInference
Description copied from interface:Descriptor
Instructs this descriptor to specify that only asserted statements should be loaded for otherwise inferred attributes.- Specified by:
disableInference
in interfaceDescriptor
- Returns:
- This descriptor
- See Also:
-
enableInference
Description copied from interface:Descriptor
Instructs this descriptor to specify that both inferred and asserted statements should be loaded for otherwise inferred attributes.This is the default setting.
- Specified by:
enableInference
in interfaceDescriptor
- Returns:
- This descriptor
- See Also:
-
setIncludeInferred
protected void setIncludeInferred(boolean includeInferred) -
equals
-
equalsImpl
-
equals
-
hashCode
public int hashCode() -
hashCodeImpl
protected int hashCodeImpl() -
hashCode
-
toString
-