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

Class Class, % Method, % Line, %
UnmodifiableSortedMultiset 0% (0/1) 0% (0/13) 0% (0/19)


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.GwtCompatible; 20 import com.google.common.collect.Multisets.UnmodifiableMultiset; 21 import java.util.Comparator; 22 import java.util.NavigableSet; 23 import javax.annotation.CheckForNull; 24 import org.checkerframework.checker.nullness.qual.Nullable; 25  26 /** 27  * Implementation of {@link Multisets#unmodifiableSortedMultiset(SortedMultiset)}, split out into 28  * its own file so it can be GWT emulated (to deal with the differing elementSet() types in GWT and 29  * non-GWT). 30  * 31  * @author Louis Wasserman 32  */ 33 @GwtCompatible(emulated = true) 34 @ElementTypesAreNonnullByDefault 35 final class UnmodifiableSortedMultiset<E extends @Nullable Object> extends UnmodifiableMultiset<E> 36  implements SortedMultiset<E> { 37  UnmodifiableSortedMultiset(SortedMultiset<E> delegate) { 38  super(delegate); 39  } 40  41  @Override 42  protected SortedMultiset<E> delegate() { 43  return (SortedMultiset<E>) super.delegate(); 44  } 45  46  @Override 47  public Comparator<? super E> comparator() { 48  return delegate().comparator(); 49  } 50  51  @Override 52  NavigableSet<E> createElementSet() { 53  return Sets.unmodifiableNavigableSet(delegate().elementSet()); 54  } 55  56  @Override 57  public NavigableSet<E> elementSet() { 58  return (NavigableSet<E>) super.elementSet(); 59  } 60  61  @CheckForNull private transient UnmodifiableSortedMultiset<E> descendingMultiset; 62  63  @Override 64  public SortedMultiset<E> descendingMultiset() { 65  UnmodifiableSortedMultiset<E> result = descendingMultiset; 66  if (result == null) { 67  result = new UnmodifiableSortedMultiset<E>(delegate().descendingMultiset()); 68  result.descendingMultiset = this; 69  return descendingMultiset = result; 70  } 71  return result; 72  } 73  74  @Override 75  @CheckForNull 76  public Entry<E> firstEntry() { 77  return delegate().firstEntry(); 78  } 79  80  @Override 81  @CheckForNull 82  public Entry<E> lastEntry() { 83  return delegate().lastEntry(); 84  } 85  86  @Override 87  @CheckForNull 88  public Entry<E> pollFirstEntry() { 89  throw new UnsupportedOperationException(); 90  } 91  92  @Override 93  @CheckForNull 94  public Entry<E> pollLastEntry() { 95  throw new UnsupportedOperationException(); 96  } 97  98  @Override 99  public SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType) { 100  return Multisets.unmodifiableSortedMultiset(delegate().headMultiset(upperBound, boundType)); 101  } 102  103  @Override 104  public SortedMultiset<E> subMultiset( 105  @ParametricNullness E lowerBound, 106  BoundType lowerBoundType, 107  @ParametricNullness E upperBound, 108  BoundType upperBoundType) { 109  return Multisets.unmodifiableSortedMultiset( 110  delegate().subMultiset(lowerBound, lowerBoundType, upperBound, upperBoundType)); 111  } 112  113  @Override 114  public SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType) { 115  return Multisets.unmodifiableSortedMultiset(delegate().tailMultiset(lowerBound, boundType)); 116  } 117  118  private static final long serialVersionUID = 0; 119 }