Skip to content

Apache Lucene open-source search software

Fix method declared final in final class in Document. (#15669)

zhouhuia980ea6dd16a
diff --git a/lucene/core/src/java/org/apache/lucene/document/Document.java b/lucene/core/src/java/org/apache/lucene/document/Document.java
index 36b86940179..43f8e1a5631 100644
--- a/lucene/core/src/java/org/apache/lucene/document/Document.java
+++ b/lucene/core/src/java/org/apache/lucene/document/Document.java
@@ -58,7 +58,7 @@ public final class Document implements Iterable<IndexableField> {
* achieve this, a document has to be deleted from an index and a new changed version of that
* document has to be added.
*/
- public final void add(IndexableField field) {
+ public void add(IndexableField field) {
fields.add(field);
}
@@ -72,7 +72,7 @@ public final class Document implements Iterable<IndexableField> {
* In order to achieve this, a document has to be deleted from an index and a new changed version
* of that document has to be added.
*/
- public final void removeField(String name) {
+ public void removeField(String name) {
Iterator<IndexableField> it = fields.iterator();
while (it.hasNext()) {
IndexableField field = it.next();
@@ -92,7 +92,7 @@ public final class Document implements Iterable<IndexableField> {
* In order to achieve this, a document has to be deleted from an index and a new changed version
* of that document has to be added.
*/
- public final void removeFields(String name) {
+ public void removeFields(String name) {
Iterator<IndexableField> it = fields.iterator();
while (it.hasNext()) {
IndexableField field = it.next();
@@ -110,7 +110,7 @@ public final class Document implements Iterable<IndexableField> {
* @param name the name of the field
* @return a <code>BytesRef[]</code> of binary field values
*/
- public final BytesRef[] getBinaryValues(String name) {
+ public BytesRef[] getBinaryValues(String name) {
final List<BytesRef> result = new ArrayList<>();
for (IndexableField field : fields) {
if (field.name().equals(name)) {
@@ -132,7 +132,7 @@ public final class Document implements Iterable<IndexableField> {
* @param name the name of the field.
* @return a <code>BytesRef</code> containing the binary field value or <code>null</code>
*/
- public final BytesRef getBinaryValue(String name) {
+ public BytesRef getBinaryValue(String name) {
for (IndexableField field : fields) {
if (field.name().equals(name)) {
final BytesRef bytes = field.binaryValue();
@@ -148,7 +148,7 @@ public final class Document implements Iterable<IndexableField> {
* Returns a field with the given name if any exist in this document, or null. If multiple fields
* exists with this name, this method returns the first value added.
*/
- public final IndexableField getField(String name) {
+ public IndexableField getField(String name) {
for (IndexableField field : fields) {
if (field.name().equals(name)) {
return field;
@@ -183,7 +183,7 @@ public final class Document implements Iterable<IndexableField> {
*
* @return an immutable <code>List&lt;Field&gt;</code>
*/
- public final List<IndexableField> getFields() {
+ public List<IndexableField> getFields() {
return Collections.unmodifiableList(fields);
}
@@ -198,7 +198,7 @@ public final class Document implements Iterable<IndexableField> {
* @param name the name of the field
* @return a <code>String[]</code> of field values
*/
- public final String[] getValues(String name) {
+ public String[] getValues(String name) {
List<String> result = new ArrayList<>();
for (IndexableField field : fields) {
if (field.name().equals(name) && field.stringValue() != null) {
@@ -220,7 +220,7 @@ public final class Document implements Iterable<IndexableField> {
* returns the string value of the number. If you want the actual numeric field instance back, use
* {@link #getField}.
*/
- public final String get(String name) {
+ public String get(String name) {
for (IndexableField field : fields) {
if (field.name().equals(name) && field.stringValue() != null) {
return field.stringValue();
@@ -231,7 +231,7 @@ public final class Document implements Iterable<IndexableField> {
/** Prints the fields of a document for human consumption. */
@Override
- public final String toString() {
+ public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append("Document<");
for (int i = 0; i < fields.size(); i++) {