CollectionConstraint.Contains (BioJava-1.5-beta API)
Keywords: org.biojava.bio.CollectionConstraint.Contains class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.biojava.bio
Class CollectionConstraint.Contains

    java.lang.Object
      org.biojava.bio.CollectionConstraint.Contains

All Implemented Interfaces:
  CollectionConstraint

Enclosing interface:
  CollectionConstraint

    public static class CollectionConstraint.Contains

extends Object
implements CollectionConstraint

CollectionConstraint which validates a portion of a Collection. Accepts only collections where the number of members matching the `PropertyConstraint` is in the supplied cardinality.

A typical application for this would be with Annotations where one property can contain a number of synonyms. `CollectionConstraint.Contains` could be used as a query to select instances based on one of these synonyms.

Author:
  Thomas Down

Nested Class Summary

Nested classes/interfaces inherited from interface org.biojava.bio.CollectionConstraint
`CollectionConstraint.AllValuesIn, CollectionConstraint.And, CollectionConstraint.Contains, CollectionConstraint.Or`

Field Summary

Fields inherited from interface org.biojava.bio.CollectionConstraint
`ANY, EMPTY, NONE`

Constructor Summary
`CollectionConstraint.Contains(PropertyConstraint pc, Location card)` Create a Contains based upon a PropertyConstraint and a cardinality.

Method Summary
`boolean` | `accept(Object o)` `accept` returns true if the value fulfills the constraint.
`boolean` | `equals(Object o)`
`Location` | `getCardinalityConstraint()` Get the cardinality constraint used to validate the number of property values.
`PropertyConstraint` | `getPropertyConstraint()` Get the PropertyConstraint used to validate each property value.
`int` | `hashCode()`
`boolean` | `subConstraintOf(CollectionConstraint cc)` `subConstraintOf` returns true if the constraint is a sub-constraint.
`String` | `toString()`
`boolean` | `validateAddValue(Collection oldCol, Object newValue)` Return `true` iff the Collection formed by adding `newValue` to `current` would be accepted by this constraint.
`boolean` | `validateRemoveValue(Collection oldCol, Object newValue)` Return `true` iff the Collection formed by removing `newValue` from `current` would be accepted by this constraint.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### CollectionConstraint.Contains

    public CollectionConstraint.Contains(PropertyConstraint pc,
                                         Location card)

  Create a Contains based upon a PropertyConstraint and a cardinality.

  Parameters:
    `pc` - the PropertyConstraint to apply to each property value
    `card` - the cardinality constraint restricting the number of values

Method Detail

### getPropertyConstraint

    public PropertyConstraint getPropertyConstraint()

  Get the PropertyConstraint used to validate each property value.

  Returns:
    the PropertyConstraint used

### getCardinalityConstraint

    public Location getCardinalityConstraint()

  Get the cardinality constraint used to validate the number of property values.

  Returns:
    the cardinality constraint as a Location

### accept

    public boolean accept(Object o)

  Description copied from interface: `CollectionConstraint`
  `accept` returns true if the value fulfills the constraint.

  Specified by:
    `accept` in interface `CollectionConstraint`
  Parameters:
    `o` - a `Collection` to check.
  Returns:
    true if the values are acceptable

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object o)

  Overrides:
    `equals` in class `Object`

### validateAddValue

    public boolean validateAddValue(Collection oldCol,
                                    Object newValue)

  Description copied from interface: `CollectionConstraint`
  Return `true` iff the Collection formed by adding `newValue` to `current` would be accepted by this constraint.

  Specified by:
    `validateAddValue` in interface `CollectionConstraint`
  Parameters:
    `oldCol` - a Collection containing the current values
    `newValue` - the new value to add
  Returns:
    true if adding the new value will result in an acceptable property

### validateRemoveValue

    public boolean validateRemoveValue(Collection oldCol,
                                       Object newValue)

  Description copied from interface: `CollectionConstraint`
  Return `true` iff the Collection formed by removing `newValue` from `current` would be accepted by this constraint.

  Specified by:
    `validateRemoveValue` in interface `CollectionConstraint`
  Parameters:
    `oldCol` - a Collection containing the current values
    `newValue` - the value to remove
  Returns:
    true if removing the victim will result in an acceptable property value set

### subConstraintOf

    public boolean subConstraintOf(CollectionConstraint cc)

  Description copied from interface: `CollectionConstraint`

  `subConstraintOf` returns true if the constraint is a sub-constraint.

  A pair of constraints super and sub are in a superConstraint/subConstraint relationship if every object accepted by sub is also accepted by super. To put it another way, if instanceOf was used as a set-membership indicator function over some set of objects, then the set produced by super would be a superset of that produced by sub.

  It is not expected that constraints will neccesarily maintain references to super/sub types. It will be more usual to infer this relationship by introspecting the constraints themselves. For example, `CollectionConstraint.ByClass` will infer subConstraintOf by looking at the possible class of all items matching subConstraint.

  Specified by:
    `subConstraintOf` in interface `CollectionConstraint`
  Parameters:
    `cc` - a `CollectionConstraint` to check.
  Returns:
    a `boolean`.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD