001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021package org.biojava.bio;
022
023import org.biojava.bio.symbol.Location;
024import org.biojava.bio.symbol.RangeLocation;
025
026/**
027 * A constraint on the number of values a property can have.
028 *
029 * @author Matthew Pocock
030 * @since 1.3
031 *
032 * Usefull constants for whenever you need one of the common
033 * cardinalitites. Otherwise, build a Location using the normal Location
034 * APIs.:
035 */
036public final class CardinalityConstraint {
037  /**
038   * This cardinality contains no intengers, not even zero. It means that there
039   * is no way to fulfill this cardinality constraint. It's like Double.NaN
040   */
041  public static final Location NONE
042    = Location.empty;
043  /**
044   * The property should have zero values. This means that it should be absent.
045   */
046  public static final Location ZERO
047    = new RangeLocation(0, 0);
048  /**
049   * The property should have zero or one values. This means that it is optional
050   * but if present must have exactly one value.
051   */
052  public static final Location ZERO_OR_ONE
053    = new RangeLocation(0, 1);
054  /**
055   * The property can have any number of values, including none.
056   */
057  public static final Location ANY
058    = new RangeLocation(0, Integer.MAX_VALUE);
059  /**
060   * The property should have exactly one value.
061   */
062  public static final Location ONE
063    = new RangeLocation(1, 1);
064  /**
065   * The property should have one or more values. It can not be absent.
066   */
067  public static final Location ONE_OR_MORE
068    = new RangeLocation(1, Integer.MAX_VALUE);
069  
070  private CardinalityConstraint() {}
071}