/** * <p>Answer the cardinality of the restricted property.</p> * @return The cardinality of the restricted property * @exception OntProfileException If the {@link Profile#CARDINALITY_Q()} property is not supported in the current language profile. */ @Override public int getCardinalityQ() { return objectAsInt( getProfile().CARDINALITY_Q(), "CARDINALITY_Q" ); }
/** * <p>Assert that this restriction restricts the property to have the given * cardinality. Any existing statements for <code>cardinalityQ</code> * will be removed.</p> * @param cardinality The cardinality of the restricted property * @exception OntProfileException If the {@link Profile#CARDINALITY_Q()} property is not supported in the current language profile. */ @Override public void setCardinalityQ( int cardinality ) { setPropertyValue( getProfile().CARDINALITY_Q(), "CARDINALITY_Q", getModel().createTypedLiteral( cardinality ) ); }
/** * <p>Remove the statement that this restriction has the given cardinality * for the restricted property. If this statement * is not true of the current model, nothing happens.</p> * @param cardinality A cardinality value to be removed from this restriction * @exception OntProfileException If the {@link Profile#CARDINALITY_Q()} property is not supported in the current language profile. */ @Override public void removeCardinalityQ( int cardinality ) { removePropertyValue( getProfile().CARDINALITY_Q(), "CARDINALITY_Q", getModel().createTypedLiteral( cardinality ) ); }
/** * <p>Answer true if this property restriction has the given cardinality.</p> * @param cardinality The cardinality to test against * @return True if the given cardinality is the cardinality of the restricted property in this restriction * @exception OntProfileException If the {@link Profile#CARDINALITY_Q()} property is not supported in the current language profile. */ @Override public boolean hasCardinalityQ( int cardinality ) { return hasPropertyValue( getProfile().CARDINALITY_Q(), "CARDINALITY_Q", getModel().createTypedLiteral( cardinality ) ); }
/** * <p>Answer a class description defined as the class of those individuals that have exactly * the given number of values for the given property, all values of which belong to the given * class.</p> * * @param uri The optional URI for the restriction, or null for an anonymous restriction (which * should be the normal case) * @param prop The property the restriction applies to * @param cardinality The cardinality of the property * @param cls The class to which all values of the restricted property should belong * @return A new resource representing a mas-cardinality restriction */ @Override public CardinalityQRestriction createCardinalityQRestriction( String uri, Property prop, int cardinality, OntClass cls ) { checkProfileEntry( getProfile().RESTRICTION(), "RESTRICTION" ); checkProfileEntry( getProfile().ON_PROPERTY(), "ON_PROPERTY" ); checkProfileEntry( getProfile().CARDINALITY_Q(), "CARDINALITY_Q" ); checkProfileEntry( getProfile().HAS_CLASS_Q(), "HAS_CLASS_Q" ); if (prop == null) { throw new IllegalArgumentException( "Cannot create CardinalityQRestriction with a null property" ); } if (cls == null) { throw new IllegalArgumentException( "Cannot create CardinalityQRestriction with a null class" ); } Restriction r = createOntResource( Restriction.class, getProfile().RESTRICTION(), uri ); r.addProperty( getProfile().ON_PROPERTY(), prop ); r.addProperty( getProfile().CARDINALITY_Q(), createTypedLiteral( cardinality ) ); r.addProperty( getProfile().HAS_CLASS_Q(), cls ); return r.as( CardinalityQRestriction.class ); }