Coverage Summary for Class: AbstractRangeSet (com.google.common.collect)

Class Class, % Method, % Line, %
AbstractRangeSet 0% (0/1) 0% (0/13) 0% (0/18)


1 /* 2  * Copyright (C) 2011 The Guava Authors 3  * 4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5  * in compliance with the License. You may obtain a copy of the License at 6  * 7  * http://www.apache.org/licenses/LICENSE-2.0 8  * 9  * Unless required by applicable law or agreed to in writing, software distributed under the 10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11  * express or implied. See the License for the specific language governing permissions and 12  * limitations under the License. 13  */ 14  15 package com.google.common.collect; 16  17 import com.google.common.annotations.GwtIncompatible; 18 import org.checkerframework.checker.nullness.qual.Nullable; 19  20 /** 21  * A skeletal implementation of {@code RangeSet}. 22  * 23  * @author Louis Wasserman 24  */ 25 @GwtIncompatible 26 abstract class AbstractRangeSet<C extends Comparable> implements RangeSet<C> { 27  AbstractRangeSet() {} 28  29  @Override 30  public boolean contains(C value) { 31  return rangeContaining(value) != null; 32  } 33  34  @Override 35  public abstract Range<C> rangeContaining(C value); 36  37  @Override 38  public boolean isEmpty() { 39  return asRanges().isEmpty(); 40  } 41  42  @Override 43  public void add(Range<C> range) { 44  throw new UnsupportedOperationException(); 45  } 46  47  @Override 48  public void remove(Range<C> range) { 49  throw new UnsupportedOperationException(); 50  } 51  52  @Override 53  public void clear() { 54  remove(Range.<C>all()); 55  } 56  57  @Override 58  public boolean enclosesAll(RangeSet<C> other) { 59  return enclosesAll(other.asRanges()); 60  } 61  62  @Override 63  public void addAll(RangeSet<C> other) { 64  addAll(other.asRanges()); 65  } 66  67  @Override 68  public void removeAll(RangeSet<C> other) { 69  removeAll(other.asRanges()); 70  } 71  72  @Override 73  public boolean intersects(Range<C> otherRange) { 74  return !subRangeSet(otherRange).isEmpty(); 75  } 76  77  @Override 78  public abstract boolean encloses(Range<C> otherRange); 79  80  @Override 81  public boolean equals(@Nullable Object obj) { 82  if (obj == this) { 83  return true; 84  } else if (obj instanceof RangeSet) { 85  RangeSet<?> other = (RangeSet<?>) obj; 86  return this.asRanges().equals(other.asRanges()); 87  } 88  return false; 89  } 90  91  @Override 92  public final int hashCode() { 93  return asRanges().hashCode(); 94  } 95  96  @Override 97  public final String toString() { 98  return asRanges().toString(); 99  } 100 }