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
015package com.google.common.collect;
016
017import com.google.common.annotations.GwtCompatible;
018
019/**
020 * Indicates whether an endpoint of some range is contained in the range itself ("closed") or not
021 * ("open"). If a range is unbounded on a side, it is neither open nor closed on that side; the
022 * bound simply does not exist.
023 *
024 * @since 10.0
025 */
026@GwtCompatible
027public enum BoundType {
028  /**
029   * The endpoint value <i>is not</i> considered part of the set ("exclusive").
030   */
031  OPEN {
032    @Override
033    BoundType flip() {
034      return CLOSED;
035    }
036  },
037  /**
038   * The endpoint value <i>is</i> considered part of the set ("inclusive").
039   */
040  CLOSED {
041    @Override
042    BoundType flip() {
043      return OPEN;
044    }
045  };
046
047  /**
048   * Returns the bound type corresponding to a boolean value for inclusivity.
049   */
050  static BoundType forBoolean(boolean inclusive) {
051    return inclusive ? CLOSED : OPEN;
052  }
053
054  abstract BoundType flip();
055}