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

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
Interface CollectionConstraint

All Known Implementing Classes:
  CollectionConstraint.AllValuesIn, CollectionConstraint.And, CollectionConstraint.Contains, CollectionConstraint.Or

    public interface CollectionConstraint

Used by `AnnotationType` to represent the constraint on the collection of values in a property-slot. CollectionConstraints usually use a `PropertyConstraint` to validate the individual elements.

Since:
  1.3
Author:
  Thomas Down, Matthew Pocock
For general use:
  Use one or more of the built-in implementations to build new `AnnotationTypes`.

Nested Class Summary
`static class` | `CollectionConstraint.AllValuesIn` CollectionConstraint which validates all members of a Collection.
`static class` | `CollectionConstraint.And` A collection constraint that accpepts collections iff they are accepted by both child constraints.
`static class` | `CollectionConstraint.Contains` CollectionConstraint which validates a portion of a Collection.
`static class` | `CollectionConstraint.Or` A collection constraint that accepts items iff they are accepted by either child constraints.

Field Summary
`static CollectionConstraint` | `ANY` `ANY` is a constraint which accepts a property for addition under all conditions.
`static CollectionConstraint` | `EMPTY` `EMPTY` is a constraint which only accepts the empty set.
`static CollectionConstraint` | `NONE` `NONE` is a constraint which accepts no value for a property under any condition.

Method Summary
`boolean` | `accept(Object values)` `accept` returns true if the value fulfills the constraint.
`boolean` | `subConstraintOf(CollectionConstraint subConstraint)` `subConstraintOf` returns true if the constraint is a sub-constraint.
`boolean` | `validateAddValue(Collection current, Object newValue)` Return `true` iff the Collection formed by adding `newValue` to `current` would be accepted by this constraint.
`boolean` | `validateRemoveValue(Collection current, Object victim)` Return `true` iff the Collection formed by removing `newValue` from `current` would be accepted by this constraint.

Field Detail

### ANY

    static final CollectionConstraint ANY

  `ANY` is a constraint which accepts a property for addition under all conditions.

  For general use:
    Whenever a CollectionConstraint is needed and you want to allow any value there

### EMPTY

    static final CollectionConstraint EMPTY

  `EMPTY` is a constraint which only accepts the empty set.

  For general use:
    Use this to indicate that a property must be undefined

### NONE

    static final CollectionConstraint NONE

  `NONE` is a constraint which accepts no value for a property under any condition.

  For developers:
    This value indicates an impossible condition. It may be returned by methods such as `AnnotationTools.intersection` to indicate that `NO` values of a property (include undefined) are valid.

Method Detail

### accept

    boolean accept(Object values)

  `accept` returns true if the value fulfills the constraint.

  Parameters:
    `values` - a `Collection` to check.
  Returns:
    true if the values are acceptable
  For advanced users:
    Manually compare items with the CollectionConstraint. Node: this will ususaly be done for you in an AnnotationType instance

### subConstraintOf

    boolean subConstraintOf(CollectionConstraint subConstraint)

  `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.

  Parameters:
    `subConstraint` - a `CollectionConstraint` to check.
  Returns:
    a `boolean`.
  For developers:
    Usefull when attempting to compare two constraints to see if it is necisary to retain both. You may want to check the more general or the more specific constraint only.

### validateAddValue

    boolean validateAddValue(Collection current,
                             Object newValue)

  Return `true` iff the Collection formed by adding `newValue` to `current` would be accepted by this constraint.

  Parameters:
    `current` - 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
  For developers:
    Implementations may not assume that `current` is valid.

### validateRemoveValue

    boolean validateRemoveValue(Collection current,
                                Object victim)

  Return `true` iff the Collection formed by removing `newValue` from `current` would be accepted by this constraint.

  Parameters:
    `current` - a Collection containing the current values
    `victim` - the value to remove
  Returns:
    true if removing the victim will result in an acceptable property value set
  For developers:
    Implementations may not assume that `current` is valid. However, `current` will already have been checked to ensure that it contains `victim`.

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