Nicer solution to generic array creation (still problematic in Java 6, but correct in Java 7 if done this way)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1366832 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-07-29 12:36:14 +00:00
parent 8318dff526
commit c6455c6da2
1 changed files with 7 additions and 3 deletions

View File

@ -160,11 +160,15 @@ public class TestSubScorerFreqs extends LuceneTestCase {
query.add(inner, Occur.MUST);
query.add(aQuery, Occur.MUST);
query.add(dQuery, Occur.MUST);
@SuppressWarnings({"unchecked","rawtypes"}) Set<String>[] occurList = new Set[] {
// Only needed in Java6; Java7+ has a @SafeVarargs annotated Arrays#asList()!
// see http://docs.oracle.com/javase/7/docs/api/java/lang/SafeVarargs.html
@SuppressWarnings("unchecked") final Iterable<Set<String>> occurList = Arrays.asList(
Collections.singleton("MUST"),
new HashSet<String>(Arrays.asList("MUST", "SHOULD"))
};
for (Set<String> occur : occurList) {
);
for (final Set<String> occur : occurList) {
CountingCollector c = new CountingCollector(TopScoreDocCollector.create(
10, true), occur);
s.search(query, null, c);