mirror of
https://github.com/apache/lucene.git
synced 2025-02-11 20:45:27 +00:00
LUCENE-4519: remove generics wildcards from the return types of IndexDocument methods.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1405639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
463a478a11
commit
4c10042be4
@ -138,9 +138,8 @@ public final class Document implements IndexDocument {
|
|||||||
*/
|
*/
|
||||||
public final BytesRef[] getBinaryValues(String name) {
|
public final BytesRef[] getBinaryValues(String name) {
|
||||||
final List<BytesRef> result = new ArrayList<BytesRef>();
|
final List<BytesRef> result = new ArrayList<BytesRef>();
|
||||||
Iterator<Field> it = storedFieldsIterator();
|
|
||||||
|
for (Iterator<StorableField> it = storedFieldsIterator(); it.hasNext(); ) {
|
||||||
while (it.hasNext()) {
|
|
||||||
StorableField field = it.next();
|
StorableField field = it.next();
|
||||||
if (field.name().equals(name)) {
|
if (field.name().equals(name)) {
|
||||||
final BytesRef bytes = field.binaryValue();
|
final BytesRef bytes = field.binaryValue();
|
||||||
@ -163,9 +162,7 @@ public final class Document implements IndexDocument {
|
|||||||
* @return a <code>BytesRef</code> containing the binary field value or <code>null</code>
|
* @return a <code>BytesRef</code> containing the binary field value or <code>null</code>
|
||||||
*/
|
*/
|
||||||
public final BytesRef getBinaryValue(String name) {
|
public final BytesRef getBinaryValue(String name) {
|
||||||
Iterator<Field> it = storedFieldsIterator();
|
for (Iterator<StorableField> it = storedFieldsIterator(); it.hasNext(); ) {
|
||||||
|
|
||||||
while (it.hasNext()) {
|
|
||||||
StorableField field = it.next();
|
StorableField field = it.next();
|
||||||
if (field.name().equals(name)) {
|
if (field.name().equals(name)) {
|
||||||
final BytesRef bytes = field.binaryValue();
|
final BytesRef bytes = field.binaryValue();
|
||||||
@ -235,9 +232,8 @@ public final class Document implements IndexDocument {
|
|||||||
*/
|
*/
|
||||||
public final String[] getValues(String name) {
|
public final String[] getValues(String name) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
Iterator<Field> it = storedFieldsIterator();
|
|
||||||
|
for (Iterator<StorableField> it = storedFieldsIterator(); it.hasNext(); ) {
|
||||||
while (it.hasNext()) {
|
|
||||||
StorableField field = it.next();
|
StorableField field = it.next();
|
||||||
if (field.name().equals(name) && field.stringValue() != null) {
|
if (field.name().equals(name) && field.stringValue() != null) {
|
||||||
result.add(field.stringValue());
|
result.add(field.stringValue());
|
||||||
@ -260,9 +256,7 @@ public final class Document implements IndexDocument {
|
|||||||
* the actual numeric field instance back, use {@link #getField}.
|
* the actual numeric field instance back, use {@link #getField}.
|
||||||
*/
|
*/
|
||||||
public final String get(String name) {
|
public final String get(String name) {
|
||||||
Iterator<Field> it = storedFieldsIterator();
|
for (Iterator<StorableField> it = storedFieldsIterator(); it.hasNext(); ) {
|
||||||
|
|
||||||
while (it.hasNext()) {
|
|
||||||
StorableField field = it.next();
|
StorableField field = it.next();
|
||||||
if (field.name().equals(name) && field.stringValue() != null) {
|
if (field.name().equals(name) && field.stringValue() != null) {
|
||||||
return field.stringValue();
|
return field.stringValue();
|
||||||
@ -288,29 +282,28 @@ public final class Document implements IndexDocument {
|
|||||||
|
|
||||||
/** Obtains all indexed fields in document */
|
/** Obtains all indexed fields in document */
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends IndexableField> indexableFields() {
|
public Iterable<IndexableField> indexableFields() {
|
||||||
return new Iterable<Field>() {
|
return new Iterable<IndexableField>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Field> iterator() {
|
public Iterator<IndexableField> iterator() {
|
||||||
return Document.this.indexedFieldsIterator();
|
return Document.this.indexedFieldsIterator();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Obtains all stored fields in document. */
|
/** Obtains all stored fields in document. */
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends StorableField> storableFields() {
|
public Iterable<StorableField> storableFields() {
|
||||||
return new Iterable<Field>() {
|
return new Iterable<StorableField>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Field> iterator() {
|
public Iterator<StorableField> iterator() {
|
||||||
return Document.this.storedFieldsIterator();
|
return Document.this.storedFieldsIterator();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterator<Field> storedFieldsIterator() {
|
private Iterator<StorableField> storedFieldsIterator() {
|
||||||
return new FilterIterator<Field>(fields.iterator()) {
|
return new FilterIterator<StorableField, Field>(fields.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(Field field) {
|
protected boolean predicateFunction(Field field) {
|
||||||
return field.type.stored() || field.type.docValueType() != null;
|
return field.type.stored() || field.type.docValueType() != null;
|
||||||
@ -318,8 +311,8 @@ public final class Document implements IndexDocument {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterator<Field> indexedFieldsIterator() {
|
private Iterator<IndexableField> indexedFieldsIterator() {
|
||||||
return new FilterIterator<Field>(fields.iterator()) {
|
return new FilterIterator<IndexableField, Field>(fields.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(Field field) {
|
protected boolean predicateFunction(Field field) {
|
||||||
return field.type.indexed();
|
return field.type.indexed();
|
||||||
|
@ -24,8 +24,8 @@ package org.apache.lucene.index;
|
|||||||
public interface IndexDocument {
|
public interface IndexDocument {
|
||||||
|
|
||||||
/** Obtains all indexable fields in document */
|
/** Obtains all indexable fields in document */
|
||||||
public Iterable<? extends IndexableField> indexableFields();
|
public Iterable<IndexableField> indexableFields();
|
||||||
|
|
||||||
/** Obtains all storable fields in document */
|
/** Obtains all storable fields in document */
|
||||||
public Iterable<? extends StorableField> storableFields();
|
public Iterable<StorableField> storableFields();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package org.apache.lucene.util;
|
package org.apache.lucene.util;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with this
|
* contributor license agreements. See the NOTICE file distributed with this
|
||||||
@ -20,20 +17,26 @@ import java.util.NoSuchElementException;
|
|||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link Iterator} implementation that filters elements with a boolean predicate.
|
* An {@link Iterator} implementation that filters elements with a boolean predicate.
|
||||||
|
*
|
||||||
|
* @param <T> generic parameter for this iterator instance: this iterator implements {@link Iterator Iterator<T>}
|
||||||
|
* @param <InnerT> generic parameter of the wrapped iterator, must be <tt>T</tt> or extend <tt>T</tt>
|
||||||
* @see #predicateFunction
|
* @see #predicateFunction
|
||||||
*/
|
*/
|
||||||
public abstract class FilterIterator<T> implements Iterator<T> {
|
public abstract class FilterIterator<T, InnerT extends T> implements Iterator<T> {
|
||||||
|
|
||||||
private final Iterator<T> iterator;
|
private final Iterator<InnerT> iterator;
|
||||||
private T next = null;
|
private T next = null;
|
||||||
private boolean nextIsSet = false;
|
private boolean nextIsSet = false;
|
||||||
|
|
||||||
/** returns true, if this element should be returned by {@link #next()}. */
|
/** returns true, if this element should be returned by {@link #next()}. */
|
||||||
protected abstract boolean predicateFunction(T object);
|
protected abstract boolean predicateFunction(InnerT object);
|
||||||
|
|
||||||
public FilterIterator(Iterator<T> baseIterator) {
|
public FilterIterator(Iterator<InnerT> baseIterator) {
|
||||||
this.iterator = baseIterator;
|
this.iterator = baseIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +63,7 @@ public abstract class FilterIterator<T> implements Iterator<T> {
|
|||||||
|
|
||||||
private boolean setNext() {
|
private boolean setNext() {
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final T object = iterator.next();
|
final InnerT object = iterator.next();
|
||||||
if (predicateFunction(object)) {
|
if (predicateFunction(object)) {
|
||||||
next = object;
|
next = object;
|
||||||
nextIsSet = true;
|
nextIsSet = true;
|
||||||
|
@ -1568,7 +1568,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
|||||||
List<StorableField> storedList = new ArrayList<StorableField>();
|
List<StorableField> storedList = new ArrayList<StorableField>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends IndexableField> indexableFields() {
|
public Iterable<IndexableField> indexableFields() {
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
list.add(new IndexableField() {
|
list.add(new IndexableField() {
|
||||||
@Override
|
@Override
|
||||||
@ -1596,7 +1596,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends StorableField> storableFields() {
|
public Iterable<StorableField> storableFields() {
|
||||||
return storedList;
|
return storedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public class TestIndexableField extends LuceneTestCase {
|
|||||||
|
|
||||||
IndexDocument d = new IndexDocument() {
|
IndexDocument d = new IndexDocument() {
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends IndexableField> indexableFields() {
|
public Iterable<IndexableField> indexableFields() {
|
||||||
return new Iterable<IndexableField>() {
|
return new Iterable<IndexableField>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<IndexableField> iterator() {
|
public Iterator<IndexableField> iterator() {
|
||||||
@ -230,7 +230,7 @@ public class TestIndexableField extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends StorableField> storableFields() {
|
public Iterable<StorableField> storableFields() {
|
||||||
return new Iterable<StorableField>() {
|
return new Iterable<StorableField>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<StorableField> iterator() {
|
public Iterator<StorableField> iterator() {
|
||||||
|
@ -39,7 +39,7 @@ public class TestFilterIterator extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testEmpty() {
|
public void testEmpty() {
|
||||||
final Iterator<String> it = new FilterIterator<String>(set.iterator()) {
|
final Iterator<String> it = new FilterIterator<String, String>(set.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String s) {
|
protected boolean predicateFunction(String s) {
|
||||||
return false;
|
return false;
|
||||||
@ -49,7 +49,7 @@ public class TestFilterIterator extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testA1() {
|
public void testA1() {
|
||||||
final Iterator<String> it = new FilterIterator<String>(set.iterator()) {
|
final Iterator<String> it = new FilterIterator<String, String>(set.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String s) {
|
protected boolean predicateFunction(String s) {
|
||||||
return "a".equals(s);
|
return "a".equals(s);
|
||||||
@ -61,7 +61,7 @@ public class TestFilterIterator extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testA2() {
|
public void testA2() {
|
||||||
final Iterator<String> it = new FilterIterator<String>(set.iterator()) {
|
final Iterator<String> it = new FilterIterator<String, String>(set.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String s) {
|
protected boolean predicateFunction(String s) {
|
||||||
return "a".equals(s);
|
return "a".equals(s);
|
||||||
@ -73,7 +73,7 @@ public class TestFilterIterator extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testB1() {
|
public void testB1() {
|
||||||
final Iterator<String> it = new FilterIterator<String>(set.iterator()) {
|
final Iterator<String> it = new FilterIterator<String, String>(set.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String s) {
|
protected boolean predicateFunction(String s) {
|
||||||
return "b".equals(s);
|
return "b".equals(s);
|
||||||
@ -85,7 +85,7 @@ public class TestFilterIterator extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testB2() {
|
public void testB2() {
|
||||||
final Iterator<String> it = new FilterIterator<String>(set.iterator()) {
|
final Iterator<String> it = new FilterIterator<String, String>(set.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String s) {
|
protected boolean predicateFunction(String s) {
|
||||||
return "b".equals(s);
|
return "b".equals(s);
|
||||||
@ -97,7 +97,7 @@ public class TestFilterIterator extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAll1() {
|
public void testAll1() {
|
||||||
final Iterator<String> it = new FilterIterator<String>(set.iterator()) {
|
final Iterator<String> it = new FilterIterator<String, String>(set.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String s) {
|
protected boolean predicateFunction(String s) {
|
||||||
return true;
|
return true;
|
||||||
@ -113,7 +113,7 @@ public class TestFilterIterator extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAll2() {
|
public void testAll2() {
|
||||||
final Iterator<String> it = new FilterIterator<String>(set.iterator()) {
|
final Iterator<String> it = new FilterIterator<String, String>(set.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String s) {
|
protected boolean predicateFunction(String s) {
|
||||||
return true;
|
return true;
|
||||||
@ -126,7 +126,7 @@ public class TestFilterIterator extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testUnmodifiable() {
|
public void testUnmodifiable() {
|
||||||
final Iterator<String> it = new FilterIterator<String>(set.iterator()) {
|
final Iterator<String> it = new FilterIterator<String, String>(set.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String s) {
|
protected boolean predicateFunction(String s) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -146,7 +146,7 @@ public final class FieldFilterAtomicReader extends FilterAtomicReader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<String> iterator() {
|
public Iterator<String> iterator() {
|
||||||
return new FilterIterator<String>(super.iterator()) {
|
return new FilterIterator<String, String>(super.iterator()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean predicateFunction(String field) {
|
protected boolean predicateFunction(String field) {
|
||||||
return hasField(field);
|
return hasField(field);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user