| 1034 | } |
| 1035 | |
| 1036 | private static <E> SortedSet<E> removeOnlySortedSet(final SortedSet<E> set) { |
| 1037 | return new ForwardingSortedSet<E>() { |
| 1038 | @Override |
| 1039 | protected SortedSet<E> delegate() { |
| 1040 | return set; |
| 1041 | } |
| 1042 | |
| 1043 | @Override |
| 1044 | public boolean add(E element) { |
| 1045 | throw new UnsupportedOperationException(); |
| 1046 | } |
| 1047 | |
| 1048 | @Override |
| 1049 | public boolean addAll(Collection<? extends E> es) { |
| 1050 | throw new UnsupportedOperationException(); |
| 1051 | } |
| 1052 | |
| 1053 | @Override |
| 1054 | public SortedSet<E> headSet(E toElement) { |
| 1055 | return removeOnlySortedSet(super.headSet(toElement)); |
| 1056 | } |
| 1057 | |
| 1058 | @Override |
| 1059 | public SortedSet<E> subSet(E fromElement, E toElement) { |
| 1060 | return removeOnlySortedSet(super.subSet(fromElement, toElement)); |
| 1061 | } |
| 1062 | |
| 1063 | @Override |
| 1064 | public SortedSet<E> tailSet(E fromElement) { |
| 1065 | return removeOnlySortedSet(super.tailSet(fromElement)); |
| 1066 | } |
| 1067 | }; |
| 1068 | } |
| 1069 | |
| 1070 | @GwtIncompatible // NavigableSet |
| 1071 | private static <E> NavigableSet<E> removeOnlyNavigableSet(final NavigableSet<E> set) { |