
HeaderValue prefered = headerValueIterator.hasNext() ? headerValueIterator.next() : null;
</BUG>
while (headerValueIterator.hasNext()) {
<BUG>final HeaderValue next = headerValueIterator.next();
</BUG>
if (next.getQualityFactor() > prefered.getQualityFactor()) {
prefered = next;
}
}

package com.rackspace.papi.commons.util.http.header;
import java.util.Iterator;
public final class QualityFactorUtility {
private QualityFactorUtility() {
}
public static <T extends HeaderValue> T choosePreferedHeaderValue(Iterable<T> headerValues) {
final Iterator<T> headerValueIterator = headerValues.iterator();
T prefered = headerValueIterator.hasNext() ? headerValueIterator.next() : null;
while (headerValueIterator.hasNext()) {
final T next = headerValueIterator.next();
if (next.getQualityFactor() > prefered.getQualityFactor()) {
prefered = next;
}
}
