Skip to content

Commit 6abdc20

Browse files
committed
Polish microsphere-projects#161 : Update JavaDoc
1 parent e283f36 commit 6abdc20

1 file changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package io.microsphere.collection;
19+
20+
import java.io.Serializable;
21+
import java.util.Deque;
22+
import java.util.Iterator;
23+
24+
import static io.microsphere.collection.CollectionUtils.unmodifiableIterator;
25+
26+
27+
/**
28+
* An unmodifiable view of a {@link Deque} which wraps a given delegate and prevents any modifications to it.
29+
* <p>
30+
* All mutation operations like {@link #addFirst(Object)}, {@link #remove()}, or {@link #push(Object)} will throw an
31+
* {@link UnsupportedOperationException}.
32+
* </p>
33+
*
34+
* @param <E> the type of elements held in this deque
35+
* @author <a href="mailto:mercyblitz@gmail.com">Mercy<a/>
36+
* @since 1.0.0
37+
*/
38+
public class UnmodifiableDeque<E> extends UnmodifiableQueue<E> implements Deque<E>, Serializable {
39+
40+
private final Deque<E> delegate;
41+
42+
public UnmodifiableDeque(Deque<E> deque) {
43+
super(deque);
44+
this.delegate = deque;
45+
}
46+
47+
@Override
48+
public void addFirst(E e) {
49+
throw new UnsupportedOperationException();
50+
}
51+
52+
@Override
53+
public void addLast(E e) {
54+
throw new UnsupportedOperationException();
55+
}
56+
57+
@Override
58+
public boolean offerFirst(E e) {
59+
throw new UnsupportedOperationException();
60+
}
61+
62+
@Override
63+
public boolean offerLast(E e) {
64+
throw new UnsupportedOperationException();
65+
}
66+
67+
@Override
68+
public E removeFirst() {
69+
throw new UnsupportedOperationException();
70+
}
71+
72+
@Override
73+
public E removeLast() {
74+
throw new UnsupportedOperationException();
75+
}
76+
77+
@Override
78+
public E pollFirst() {
79+
throw new UnsupportedOperationException();
80+
}
81+
82+
@Override
83+
public E pollLast() {
84+
throw new UnsupportedOperationException();
85+
}
86+
87+
@Override
88+
public E getFirst() {
89+
return delegate.getFirst();
90+
}
91+
92+
@Override
93+
public E getLast() {
94+
return delegate.getLast();
95+
}
96+
97+
@Override
98+
public E peekFirst() {
99+
return getFirst();
100+
}
101+
102+
@Override
103+
public E peekLast() {
104+
return getLast();
105+
}
106+
107+
@Override
108+
public boolean removeFirstOccurrence(Object o) {
109+
throw new UnsupportedOperationException();
110+
}
111+
112+
@Override
113+
public boolean removeLastOccurrence(Object o) {
114+
throw new UnsupportedOperationException();
115+
}
116+
117+
@Override
118+
public void push(E e) {
119+
throw new UnsupportedOperationException();
120+
}
121+
122+
@Override
123+
public E pop() {
124+
throw new UnsupportedOperationException();
125+
}
126+
127+
@Override
128+
public Iterator<E> descendingIterator() {
129+
return unmodifiableIterator(delegate.descendingIterator());
130+
}
131+
}

0 commit comments

Comments
 (0)