Coverage Summary for Class: DescendingImmutableSortedSet (com.google.common.collect)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| DescendingImmutableSortedSet | 0% (0/1) | 0% (0/16) | 0% (0/20) |
1 /* 2 * Copyright (C) 2012 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.collect; 18 19 import com.google.common.annotations.GwtIncompatible; 20 import org.checkerframework.checker.nullness.qual.Nullable; 21 22 /** 23 * Skeletal implementation of {@link ImmutableSortedSet#descendingSet()}. 24 * 25 * @author Louis Wasserman 26 */ 27 @GwtIncompatible 28 final class DescendingImmutableSortedSet<E> extends ImmutableSortedSet<E> { 29 private final ImmutableSortedSet<E> forward; 30 31 DescendingImmutableSortedSet(ImmutableSortedSet<E> forward) { 32 super(Ordering.from(forward.comparator()).reverse()); 33 this.forward = forward; 34 } 35 36 @Override 37 public boolean contains(@Nullable Object object) { 38 return forward.contains(object); 39 } 40 41 @Override 42 public int size() { 43 return forward.size(); 44 } 45 46 @Override 47 public UnmodifiableIterator<E> iterator() { 48 return forward.descendingIterator(); 49 } 50 51 @Override 52 ImmutableSortedSet<E> headSetImpl(E toElement, boolean inclusive) { 53 return forward.tailSet(toElement, inclusive).descendingSet(); 54 } 55 56 @Override 57 ImmutableSortedSet<E> subSetImpl( 58 E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) { 59 return forward.subSet(toElement, toInclusive, fromElement, fromInclusive).descendingSet(); 60 } 61 62 @Override 63 ImmutableSortedSet<E> tailSetImpl(E fromElement, boolean inclusive) { 64 return forward.headSet(fromElement, inclusive).descendingSet(); 65 } 66 67 @Override 68 @GwtIncompatible("NavigableSet") 69 public ImmutableSortedSet<E> descendingSet() { 70 return forward; 71 } 72 73 @Override 74 @GwtIncompatible("NavigableSet") 75 public UnmodifiableIterator<E> descendingIterator() { 76 return forward.iterator(); 77 } 78 79 @Override 80 @GwtIncompatible("NavigableSet") 81 ImmutableSortedSet<E> createDescendingSet() { 82 throw new AssertionError("should never be called"); 83 } 84 85 @Override 86 public E lower(E element) { 87 return forward.higher(element); 88 } 89 90 @Override 91 public E floor(E element) { 92 return forward.ceiling(element); 93 } 94 95 @Override 96 public E ceiling(E element) { 97 return forward.floor(element); 98 } 99 100 @Override 101 public E higher(E element) { 102 return forward.lower(element); 103 } 104 105 @Override 106 int indexOf(@Nullable Object target) { 107 int index = forward.indexOf(target); 108 if (index == -1) { 109 return index; 110 } else { 111 return size() - 1 - index; 112 } 113 } 114 115 @Override 116 boolean isPartialView() { 117 return forward.isPartialView(); 118 } 119 }