/hazelcast-client/src/main/java/com/hazelcast/client/ValueIterator.java

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 45 lines · 22 code · 8 blank · 15 comment · 2 complexity · cc29e989e4175b68dab95edcaab14cd4 MD5 · raw file

  1. /*
  2. * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  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. package com.hazelcast.client;
  17. import java.util.Iterator;
  18. import java.util.Map.Entry;
  19. public class ValueIterator<K, V> implements Iterator<V> {
  20. private final Iterator<Entry<K, V>> entryIterator;
  21. public ValueIterator(Iterator<Entry<K, V>> entryIterator) {
  22. this.entryIterator = entryIterator;
  23. }
  24. public boolean hasNext() {
  25. return entryIterator.hasNext();
  26. }
  27. public V next() {
  28. V next = entryIterator.next().getValue();
  29. if (next == null) {
  30. next = next();
  31. }
  32. return next;
  33. }
  34. public void remove() {
  35. throw new UnsupportedOperationException();
  36. }
  37. };