Property Restrictions in Owl2java

In OWL adding additional rdfs:subclass and owl:equivalentClass constructs allows to define restrictions for properties to a class definition hence augmenting the information model with additional information about the range or cardinality of a property. On this page the handling of property restrictions in owl2java is presented.


A proper handling of all restriction cases is difficult. See the the document Restrictions and Accessor Methods for complex example cases and conculsions.

In the following sections details about the handling of restrictions is presented. Each section starts with a short definition of the key characteristics of the restrictions and moves on to discuss the implications for owl2java.

Restrictions in OWL

According to the OWL DL technical recommendation, for properties the following restrictions are possible:

  • property restrictions
  • restricted cardinality
  • filler information

Property Restrictions

  • allValuesFrom defines a local range restriction for the property defined.
  • someValuesFrom defines that at least one value for the property is of a certain type.

allValuesFrom: Defining multiple property ranges for a certain property may lead to unwanted side effects. E. g. assume a property knows with the ranges Cities and Persons and an instance:

   knows City(Rome)
   knows Person(Paul)

As it can be inferred that the object of the statement is an instance of all classes in the range of the property it follows that Rome and Paul are both of the type City and Person. Not good. Using a restriction of type allValuesFrom it is possible to define that the property knows should only contain values of the types Person or City without incorrect results provided by a reasoner.

For a general purpose java code generator the following problems should be considered:

  • A class adds an allValuesFrom restriction to a property without a domain: If enabled owl2javav changes the domain of the property from owl:thing aka OwlThing to the class where the restriction for the property is defined. If not enabled, see the next point.
  • A subclass adds a second allValuesFrom restriction to a property: In this case owl2java generates new accessor methods (get/set/list) for the subclass named getClassNameR1 etc. The accessor methods of the parent class are also implemented yet are marked as deprecated via the @Deprecated java annotation tag.
  • Multiple allValuesFrom restrictions in a single class: In contrast to the OWL standard, if multiple allValuesFrom restrictions are present a union class is created and added as new range for the property, see the explanation here. Accessor methods named getClassNameR1 etc. are created. Parent accessor methods are marked deprecated.
  • Union, Intersection in a property restriction:. For simple unions and intersections corresponding anonymous classes are created and set as range, see above.

someValuesFrom: Under the Open World Assumption everything that is not explicitly stated as either true or false is not known. Therefore, in OWL someValuesFrom can be used to determine if certain instance types are missing or to derive that an element of this property also has a different class.

With the closed world reasoning done in java imho the only usage scenario for this type of restriction is to deny deletion of an object property or value if it is the last in an instance.

Restricted Cardinality

  • minCardinality states that each instance of the class must have at least the given number of values (datatype property) or instances (object property) for the given property.
  • maxCardinality defines that each instance of the class must not have more than the given number of values (datatype property) or instances (object property) for the given property.
  • cardinality is a convenience definition stating that maxCardinality = minCardinality = cardinality.

Under the closed world assumption using a maxCardinality restriction allows to restrict the maximum permissible number of elements for a property on a certain class. From a java perspective the following cases are relevant:

  • maxCardinality restriction > 1 for a non functional property: If adding an element to the property, the class implementations checks if the maximum number of elements is reached and throws an exception if this is the case.
  • maxCardinality restriction = 1 for a non functional property: This defines the property as functional property for this class and subclasses. All list-style accessor methods are disabled and marked as deprecated via the @Deprecared java annotation tag.
  • maxCardinality restriction = 0 for any property: The property is not allowed for the class. All accessor methods from parent classes / interfaces are disabled and marked as deprecated via the @Deprecated java annotation tag.
  • maxCardinality > 1 for a functional property: The global definition as functional property overrides the local cardinality constraint. Hence, the restriction is ignored.

Similar to the someValuesFrom restriction a minCardinality restriction can be used to disable removal of an element if the minimum permissible number of elements has been reached. Currently, this is *not supported.

As defined in the OWL standard a cardinality restriction is handled as:

 maxCardinality = cardinality
 minCardinality = cardinality

Filler Information

  • hasValue defines that a property has a certain individual as value.

Similar to the someValuesFrom restriction this could be used to lock certain properties, i. e. to deny the removal of the element.