| 1062 | } |
| 1063 | |
| 1064 | private static <E> SortedSet<E> removeOnlySortedSet(final SortedSet<E> set) { |
| 1065 | return new ForwardingSortedSet<E>() { |
| 1066 | @Override |
| 1067 | protected SortedSet<E> delegate() { |
| 1068 | return set; |
| 1069 | } |
| 1070 | |
| 1071 | @Override |
| 1072 | public boolean add(E element) { |
| 1073 | throw new UnsupportedOperationException(); |
| 1074 | } |
| 1075 | |
| 1076 | @Override |
| 1077 | public boolean addAll(Collection<? extends E> es) { |
| 1078 | throw new UnsupportedOperationException(); |
| 1079 | } |
| 1080 | |
| 1081 | @Override |
| 1082 | public SortedSet<E> headSet(E toElement) { |
| 1083 | return removeOnlySortedSet(super.headSet(toElement)); |
| 1084 | } |
| 1085 | |
| 1086 | @Override |
| 1087 | public SortedSet<E> subSet(E fromElement, E toElement) { |
| 1088 | return removeOnlySortedSet(super.subSet(fromElement, toElement)); |
| 1089 | } |
| 1090 | |
| 1091 | @Override |
| 1092 | public SortedSet<E> tailSet(E fromElement) { |
| 1093 | return removeOnlySortedSet(super.tailSet(fromElement)); |
| 1094 | } |
| 1095 | }; |
| 1096 | } |
| 1097 | |
| 1098 | @GwtIncompatible // NavigableSet |
| 1099 | private static <E> NavigableSet<E> removeOnlyNavigableSet(final NavigableSet<E> set) { |