8042864: Fix raw and unchecked warnings in javax.print
Reviewed-by: prr, henryjen
--- a/jdk/src/share/classes/javax/print/AttributeException.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/AttributeException.java Tue May 20 09:36:22 2014 -0700
@@ -52,7 +52,7 @@
*
* @return unsupported attribute classes
*/
- public Class[] getUnsupportedAttributes();
+ public Class<?>[] getUnsupportedAttributes();
/**
* Returns the array of printing attributes for which the Print Service
--- a/jdk/src/share/classes/javax/print/DocFlavor.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/DocFlavor.java Tue May 20 09:36:22 2014 -0700
@@ -545,8 +545,7 @@
* @exception NullPointerException if paramName is null.
*/
public String getParameter(String paramName) {
- return
- (String)myMimeType.getParameterMap().get(paramName.toLowerCase());
+ return myMimeType.getParameterMap().get(paramName.toLowerCase());
}
/**
--- a/jdk/src/share/classes/javax/print/MimeType.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/MimeType.java Tue May 20 09:36:22 2014 -0700
@@ -117,18 +117,18 @@
/**
* Parameter map entry.
*/
- private class ParameterMapEntry implements Map.Entry {
+ private class ParameterMapEntry implements Map.Entry<String, String> {
private int myIndex;
public ParameterMapEntry(int theIndex) {
myIndex = theIndex;
}
- public Object getKey(){
+ public String getKey(){
return myPieces[myIndex];
}
- public Object getValue(){
+ public String getValue(){
return myPieces[myIndex+1];
}
- public Object setValue (Object value) {
+ public String setValue (String value) {
throw new UnsupportedOperationException();
}
public boolean equals(Object o) {
@@ -145,12 +145,12 @@
/**
* Parameter map entry set iterator.
*/
- private class ParameterMapEntrySetIterator implements Iterator {
+ private class ParameterMapEntrySetIterator implements Iterator<Map.Entry<String, String>> {
private int myIndex = 2;
public boolean hasNext() {
return myIndex < myPieces.length;
}
- public Object next() {
+ public Map.Entry<String, String> next() {
if (hasNext()) {
ParameterMapEntry result = new ParameterMapEntry (myIndex);
myIndex += 2;
@@ -167,8 +167,8 @@
/**
* Parameter map entry set.
*/
- private class ParameterMapEntrySet extends AbstractSet {
- public Iterator iterator() {
+ private class ParameterMapEntrySet extends AbstractSet<Map.Entry<String, String>> {
+ public Iterator<Map.Entry<String, String>> iterator() {
return new ParameterMapEntrySetIterator();
}
public int size() {
@@ -179,8 +179,8 @@
/**
* Parameter map.
*/
- private class ParameterMap extends AbstractMap {
- public Set entrySet() {
+ private class ParameterMap extends AbstractMap<String, String> {
+ public Set<Map.Entry<String, String>> entrySet() {
if (myEntrySet == null) {
myEntrySet = new ParameterMapEntrySet();
}
@@ -234,7 +234,7 @@
*
* @return Parameter map for this MIME type object.
*/
- public Map getParameterMap() {
+ public Map<String, String> getParameterMap() {
if (myParameterMap == null) {
myParameterMap = new ParameterMap();
}
@@ -548,7 +548,7 @@
}
LexicalAnalyzer theLexer = new LexicalAnalyzer (s);
int theLexemeType;
- Vector thePieces = new Vector();
+ Vector<String> thePieces = new Vector<>();
boolean mediaTypeIsText = false;
boolean parameterNameIsCharset = false;
@@ -623,7 +623,7 @@
// Save the pieces. Parameters are not in ascending order yet.
int n = thePieces.size();
- myPieces = (String[]) thePieces.toArray (new String [n]);
+ myPieces = thePieces.toArray (new String [n]);
// Sort the parameters into ascending order using an insertion sort.
int i, j;
--- a/jdk/src/share/classes/javax/print/PrintServiceLookup.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/PrintServiceLookup.java Tue May 20 09:36:22 2014 -0700
@@ -69,8 +69,8 @@
public abstract class PrintServiceLookup {
static class Services {
- private ArrayList listOfLookupServices = null;
- private ArrayList registeredServices = null;
+ private ArrayList<PrintServiceLookup> listOfLookupServices = null;
+ private ArrayList<PrintService> registeredServices = null;
}
private static Services getServicesForContext() {
@@ -83,23 +83,23 @@
return services;
}
- private static ArrayList getListOfLookupServices() {
+ private static ArrayList<PrintServiceLookup> getListOfLookupServices() {
return getServicesForContext().listOfLookupServices;
}
- private static ArrayList initListOfLookupServices() {
- ArrayList listOfLookupServices = new ArrayList();
+ private static ArrayList<PrintServiceLookup> initListOfLookupServices() {
+ ArrayList<PrintServiceLookup> listOfLookupServices = new ArrayList<>();
getServicesForContext().listOfLookupServices = listOfLookupServices;
return listOfLookupServices;
}
- private static ArrayList getRegisteredServices() {
+ private static ArrayList<PrintService> getRegisteredServices() {
return getServicesForContext().registeredServices;
}
- private static ArrayList initRegisteredServices() {
- ArrayList registeredServices = new ArrayList();
+ private static ArrayList<PrintService> initRegisteredServices() {
+ ArrayList<PrintService> registeredServices = new ArrayList<>();
getServicesForContext().registeredServices = registeredServices;
return registeredServices;
}
@@ -120,8 +120,8 @@
public static final PrintService[]
lookupPrintServices(DocFlavor flavor,
AttributeSet attributes) {
- ArrayList list = getServices(flavor, attributes);
- return (PrintService[])(list.toArray(new PrintService[list.size()]));
+ ArrayList<PrintService> list = getServices(flavor, attributes);
+ return list.toArray(new PrintService[list.size()]);
}
@@ -148,9 +148,8 @@
public static final MultiDocPrintService[]
lookupMultiDocPrintServices(DocFlavor[] flavors,
AttributeSet attributes) {
- ArrayList list = getMultiDocServices(flavors, attributes);
- return (MultiDocPrintService[])
- list.toArray(new MultiDocPrintService[list.size()]);
+ ArrayList<MultiDocPrintService> list = getMultiDocServices(flavors, attributes);
+ return list.toArray(new MultiDocPrintService[list.size()]);
}
@@ -177,10 +176,10 @@
public static final PrintService lookupDefaultPrintService() {
- Iterator psIterator = getAllLookupServices().iterator();
+ Iterator<PrintServiceLookup> psIterator = getAllLookupServices().iterator();
while (psIterator.hasNext()) {
try {
- PrintServiceLookup lus = (PrintServiceLookup)psIterator.next();
+ PrintServiceLookup lus = psIterator.next();
PrintService service = lus.getDefaultPrintService();
if (service != null) {
return service;
@@ -208,7 +207,8 @@
*/
public static boolean registerServiceProvider(PrintServiceLookup sp) {
synchronized (PrintServiceLookup.class) {
- Iterator psIterator = getAllLookupServices().iterator();
+ Iterator<PrintServiceLookup> psIterator =
+ getAllLookupServices().iterator();
while (psIterator.hasNext()) {
try {
Object lus = psIterator.next();
@@ -249,7 +249,7 @@
if (service instanceof StreamPrintService) {
return false;
}
- ArrayList registeredServices = getRegisteredServices();
+ ArrayList<PrintService> registeredServices = getRegisteredServices();
if (registeredServices == null) {
registeredServices = initRegisteredServices();
}
@@ -326,9 +326,9 @@
*/
public abstract PrintService getDefaultPrintService();
- private static ArrayList getAllLookupServices() {
+ private static ArrayList<PrintServiceLookup> getAllLookupServices() {
synchronized (PrintServiceLookup.class) {
- ArrayList listOfLookupServices = getListOfLookupServices();
+ ArrayList<PrintServiceLookup> listOfLookupServices = getListOfLookupServices();
if (listOfLookupServices != null) {
return listOfLookupServices;
} else {
@@ -336,12 +336,12 @@
}
try {
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedExceptionAction() {
+ new java.security.PrivilegedExceptionAction<Object>() {
public Object run() {
Iterator<PrintServiceLookup> iterator =
ServiceLoader.load(PrintServiceLookup.class).
iterator();
- ArrayList los = getListOfLookupServices();
+ ArrayList<PrintServiceLookup> los = getListOfLookupServices();
while (iterator.hasNext()) {
try {
los.add(iterator.next());
@@ -364,14 +364,14 @@
}
}
- private static ArrayList getServices(DocFlavor flavor,
- AttributeSet attributes) {
+ private static ArrayList<PrintService> getServices(DocFlavor flavor,
+ AttributeSet attributes) {
- ArrayList listOfServices = new ArrayList();
- Iterator psIterator = getAllLookupServices().iterator();
+ ArrayList<PrintService> listOfServices = new ArrayList<>();
+ Iterator<PrintServiceLookup> psIterator = getAllLookupServices().iterator();
while (psIterator.hasNext()) {
try {
- PrintServiceLookup lus = (PrintServiceLookup)psIterator.next();
+ PrintServiceLookup lus = psIterator.next();
PrintService[] services=null;
if (flavor == null && attributes == null) {
try {
@@ -391,7 +391,7 @@
}
}
/* add any directly registered services */
- ArrayList registeredServices = null;
+ ArrayList<PrintService> registeredServices = null;
try {
SecurityManager security = System.getSecurityManager();
if (security != null) {
@@ -401,8 +401,7 @@
} catch (SecurityException se) {
}
if (registeredServices != null) {
- PrintService[] services = (PrintService[])
- registeredServices.toArray(
+ PrintService[] services = registeredServices.toArray(
new PrintService[registeredServices.size()]);
for (int i=0; i<services.length; i++) {
if (!listOfServices.contains(services[i])) {
@@ -421,15 +420,15 @@
return listOfServices;
}
- private static ArrayList getMultiDocServices(DocFlavor[] flavors,
- AttributeSet attributes) {
+ private static ArrayList<MultiDocPrintService> getMultiDocServices(DocFlavor[] flavors,
+ AttributeSet attributes) {
- ArrayList listOfServices = new ArrayList();
- Iterator psIterator = getAllLookupServices().iterator();
+ ArrayList<MultiDocPrintService> listOfServices = new ArrayList<>();
+ Iterator<PrintServiceLookup> psIterator = getAllLookupServices().iterator();
while (psIterator.hasNext()) {
try {
- PrintServiceLookup lus = (PrintServiceLookup)psIterator.next();
+ PrintServiceLookup lus = psIterator.next();
MultiDocPrintService[] services =
lus.getMultiDocPrintServices(flavors, attributes);
if (services == null) {
@@ -442,7 +441,7 @@
}
}
/* add any directly registered services */
- ArrayList registeredServices = null;
+ ArrayList<PrintService> registeredServices = null;
try {
SecurityManager security = System.getSecurityManager();
if (security != null) {
@@ -452,14 +451,13 @@
} catch (Exception e) {
}
if (registeredServices != null) {
- PrintService[] services = (PrintService[])
- registeredServices.toArray(
- new PrintService[registeredServices.size()]);
+ PrintService[] services =
+ registeredServices.toArray(new PrintService[registeredServices.size()]);
for (int i=0; i<services.length; i++) {
if (services[i] instanceof MultiDocPrintService &&
!listOfServices.contains(services[i])) {
if (flavors == null || flavors.length == 0) {
- listOfServices.add(services[i]);
+ listOfServices.add((MultiDocPrintService)services[i]);
} else {
boolean supported = true;
for (int f=0; f<flavors.length; f++) {
@@ -476,7 +474,7 @@
}
}
if (supported) {
- listOfServices.add(services[i]);
+ listOfServices.add((MultiDocPrintService)services[i]);
}
}
}
--- a/jdk/src/share/classes/javax/print/ServiceUI.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/ServiceUI.java Tue May 20 09:36:22 2014 -0700
@@ -228,9 +228,9 @@
if (dialog.getStatus() == ServiceDialog.APPROVE) {
PrintRequestAttributeSet newas = dialog.getAttributes();
- Class dstCategory = Destination.class;
- Class amCategory = SunAlternateMedia.class;
- Class fdCategory = Fidelity.class;
+ Class<?> dstCategory = Destination.class;
+ Class<?> amCategory = SunAlternateMedia.class;
+ Class<?> fdCategory = Fidelity.class;
if (attributes.containsKey(dstCategory) &&
!newas.containsKey(dstCategory))
@@ -315,7 +315,7 @@
Attribute[] usAttrs = asUnsupported.toArray();
for (int i=0; i<usAttrs.length; i++) {
- Class category = usAttrs[i].getCategory();
+ Class<? extends Attribute> category = usAttrs[i].getCategory();
if (ps.isAttributeCategorySupported(category)) {
Attribute attr =
--- a/jdk/src/share/classes/javax/print/SimpleDoc.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/SimpleDoc.java Tue May 20 09:36:22 2014 -0700
@@ -89,7 +89,7 @@
throw new IllegalArgumentException("null argument(s)");
}
- Class repClass = null;
+ Class<?> repClass = null;
try {
String className = flavor.getRepresentationClassName();
sun.reflect.misc.ReflectUtil.checkPackageAccess(className);
--- a/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java Tue May 20 09:36:22 2014 -0700
@@ -59,7 +59,7 @@
public abstract class StreamPrintServiceFactory {
static class Services {
- private ArrayList listOfFactories = null;
+ private ArrayList<StreamPrintServiceFactory> listOfFactories = null;
}
private static Services getServices() {
@@ -72,12 +72,12 @@
return services;
}
- private static ArrayList getListOfFactories() {
+ private static ArrayList<StreamPrintServiceFactory> getListOfFactories() {
return getServices().listOfFactories;
}
- private static ArrayList initListOfFactories() {
- ArrayList listOfFactories = new ArrayList();
+ private static ArrayList<StreamPrintServiceFactory> initListOfFactories() {
+ ArrayList<StreamPrintServiceFactory> listOfFactories = new ArrayList<>();
getServices().listOfFactories = listOfFactories;
return listOfFactories;
}
@@ -108,9 +108,8 @@
lookupStreamPrintServiceFactories(DocFlavor flavor,
String outputMimeType) {
- ArrayList list = getFactories(flavor, outputMimeType);
- return (StreamPrintServiceFactory[])
- (list.toArray(new StreamPrintServiceFactory[list.size()]));
+ ArrayList<StreamPrintServiceFactory> list = getFactories(flavor, outputMimeType);
+ return list.toArray(new StreamPrintServiceFactory[list.size()]);
}
/** Queries the factory for the document format that is emitted
@@ -162,10 +161,10 @@
public abstract StreamPrintService getPrintService(OutputStream out);
- private static ArrayList getAllFactories() {
+ private static ArrayList<StreamPrintServiceFactory> getAllFactories() {
synchronized (StreamPrintServiceFactory.class) {
- ArrayList listOfFactories = getListOfFactories();
+ ArrayList<StreamPrintServiceFactory> listOfFactories = getListOfFactories();
if (listOfFactories != null) {
return listOfFactories;
} else {
@@ -174,12 +173,12 @@
try {
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedExceptionAction() {
+ new java.security.PrivilegedExceptionAction<Object>() {
public Object run() {
Iterator<StreamPrintServiceFactory> iterator =
ServiceLoader.load
(StreamPrintServiceFactory.class).iterator();
- ArrayList lof = getListOfFactories();
+ ArrayList<StreamPrintServiceFactory> lof = getListOfFactories();
while (iterator.hasNext()) {
try {
lof.add(iterator.next());
@@ -210,17 +209,16 @@
return false;
}
- private static ArrayList getFactories(DocFlavor flavor, String outType) {
+ private static ArrayList<StreamPrintServiceFactory> getFactories(DocFlavor flavor, String outType) {
if (flavor == null && outType == null) {
return getAllFactories();
}
- ArrayList list = new ArrayList();
- Iterator iterator = getAllFactories().iterator();
+ ArrayList<StreamPrintServiceFactory> list = new ArrayList<>();
+ Iterator<StreamPrintServiceFactory> iterator = getAllFactories().iterator();
while (iterator.hasNext()) {
- StreamPrintServiceFactory factory =
- (StreamPrintServiceFactory)iterator.next();
+ StreamPrintServiceFactory factory = iterator.next();
if ((outType == null ||
outType.equalsIgnoreCase(factory.getOutputFormat())) &&
(flavor == null ||
--- a/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java Tue May 20 09:36:22 2014 -0700
@@ -523,7 +523,7 @@
public static Class<?>
verifyAttributeCategory(Object object, Class<?> interfaceName) {
- Class result = (Class) object;
+ Class<?> result = (Class<?>) object;
if (interfaceName.isAssignableFrom (result)) {
return result;
}
--- a/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java Tue May 20 09:36:22 2014 -0700
@@ -48,13 +48,13 @@
* or a subinterface thereof.
* @serial
*/
- private Class myInterface;
+ private Class<?> myInterface;
/*
* A HashMap used by the implementation.
* The serialised form doesn't include this instance variable.
*/
- private transient HashMap attrMap = new HashMap();
+ private transient HashMap<Class<?>, Attribute> attrMap = new HashMap<>();
/**
* Write the instance to a stream (ie serialize the object)
@@ -82,7 +82,7 @@
throws ClassNotFoundException, IOException {
s.defaultReadObject();
- attrMap = new HashMap();
+ attrMap = new HashMap<>();
int count = s.readInt();
Attribute attr;
for (int i = 0; i < count; i++) {
@@ -274,10 +274,9 @@
* Attribute Attribute}.
*/
public Attribute get(Class<?> category) {
- return (Attribute)
- attrMap.get(AttributeSetUtilities.
- verifyAttributeCategory(category,
- Attribute.class));
+ return attrMap.get(AttributeSetUtilities.
+ verifyAttributeCategory(category,
+ Attribute.class));
}
/**
--- a/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java Tue May 20 09:36:22 2014 -0700
@@ -112,7 +112,7 @@
private static int[][] parse(String members) {
// Create vector to hold int[] elements, each element being one range
// parsed out of members.
- Vector theRanges = new Vector();
+ Vector<int[]> theRanges = new Vector<>();
// Run state machine over members.
int n = (members == null ? 0 : members.length());
@@ -243,7 +243,7 @@
* Accumulate the given range (lb .. ub) into the canonical array form
* into the given vector of int[] objects.
*/
- private static void accumulate(Vector ranges, int lb,int ub) {
+ private static void accumulate(Vector<int[]> ranges, int lb,int ub) {
// Make sure range is non-null.
if (lb <= ub) {
// Stick range at the back of the vector.
@@ -253,10 +253,10 @@
// with the existing ranges.
for (int j = ranges.size()-2; j >= 0; -- j) {
// Get lower and upper bounds of the two ranges being compared.
- int[] rangea = (int[]) ranges.elementAt (j);
+ int[] rangea = ranges.elementAt (j);
int lba = rangea[0];
int uba = rangea[1];
- int[] rangeb = (int[]) ranges.elementAt (j+1);
+ int[] rangeb = ranges.elementAt (j+1);
int lbb = rangeb[0];
int ubb = rangeb[1];
@@ -293,8 +293,8 @@
/**
* Convert the given vector of int[] objects to canonical array form.
*/
- private static int[][] canonicalArrayForm(Vector ranges) {
- return (int[][]) ranges.toArray (new int[ranges.size()][]);
+ private static int[][] canonicalArrayForm(Vector<int[]> ranges) {
+ return ranges.toArray (new int[ranges.size()][]);
}
/**
@@ -323,7 +323,7 @@
private static int[][] parse(int[][] members) {
// Create vector to hold int[] elements, each element being one range
// parsed out of members.
- Vector ranges = new Vector();
+ Vector<int[]> ranges = new Vector<>();
// Process all integer groups in members.
int n = (members == null ? 0 : members.length);
--- a/jdk/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java Tue May 20 09:36:22 2014 -0700
@@ -26,6 +26,7 @@
package javax.print.attribute.standard;
import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.Attribute;
import javax.print.attribute.PrintRequestAttribute;
/**
@@ -110,7 +111,7 @@
* @return Printing attribute class (category), an instance of class
* {@link java.lang.Class java.lang.Class}.
*/
- public final Class getCategory() {
+ public final Class<? extends Attribute> getCategory() {
return DialogTypeSelection.class;
}
--- a/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java Tue May 20 09:36:22 2014 -0700
@@ -56,9 +56,9 @@
private MediaSizeName mediaName;
- private static HashMap mediaMap = new HashMap(100, 10);
+ private static HashMap<MediaSizeName, MediaSize> mediaMap = new HashMap<>(100, 10);
- private static Vector sizeVector = new Vector(100, 10);
+ private static Vector<MediaSize> sizeVector = new Vector<>(100, 10);
/**
* Construct a new media size attribute from the given floating-point
@@ -174,7 +174,7 @@
* with any size.
*/
public static MediaSize getMediaSizeForName(MediaSizeName media) {
- return (MediaSize)mediaMap.get(media);
+ return mediaMap.get(media);
}
/**
@@ -213,7 +213,7 @@
float diffy = y;
for (int i=0; i < sizeVector.size() ; i++) {
- MediaSize mediaSize = (MediaSize)sizeVector.elementAt(i);
+ MediaSize mediaSize = sizeVector.elementAt(i);
dim = mediaSize.getSize(units);
if (x == dim[0] && y == dim[1]) {
match = mediaSize;
--- a/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java Mon May 19 23:21:39 2014 +0400
+++ b/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java Tue May 20 09:36:22 2014 -0700
@@ -242,16 +242,18 @@
extends AbstractSet<PrinterStateReason>
{
private Severity mySeverity;
- private Set myEntrySet;
+
+ private Set<Map.Entry<PrinterStateReason, Severity>> myEntrySet;
- public PrinterStateReasonSet(Severity severity, Set entrySet) {
+ public PrinterStateReasonSet(Severity severity,
+ Set<Map.Entry<PrinterStateReason, Severity>> entrySet) {
mySeverity = severity;
myEntrySet = entrySet;
}
public int size() {
int result = 0;
- Iterator iter = iterator();
+ Iterator<PrinterStateReason> iter = iterator();
while (iter.hasNext()) {
iter.next();
++ result;
@@ -259,19 +261,19 @@
return result;
}
- public Iterator iterator() {
+ public Iterator<PrinterStateReason> iterator() {
return new PrinterStateReasonSetIterator(mySeverity,
myEntrySet.iterator());
}
}
- private class PrinterStateReasonSetIterator implements Iterator {
+ private class PrinterStateReasonSetIterator implements Iterator<PrinterStateReason> {
private Severity mySeverity;
- private Iterator myIterator;
- private Map.Entry myEntry;
+ private Iterator<Map.Entry<PrinterStateReason, Severity>> myIterator;
+ private Map.Entry<PrinterStateReason, Severity> myEntry;
public PrinterStateReasonSetIterator(Severity severity,
- Iterator iterator) {
+ Iterator<Map.Entry<PrinterStateReason, Severity>> iterator) {
mySeverity = severity;
myIterator = iterator;
goToNext();
@@ -280,8 +282,8 @@
private void goToNext() {
myEntry = null;
while (myEntry == null && myIterator.hasNext()) {
- myEntry = (Map.Entry) myIterator.next();
- if ((Severity) myEntry.getValue() != mySeverity) {
+ myEntry = myIterator.next();
+ if (myEntry.getValue() != mySeverity) {
myEntry = null;
}
}
@@ -291,11 +293,11 @@
return myEntry != null;
}
- public Object next() {
+ public PrinterStateReason next() {
if (myEntry == null) {
throw new NoSuchElementException();
}
- Object result = myEntry.getKey();
+ PrinterStateReason result = myEntry.getKey();
goToNext();
return result;
}