001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.jikesrvm.compilers.opt.util;
014
015 import java.util.Enumeration;
016 import java.util.NoSuchElementException;
017
018 /**
019 * Enumeration that doesn't have any elements.
020 * Use the EMPTY object to access.
021 */
022 public final class EmptyEnumerator implements Enumeration<Object> {
023 private static final EmptyEnumerator EMPTY = new EmptyEnumerator();
024
025 @SuppressWarnings({"unchecked", "RedundantCast"})
026 public static <T> Enumeration<T> emptyEnumeration() {
027 return (Enumeration<T>) (Enumeration) EMPTY;
028 }
029
030 public boolean hasMoreElements() {
031 return false;
032 }
033
034 public Object nextElement() {
035 throw new NoSuchElementException();
036 }
037
038 private EmptyEnumerator() {
039 }
040 }
041
042
043