    001    /*
    002     * Copyright (C) 2011 The Guava Authors
    003     *
    004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
    005     * in compliance with the License. You may obtain a copy of the License at
    006     *
    007     * http://www.apache.org/licenses/LICENSE-2.0
    008     *
    009     * Unless required by applicable law or agreed to in writing, software distributed under the License
    010     * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
    011     * or implied. See the License for the specific language governing permissions and limitations under
    012     * the License.
    013     */
    014
    015    package com.google.common.collect;
    016
    017    import com.google.common.annotations.Beta;
    018    import com.google.common.annotations.GwtCompatible;
    019
    020    /**
    021     * Indicates whether an endpoint of some range is contained in the range itself ("closed") or not
    022     * ("open"). If a range is unbounded on a side, it is neither open nor closed on that side; the
    023     * bound simply does not exist.
    024     *
    025     * @since 10.0
    026     */
    027    @Beta
    028    @GwtCompatible
    029    public enum BoundType {
    030      /**
    031       * The endpoint value <i>is not</i> considered part of the set ("exclusive").
    032       */
    033      OPEN {
    034        @Override
    035        BoundType flip() {
    036          return CLOSED;
    037        }
    038      },
    039      /**
    040       * The endpoint value <i>is</i> considered part of the set ("inclusive").
    041       */
    042      CLOSED {
    043        @Override
    044        BoundType flip() {
    045          return OPEN;
    046        }
    047      };
    048
    049      /**
    050       * Returns the bound type corresponding to a boolean value for inclusivity.
    051       */
    052      static BoundType forBoolean(boolean inclusive) {
    053        return inclusive ? CLOSED : OPEN;
    054      }
    055
    056      abstract BoundType flip();
    057    }