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 027@ElementTypesAreNonnullByDefault 028public enum BoundType { 029 /** The endpoint value <i>is not</i> considered part of the set ("exclusive"). */ 030 OPEN(false), 031 CLOSED(true); 032 033 final boolean inclusive; 034 035 BoundType(boolean inclusive) { 036 this.inclusive = inclusive; 037 } 038 039 /** Returns the bound type corresponding to a boolean value for inclusivity. */ 040 static BoundType forBoolean(boolean inclusive) { 041 return inclusive ? CLOSED : OPEN; 042 } 043}