From 49f43806a89a17e759d58aaa17ca825e04dd3c66 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 29 Mar 2012 17:34:34 +0000 Subject: [PATCH] LUCENE-2000: remove redundant casts git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1307012 13f79535-47bb-0310-9956-ffa450edef68 --- dev-tools/eclipse/dot.classpath | 6 +++--- .../java/org/apache/lucene/analysis/Token.java | 8 ++++---- .../tokenattributes/PayloadAttributeImpl.java | 4 ++-- .../apache/lucene/codecs/BlockTermsReader.java | 2 +- .../lucene/codecs/BlockTreeTermsReader.java | 4 ++-- .../lucene/codecs/lucene3x/SegmentTermEnum.java | 4 ++-- .../lucene/codecs/lucene3x/TermInfosReader.java | 4 ++-- .../codecs/lucene3x/TermInfosReaderIndex.java | 8 ++++---- .../lucene/codecs/sep/SepPostingsReader.java | 6 +++--- .../java/org/apache/lucene/index/CheckIndex.java | 4 ++-- .../java/org/apache/lucene/index/FieldInfos.java | 4 ++-- .../org/apache/lucene/index/IndexUpgrader.java | 2 +- .../org/apache/lucene/index/IndexWriter.java | 4 ++-- .../apache/lucene/index/ReadersAndLiveDocs.java | 2 +- .../org/apache/lucene/index/SegmentInfo.java | 4 ++-- .../org/apache/lucene/index/SegmentInfos.java | 4 ++-- .../lucene/index/StandardDirectoryReader.java | 2 +- .../org/apache/lucene/search/BooleanQuery.java | 2 +- .../lucene/search/DisjunctionMaxQuery.java | 2 +- .../org/apache/lucene/util/AttributeSource.java | 4 ++-- .../test/org/apache/lucene/index/TestCodecs.java | 4 ++-- .../org/apache/lucene/index/TestFieldInfos.java | 2 +- .../lucene/index/TestIndexWriterConfig.java | 2 +- .../apache/lucene/search/TestBooleanQuery.java | 2 +- .../org/apache/lucene/util/TestFixedBitSet.java | 12 ++++++------ .../compound/hyphenation/TernaryTree.java | 8 ++++---- .../miscellaneous/PrefixAwareTokenFilter.java | 2 +- .../miscellaneous/SingleTokenTokenStream.java | 6 +++--- .../analysis/util/TestCharArrayIterator.java | 2 +- .../icu/segmentation/LaoBreakIterator.java | 6 +++--- .../icu/segmentation/TestCharArrayIterator.java | 2 +- .../feeds/demohtml/HTMLParserTokenManager.java | 16 ++++++++-------- .../byTask/tasks/RepSumByNameRoundTask.java | 2 +- .../benchmark/byTask/tasks/RepSumByNameTask.java | 2 +- .../byTask/tasks/RepSumByPrefRoundTask.java | 2 +- .../benchmark/byTask/tasks/RepSumByPrefTask.java | 2 +- .../benchmark/byTask/tasks/TaskSequence.java | 4 ++-- .../index/attributes/CategoryAttributeImpl.java | 2 +- .../lucene/facet/search/params/FacetRequest.java | 4 ++-- .../lucene/facet/util/ScoredDocIdsUtils.java | 2 +- .../facet/search/params/FacetRequestTest.java | 2 +- .../search/join/ToChildBlockJoinQuery.java | 2 +- .../search/join/ToParentBlockJoinQuery.java | 2 +- .../org/apache/lucene/queries/BoostingQuery.java | 2 +- .../apache/lucene/queries/CustomScoreQuery.java | 8 ++++---- .../classic/QueryParserTokenManager.java | 6 +++--- .../parser/StandardSyntaxParserTokenManager.java | 6 +++--- .../processors/OpenRangeQueryNodeProcessor.java | 6 ++---- .../surround/parser/QueryParserTokenManager.java | 4 ++-- .../queryparser/surround/query/FieldsQuery.java | 2 +- .../solr/analysis/CommonGramsFilterFactory.java | 2 +- .../analysis/CommonGramsQueryFilterFactory.java | 2 +- .../MaxFieldValueUpdateProcessorFactory.java | 2 +- .../MinFieldValueUpdateProcessorFactory.java | 2 +- .../org/apache/solr/util/ConcurrentLRUCache.java | 2 +- .../org/apache/solr/schema/DateFieldTest.java | 4 ++-- 56 files changed, 108 insertions(+), 110 deletions(-) diff --git a/dev-tools/eclipse/dot.classpath b/dev-tools/eclipse/dot.classpath index b8c8dfb4858..062785c1534 100644 --- a/dev-tools/eclipse/dot.classpath +++ b/dev-tools/eclipse/dot.classpath @@ -39,7 +39,7 @@ - + @@ -169,8 +169,8 @@ - - + + diff --git a/lucene/core/src/java/org/apache/lucene/analysis/Token.java b/lucene/core/src/java/org/apache/lucene/analysis/Token.java index 5daa4b342ef..9f3d7babb79 100644 --- a/lucene/core/src/java/org/apache/lucene/analysis/Token.java +++ b/lucene/core/src/java/org/apache/lucene/analysis/Token.java @@ -370,7 +370,7 @@ public class Token extends CharTermAttributeImpl Token t = (Token)super.clone(); // Do a deep clone if (payload != null) { - t.payload = (Payload) payload.clone(); + t.payload = payload.clone(); } return t; } @@ -386,7 +386,7 @@ public class Token extends CharTermAttributeImpl t.flags = flags; t.type = type; if (payload != null) - t.payload = (Payload) payload.clone(); + t.payload = payload.clone(); return t; } @@ -577,13 +577,13 @@ public class Token extends CharTermAttributeImpl to.reinit(this); // reinit shares the payload, so clone it: if (payload !=null) { - to.payload = (Payload) payload.clone(); + to.payload = payload.clone(); } } else { super.copyTo(target); ((OffsetAttribute) target).setOffset(startOffset, endOffset); ((PositionIncrementAttribute) target).setPositionIncrement(positionIncrement); - ((PayloadAttribute) target).setPayload((payload == null) ? null : (Payload) payload.clone()); + ((PayloadAttribute) target).setPayload((payload == null) ? null : payload.clone()); ((FlagsAttribute) target).setFlags(flags); ((TypeAttribute) target).setType(type); } diff --git a/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttributeImpl.java b/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttributeImpl.java index fd742ae6291..6d44924b1f1 100644 --- a/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttributeImpl.java +++ b/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttributeImpl.java @@ -61,7 +61,7 @@ public class PayloadAttributeImpl extends AttributeImpl implements PayloadAttrib public PayloadAttributeImpl clone() { PayloadAttributeImpl clone = (PayloadAttributeImpl) super.clone(); if (payload != null) { - clone.payload = (Payload) payload.clone(); + clone.payload = payload.clone(); } return clone; } @@ -92,7 +92,7 @@ public class PayloadAttributeImpl extends AttributeImpl implements PayloadAttrib @Override public void copyTo(AttributeImpl target) { PayloadAttribute t = (PayloadAttribute) target; - t.setPayload((payload == null) ? null : (Payload) payload.clone()); + t.setPayload((payload == null) ? null : payload.clone()); } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java index 484557e3511..0c892c2da58 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java @@ -729,7 +729,7 @@ public class BlockTermsReader extends FieldsProducer { public TermState termState() throws IOException { //System.out.println("BTR.termState this=" + this); decodeMetaData(); - TermState ts = (TermState) state.clone(); + TermState ts = state.clone(); //System.out.println(" return ts=" + ts); return ts; } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java index 00a0c2a696a..97543020467 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java @@ -803,7 +803,7 @@ public class BlockTreeTermsReader extends FieldsProducer { @Override public TermState termState() throws IOException { currentFrame.decodeMetaData(); - return (TermState) currentFrame.termState.clone(); + return currentFrame.termState.clone(); } private Frame getFrame(int ord) throws IOException { @@ -2166,7 +2166,7 @@ public class BlockTreeTermsReader extends FieldsProducer { public TermState termState() throws IOException { assert !eof; currentFrame.decodeMetaData(); - TermState ts = (TermState) currentFrame.state.clone(); + TermState ts = currentFrame.state.clone(); //if (DEBUG) System.out.println("BTTR.termState seg=" + segment + " state=" + ts); return ts; } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/SegmentTermEnum.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/SegmentTermEnum.java index 7bd5e1ea3f9..b9b796bbb43 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/SegmentTermEnum.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/SegmentTermEnum.java @@ -109,8 +109,8 @@ final class SegmentTermEnum implements Cloneable { clone.input = (IndexInput) input.clone(); clone.termInfo = new TermInfo(termInfo); - clone.termBuffer = (TermBuffer)termBuffer.clone(); - clone.prevBuffer = (TermBuffer)prevBuffer.clone(); + clone.termBuffer = termBuffer.clone(); + clone.prevBuffer = prevBuffer.clone(); clone.scanBuffer = new TermBuffer(); return clone; diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/TermInfosReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/TermInfosReader.java index fd63c7fb290..de3cb84b563 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/TermInfosReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/TermInfosReader.java @@ -340,12 +340,12 @@ final class TermInfosReader { /** Returns an enumeration of all the Terms and TermInfos in the set. */ public SegmentTermEnum terms() { - return (SegmentTermEnum)origEnum.clone(); + return origEnum.clone(); } /** Returns an enumeration of terms starting at or after the named term. */ public SegmentTermEnum terms(Term term) throws IOException { get(term, true); - return (SegmentTermEnum)getThreadResources().termEnum.clone(); + return getThreadResources().termEnum.clone(); } } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/TermInfosReaderIndex.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/TermInfosReaderIndex.java index 62ff23e2f19..b37384c713e 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/TermInfosReaderIndex.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/TermInfosReaderIndex.java @@ -116,7 +116,7 @@ class TermInfosReaderIndex { } void seekEnum(SegmentTermEnum enumerator, int indexOffset) throws IOException { - PagedBytesDataInput input = (PagedBytesDataInput) dataInput.clone(); + PagedBytesDataInput input = dataInput.clone(); input.setPosition(indexToDataOffset.get(indexOffset)); @@ -152,7 +152,7 @@ class TermInfosReaderIndex { int getIndexOffset(Term term) throws IOException { int lo = 0; int hi = indexSize - 1; - PagedBytesDataInput input = (PagedBytesDataInput) dataInput.clone(); + PagedBytesDataInput input = dataInput.clone(); BytesRef scratch = new BytesRef(); while (hi >= lo) { int mid = (lo + hi) >>> 1; @@ -176,7 +176,7 @@ class TermInfosReaderIndex { * @throws IOException */ Term getTerm(int termIndex) throws IOException { - PagedBytesDataInput input = (PagedBytesDataInput) dataInput.clone(); + PagedBytesDataInput input = dataInput.clone(); input.setPosition(indexToDataOffset.get(termIndex)); // read the term @@ -206,7 +206,7 @@ class TermInfosReaderIndex { * @throws IOException */ int compareTo(Term term, int termIndex) throws IOException { - return compareTo(term, termIndex, (PagedBytesDataInput) dataInput.clone(), new BytesRef()); + return compareTo(term, termIndex, dataInput.clone(), new BytesRef()); } /** diff --git a/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java index 39a8d81bb81..533fd2f3b22 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java @@ -172,13 +172,13 @@ public class SepPostingsReader extends PostingsReaderBase { super.copyFrom(_other); SepTermState other = (SepTermState) _other; if (docIndex == null) { - docIndex = (IntIndexInput.Index) other.docIndex.clone(); + docIndex = other.docIndex.clone(); } else { docIndex.set(other.docIndex); } if (other.freqIndex != null) { if (freqIndex == null) { - freqIndex = (IntIndexInput.Index) other.freqIndex.clone(); + freqIndex = other.freqIndex.clone(); } else { freqIndex.set(other.freqIndex); } @@ -187,7 +187,7 @@ public class SepPostingsReader extends PostingsReaderBase { } if (other.posIndex != null) { if (posIndex == null) { - posIndex = (IntIndexInput.Index) other.posIndex.clone(); + posIndex = other.posIndex.clone(); } else { posIndex.set(other.posIndex); } diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java index 12cb3ef5cc4..36836842b90 100644 --- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java +++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java @@ -475,7 +475,7 @@ public class CheckIndex { } - result.newSegments = (SegmentInfos) sis.clone(); + result.newSegments = sis.clone(); result.newSegments.clear(); result.maxSegmentName = -1; @@ -642,7 +642,7 @@ public class CheckIndex { } // Keeper - result.newSegments.add((SegmentInfo) info.clone()); + result.newSegments.add(info.clone()); } if (0 == result.numBadSegments) { diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java index 37268f4218e..75e952bf516 100644 --- a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java +++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java @@ -169,7 +169,7 @@ public final class FieldInfos implements Iterable { fis.hasProx = hasProx; fis.hasVectors = hasVectors; for (FieldInfo fi : this) { - FieldInfo clone = (FieldInfo) (fi).clone(); + FieldInfo clone = fi.clone(); fis.putInternal(clone); } return fis; @@ -444,7 +444,7 @@ public final class FieldInfos implements Iterable { } final FieldInfos roFis = new FieldInfos((FieldNumberBiMap)null); for (FieldInfo fieldInfo : this) { - FieldInfo clone = (FieldInfo) (fieldInfo).clone(); + FieldInfo clone = fieldInfo.clone(); roFis.putInternal(clone); roFis.hasVectors |= clone.storeTermVector; roFis.hasProx |= clone.isIndexed && clone.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0; diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java b/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java index 4a43466fbee..335a052724d 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java @@ -145,7 +145,7 @@ public final class IndexUpgrader { } } - final IndexWriterConfig c = (IndexWriterConfig) iwc.clone(); + final IndexWriterConfig c = iwc.clone(); c.setMergePolicy(new UpgradeIndexMergePolicy(c.getMergePolicy())); c.setIndexDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy()); diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java index 364ad554f74..e16ca0243bf 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -585,7 +585,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit { */ public IndexWriter(Directory d, IndexWriterConfig conf) throws CorruptIndexException, LockObtainFailedException, IOException { - config = (IndexWriterConfig) conf.clone(); + config = conf.clone(); directory = d; analyzer = conf.getAnalyzer(); infoStream = conf.getInfoStream(); @@ -2431,7 +2431,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit { // no partial changes (eg a delete w/o // corresponding add from an updateDocument) can // sneak into the commit point: - toCommit = (SegmentInfos) segmentInfos.clone(); + toCommit = segmentInfos.clone(); pendingCommitChangeCount = changeCount; diff --git a/lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java b/lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java index e0f4d2f57f4..cc194747702 100644 --- a/lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java +++ b/lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java @@ -273,7 +273,7 @@ class ReadersAndLiveDocs { assert liveDocs.length() == info.docCount; // Save in case we need to rollback on failure: - final SegmentInfo sav = (SegmentInfo) info.clone(); + final SegmentInfo sav = info.clone(); info.advanceDelGen(); info.setDelCount(info.getDelCount() + pendingDeleteCount); diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java index 3ab59f98323..fa3a0412fc2 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java @@ -142,7 +142,7 @@ public final class SegmentInfo implements Cloneable { docStoreIsCompoundFile = src.docStoreIsCompoundFile; hasVectors = src.hasVectors; hasProx = src.hasProx; - fieldInfos = src.fieldInfos == null ? null : (FieldInfos) src.fieldInfos.clone(); + fieldInfos = src.fieldInfos == null ? null : src.fieldInfos.clone(); if (src.normGen == null) { normGen = null; } else { @@ -254,7 +254,7 @@ public final class SegmentInfo implements Cloneable { @Override public SegmentInfo clone() { final SegmentInfo si = new SegmentInfo(name, docCount, dir, isCompoundFile, codec, - fieldInfos == null ? null : (FieldInfos) fieldInfos.clone()); + fieldInfos == null ? null : fieldInfos.clone()); si.docStoreOffset = docStoreOffset; si.docStoreSegment = docStoreSegment; si.docStoreIsCompoundFile = docStoreIsCompoundFile; diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java index 53b190d3755..ef87e32be86 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java @@ -385,7 +385,7 @@ public final class SegmentInfos implements Cloneable, Iterable { for(final SegmentInfo info : this) { assert info.getCodec() != null; // dont directly access segments, use add method!!! - sis.add((SegmentInfo) info.clone()); + sis.add(info.clone()); } sis.userData = new HashMap(userData); return sis; @@ -957,7 +957,7 @@ public final class SegmentInfos implements Cloneable, Iterable { final List list = new ArrayList(size()); for(final SegmentInfo info : this) { assert info.getCodec() != null; - list.add((SegmentInfo) info.clone()); + list.add(info.clone()); } return list; } else { diff --git a/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java b/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java index c41857078a5..704a926e724 100644 --- a/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java @@ -83,7 +83,7 @@ final class StandardDirectoryReader extends DirectoryReader { List readers = new ArrayList(); final Directory dir = writer.getDirectory(); - final SegmentInfos segmentInfos = (SegmentInfos) infos.clone(); + final SegmentInfos segmentInfos = infos.clone(); int infosUpto = 0; for (int i=0;i { if (getBoost() != 1.0f) { // incorporate boost if (query == c.getQuery()) { // if rewrite was no-op - query = (Query)query.clone(); // then clone before boost + query = query.clone(); // then clone before boost } // Since the BooleanQuery only has 1 clause, the BooleanQuery will be // written out. Therefore the rewritten Query's boost must incorporate both diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java index 16b7b5dd5f4..f1b9feed6b3 100644 --- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java @@ -190,7 +190,7 @@ public class DisjunctionMaxQuery extends Query implements Iterable { Query singleton = disjuncts.get(0); Query result = singleton.rewrite(reader); if (getBoost() != 1.0f) { - if (result == singleton) result = (Query)result.clone(); + if (result == singleton) result = result.clone(); result.setBoost(getBoost() * result.getBoost()); } return result; diff --git a/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java b/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java index 5cb808d4b44..f2de36f88d1 100644 --- a/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java +++ b/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java @@ -334,7 +334,7 @@ public class AttributeSource { */ public final State captureState() { final State state = this.getCurrentState(); - return (state == null) ? null : (State) state.clone(); + return (state == null) ? null : state.clone(); } /** @@ -466,7 +466,7 @@ public class AttributeSource { if (hasAttributes()) { // first clone the impls for (State state = getCurrentState(); state != null; state = state.next) { - clone.attributeImpls.put(state.attribute.getClass(), (AttributeImpl) state.attribute.clone()); + clone.attributeImpls.put(state.attribute.getClass(), state.attribute.clone()); } // now the interfaces diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java b/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java index 5f2360a07da..4d0fc5c11e7 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java @@ -255,7 +255,7 @@ public class TestCodecs extends LuceneTestCase { final FieldData[] fields = new FieldData[] {field}; final Directory dir = newDirectory(); - FieldInfos clonedFieldInfos = (FieldInfos) fieldInfos.clone(); + FieldInfos clonedFieldInfos = fieldInfos.clone(); this.write(fieldInfos, dir, fields, true); Codec codec = Codec.getDefault(); final SegmentInfo si = new SegmentInfo(SEGMENT, 10000, dir, false, codec, clonedFieldInfos); @@ -311,7 +311,7 @@ public class TestCodecs extends LuceneTestCase { System.out.println("TEST: now write postings"); } - FieldInfos clonedFieldInfos = (FieldInfos) fieldInfos.clone(); + FieldInfos clonedFieldInfos = fieldInfos.clone(); this.write(fieldInfos, dir, fields, false); Codec codec = Codec.getDefault(); final SegmentInfo si = new SegmentInfo(SEGMENT, 10000, dir, false, codec, clonedFieldInfos); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java b/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java index cf32981a573..ac7393a6ea9 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java @@ -102,7 +102,7 @@ public class TestFieldInfos extends LuceneTestCase { FieldInfos fieldInfos = createAndWriteFieldInfos(dir, name); FieldInfos readOnly = readFieldInfos(dir, name); assertReadOnly(readOnly, fieldInfos); - FieldInfos readOnlyClone = (FieldInfos)readOnly.clone(); + FieldInfos readOnlyClone = readOnly.clone(); assertNotSame(readOnly, readOnlyClone); // clone is also read only - no global field map assertReadOnly(readOnlyClone, fieldInfos); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java index efcec8b4b88..334a389c7a0 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java @@ -156,7 +156,7 @@ public class TestIndexWriterConfig extends LuceneTestCase { @Test public void testClone() throws Exception { IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)); - IndexWriterConfig clone = (IndexWriterConfig) conf.clone(); + IndexWriterConfig clone = conf.clone(); // Clone is shallow since not all parameters are cloneable. assertTrue(conf.getIndexDeletionPolicy() == clone.getIndexDeletionPolicy()); diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java b/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java index 6565e3f6974..6bcd6ebf51b 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java @@ -94,7 +94,7 @@ public class TestBooleanQuery extends LuceneTestCase { assertEquals(score*.5F, score2, 1e-6); // LUCENE-2617: make sure that a clause not in the index still contributes to the score via coord factor - BooleanQuery qq = (BooleanQuery)q.clone(); + BooleanQuery qq = q.clone(); PhraseQuery phrase = new PhraseQuery(); phrase.add(new Term("field", "not_in_index")); phrase.add(new Term("field", "another_not_in_index")); diff --git a/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java b/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java index 33626946d0a..a1ffbde2bdb 100644 --- a/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java +++ b/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java @@ -139,14 +139,14 @@ public class TestFixedBitSet extends LuceneTestCase { fromIndex = random.nextInt(sz/2); toIndex = fromIndex + random.nextInt(sz - fromIndex); BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex); - FixedBitSet bb = (FixedBitSet)b.clone(); bb.flip(fromIndex,toIndex); + FixedBitSet bb = b.clone(); bb.flip(fromIndex,toIndex); doIterate(aa,bb, mode); // a problem here is from flip or doIterate fromIndex = random.nextInt(sz/2); toIndex = fromIndex + random.nextInt(sz - fromIndex); aa = (BitSet)a.clone(); aa.clear(fromIndex,toIndex); - bb = (FixedBitSet)b.clone(); bb.clear(fromIndex,toIndex); + bb = b.clone(); bb.clear(fromIndex,toIndex); doNextSetBit(aa,bb); // a problem here is from clear() or nextSetBit @@ -155,7 +155,7 @@ public class TestFixedBitSet extends LuceneTestCase { fromIndex = random.nextInt(sz/2); toIndex = fromIndex + random.nextInt(sz - fromIndex); aa = (BitSet)a.clone(); aa.set(fromIndex,toIndex); - bb = (FixedBitSet)b.clone(); bb.set(fromIndex,toIndex); + bb = b.clone(); bb.set(fromIndex,toIndex); doNextSetBit(aa,bb); // a problem here is from set() or nextSetBit @@ -168,9 +168,9 @@ public class TestFixedBitSet extends LuceneTestCase { BitSet a_or = (BitSet)a.clone(); a_or.or(a0); BitSet a_andn = (BitSet)a.clone(); a_andn.andNot(a0); - FixedBitSet b_and = (FixedBitSet)b.clone(); assertEquals(b,b_and); b_and.and(b0); - FixedBitSet b_or = (FixedBitSet)b.clone(); b_or.or(b0); - FixedBitSet b_andn = (FixedBitSet)b.clone(); b_andn.andNot(b0); + FixedBitSet b_and = b.clone(); assertEquals(b,b_and); b_and.and(b0); + FixedBitSet b_or = b.clone(); b_or.or(b0); + FixedBitSet b_andn = b.clone(); b_andn.andNot(b0); assertEquals(a0.cardinality(), b0.cardinality()); assertEquals(a_or.cardinality(), b_or.cardinality()); diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java index ae3bf2723e3..aaa2d56e166 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java @@ -354,7 +354,7 @@ public class TernaryTree implements Cloneable { t.hi = this.hi.clone(); t.eq = this.eq.clone(); t.sc = this.sc.clone(); - t.kv = (CharVector) this.kv.clone(); + t.kv = this.kv.clone(); t.root = this.root; t.freenode = this.freenode; t.length = this.length; @@ -556,11 +556,11 @@ public class TernaryTree implements Cloneable { case 1: if (sc[i.parent] != 0) { res = eq[i.parent]; - ns.push((Item) i.clone()); + ns.push(i.clone()); ks.append(sc[i.parent]); } else { i.child++; - ns.push((Item) i.clone()); + ns.push(i.clone()); res = hi[i.parent]; } climb = false; @@ -568,7 +568,7 @@ public class TernaryTree implements Cloneable { case 2: res = hi[i.parent]; - ns.push((Item) i.clone()); + ns.push(i.clone()); if (ks.length() > 0) { ks.setLength(ks.length() - 1); // pop } diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/PrefixAwareTokenFilter.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/PrefixAwareTokenFilter.java index 91fb8a4cfd2..603e6e12103 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/PrefixAwareTokenFilter.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/PrefixAwareTokenFilter.java @@ -95,7 +95,7 @@ public class PrefixAwareTokenFilter extends TokenStream { // Make it a deep copy Payload p = previousPrefixToken.getPayload(); if (p != null) { - previousPrefixToken.setPayload((Payload) p.clone()); + previousPrefixToken.setPayload(p.clone()); } setCurrentToken(nextToken); return true; diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/SingleTokenTokenStream.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/SingleTokenTokenStream.java index 8a401368ca6..5a0e09aec45 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/SingleTokenTokenStream.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/SingleTokenTokenStream.java @@ -39,7 +39,7 @@ public final class SingleTokenTokenStream extends TokenStream { super(Token.TOKEN_ATTRIBUTE_FACTORY); assert token != null; - this.singleToken = (Token) token.clone(); + this.singleToken = token.clone(); tokenAtt = (AttributeImpl) addAttribute(CharTermAttribute.class); assert (tokenAtt instanceof Token); @@ -63,10 +63,10 @@ public final class SingleTokenTokenStream extends TokenStream { } public Token getToken() { - return (Token) singleToken.clone(); + return singleToken.clone(); } public void setToken(Token token) { - this.singleToken = (Token) token.clone(); + this.singleToken = token.clone(); } } diff --git a/modules/analysis/common/src/test/org/apache/lucene/analysis/util/TestCharArrayIterator.java b/modules/analysis/common/src/test/org/apache/lucene/analysis/util/TestCharArrayIterator.java index bfcab81eaf5..25c5d6f700c 100644 --- a/modules/analysis/common/src/test/org/apache/lucene/analysis/util/TestCharArrayIterator.java +++ b/modules/analysis/common/src/test/org/apache/lucene/analysis/util/TestCharArrayIterator.java @@ -148,7 +148,7 @@ public class TestCharArrayIterator extends LuceneTestCase { char text[] = "testing".toCharArray(); ci.setText(text, 0, text.length); ci.next(); - CharArrayIterator ci2 = (CharArrayIterator) ci.clone(); + CharArrayIterator ci2 = ci.clone(); assertEquals(ci.getIndex(), ci2.getIndex()); assertEquals(ci.next(), ci2.next()); assertEquals(ci.last(), ci2.last()); diff --git a/modules/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/LaoBreakIterator.java b/modules/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/LaoBreakIterator.java index bf38bfa40a6..07c085a7e5e 100644 --- a/modules/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/LaoBreakIterator.java +++ b/modules/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/LaoBreakIterator.java @@ -216,11 +216,11 @@ public class LaoBreakIterator extends BreakIterator { other.rules = (RuleBasedBreakIterator) rules.clone(); other.verify = (RuleBasedBreakIterator) verify.clone(); if (text != null) - other.text = (CharArrayIterator) text.clone(); + other.text = text.clone(); if (working != null) - other.working = (CharArrayIterator) working.clone(); + other.working = working.clone(); if (verifyText != null) - other.verifyText = (CharArrayIterator) verifyText.clone(); + other.verifyText = verifyText.clone(); return other; } } diff --git a/modules/analysis/icu/src/test/org/apache/lucene/analysis/icu/segmentation/TestCharArrayIterator.java b/modules/analysis/icu/src/test/org/apache/lucene/analysis/icu/segmentation/TestCharArrayIterator.java index 02b9d0a45f7..8fd43b26055 100644 --- a/modules/analysis/icu/src/test/org/apache/lucene/analysis/icu/segmentation/TestCharArrayIterator.java +++ b/modules/analysis/icu/src/test/org/apache/lucene/analysis/icu/segmentation/TestCharArrayIterator.java @@ -99,7 +99,7 @@ public class TestCharArrayIterator extends LuceneTestCase { CharArrayIterator ci = new CharArrayIterator(); ci.setText(text, 0, text.length); ci.next(); - CharArrayIterator ci2 = (CharArrayIterator) ci.clone(); + CharArrayIterator ci2 = ci.clone(); assertEquals(ci.getIndex(), ci2.getIndex()); assertEquals(ci.next(), ci2.next()); assertEquals(ci.last(), ci2.last()); diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/demohtml/HTMLParserTokenManager.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/demohtml/HTMLParserTokenManager.java index c339edd21ba..d465c933d15 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/demohtml/HTMLParserTokenManager.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/demohtml/HTMLParserTokenManager.java @@ -464,7 +464,7 @@ private int jjMoveNfa_0(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -569,7 +569,7 @@ private int jjMoveNfa_5(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -670,7 +670,7 @@ private int jjMoveNfa_7(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -766,7 +766,7 @@ private int jjMoveNfa_4(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -892,7 +892,7 @@ private int jjMoveNfa_3(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -1061,7 +1061,7 @@ private int jjMoveNfa_6(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -1205,7 +1205,7 @@ private int jjMoveNfa_1(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -1361,7 +1361,7 @@ private int jjMoveNfa_2(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameRoundTask.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameRoundTask.java index 2fd31f3f496..7e0f2a5369b 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameRoundTask.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameRoundTask.java @@ -63,7 +63,7 @@ public class RepSumByNameRoundTask extends ReportTask { TaskStats stat2 = p2.get(rname); if (stat2 == null) { try { - stat2 = (TaskStats) stat1.clone(); + stat2 = stat1.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java index a55d26d60ab..5985046f904 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java @@ -62,7 +62,7 @@ public class RepSumByNameTask extends ReportTask { TaskStats stat2 = p2.get(name); if (stat2 == null) { try { - stat2 = (TaskStats) stat1.clone(); + stat2 = stat1.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java index 070927b5b37..1e29a70f1ab 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java @@ -59,7 +59,7 @@ public class RepSumByPrefRoundTask extends RepSumByPrefTask { TaskStats stat2 = p2.get(rname); if (stat2 == null) { try { - stat2 = (TaskStats) stat1.clone(); + stat2 = stat1.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java index 610f28263a5..deb57b6d158 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java @@ -60,7 +60,7 @@ public class RepSumByPrefTask extends ReportTask { TaskStats stat2 = p2.get(name); if (stat2 == null) { try { - stat2 = (TaskStats) stat1.clone(); + stat2 = stat1.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java index 36da1b9b66e..b9a505e2043 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java @@ -347,7 +347,7 @@ public class TaskSequence extends PerfTask { int index = 0; for (int k=0; k(); for (int i = 0; i < tasks.size(); i++) { - res.tasks.add((PerfTask)tasks.get(i).clone()); + res.tasks.add(tasks.get(i).clone()); } return res; } diff --git a/modules/facet/src/java/org/apache/lucene/facet/index/attributes/CategoryAttributeImpl.java b/modules/facet/src/java/org/apache/lucene/facet/index/attributes/CategoryAttributeImpl.java index 0b920ea687e..64566c2f73b 100644 --- a/modules/facet/src/java/org/apache/lucene/facet/index/attributes/CategoryAttributeImpl.java +++ b/modules/facet/src/java/org/apache/lucene/facet/index/attributes/CategoryAttributeImpl.java @@ -124,7 +124,7 @@ public final class CategoryAttributeImpl extends AttributeImpl implements public CategoryAttributeImpl clone() { CategoryAttributeImpl ca = (CategoryAttributeImpl) super.clone(); if (categoryPath != null) { - ca.categoryPath = (CategoryPath) categoryPath.clone(); + ca.categoryPath = categoryPath.clone(); } if (properties != null && !properties.isEmpty()) { ca.properties = (HashMap, CategoryProperty>) properties diff --git a/modules/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java b/modules/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java index 02a5fc34bd5..a64cc8c3941 100644 --- a/modules/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java +++ b/modules/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java @@ -248,9 +248,9 @@ public abstract class FacetRequest implements Cloneable { public FacetResultsHandler createFacetResultsHandler(TaxonomyReader taxonomyReader) { try { if (resultMode == ResultMode.PER_NODE_IN_TREE) { - return new TopKInEachNodeHandler(taxonomyReader, (FacetRequest) clone()); + return new TopKInEachNodeHandler(taxonomyReader, clone()); } - return new TopKFacetResultsHandler(taxonomyReader, (FacetRequest) clone()); + return new TopKFacetResultsHandler(taxonomyReader, clone()); } catch (CloneNotSupportedException e) { // Shouldn't happen since we implement Cloneable. If it does happen, it is // probably because the class was changed to not implement Cloneable diff --git a/modules/facet/src/java/org/apache/lucene/facet/util/ScoredDocIdsUtils.java b/modules/facet/src/java/org/apache/lucene/facet/util/ScoredDocIdsUtils.java index 7a56b722b59..63a0b334628 100644 --- a/modules/facet/src/java/org/apache/lucene/facet/util/ScoredDocIdsUtils.java +++ b/modules/facet/src/java/org/apache/lucene/facet/util/ScoredDocIdsUtils.java @@ -56,7 +56,7 @@ public class ScoredDocIdsUtils { final OpenBitSet complement; if (docIdSet instanceof OpenBitSet) { // That is the most common case, if ScoredDocIdsCollector was used. - complement = (OpenBitSet) ((OpenBitSet) docIdSet).clone(); + complement = ((OpenBitSet) docIdSet).clone(); } else { complement = new OpenBitSetDISI(docIdSet.iterator(), maxDoc); } diff --git a/modules/facet/src/test/org/apache/lucene/facet/search/params/FacetRequestTest.java b/modules/facet/src/test/org/apache/lucene/facet/search/params/FacetRequestTest.java index f86d36b8f57..5927472c9fc 100644 --- a/modules/facet/src/test/org/apache/lucene/facet/search/params/FacetRequestTest.java +++ b/modules/facet/src/test/org/apache/lucene/facet/search/params/FacetRequestTest.java @@ -88,7 +88,7 @@ public class FacetRequestTest extends LuceneTestCase { @Test public void testClone() throws Exception { FacetRequest fr = new CountFacetRequest(new CategoryPath("a"), 10); - FacetRequest clone = (FacetRequest) fr.clone(); + FacetRequest clone = fr.clone(); fr.setDepth(10); assertEquals("depth should not have been affected in the clone", FacetRequest.DEFAULT_DEPTH, clone.getDepth()); } diff --git a/modules/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java b/modules/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java index feb5fcb7ff4..4b00f7a333b 100644 --- a/modules/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java +++ b/modules/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java @@ -336,7 +336,7 @@ public class ToChildBlockJoinQuery extends Query { @Override public ToChildBlockJoinQuery clone() { - return new ToChildBlockJoinQuery((Query) origParentQuery.clone(), + return new ToChildBlockJoinQuery(origParentQuery.clone(), parentsFilter, doScores); } diff --git a/modules/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java b/modules/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java index 805e7385285..f12e6f8ca3d 100644 --- a/modules/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java +++ b/modules/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java @@ -451,7 +451,7 @@ public class ToParentBlockJoinQuery extends Query { @Override public ToParentBlockJoinQuery clone() { - return new ToParentBlockJoinQuery((Query) origChildQuery.clone(), + return new ToParentBlockJoinQuery(origChildQuery.clone(), parentsFilter, scoreMode); } diff --git a/modules/queries/src/java/org/apache/lucene/queries/BoostingQuery.java b/modules/queries/src/java/org/apache/lucene/queries/BoostingQuery.java index 143231cc1b0..eb48f5275b5 100644 --- a/modules/queries/src/java/org/apache/lucene/queries/BoostingQuery.java +++ b/modules/queries/src/java/org/apache/lucene/queries/BoostingQuery.java @@ -44,7 +44,7 @@ public class BoostingQuery extends Query { public BoostingQuery(Query match, Query context, float boost) { this.match = match; - this.context = (Query) context.clone(); // clone before boost + this.context = context.clone(); // clone before boost this.boost = boost; this.context.setBoost(0.0f); // ignore context-only matches } diff --git a/modules/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java b/modules/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java index 7a42fedf548..ef594d879df 100755 --- a/modules/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java +++ b/modules/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java @@ -88,14 +88,14 @@ public class CustomScoreQuery extends Query { final Query sq = subQuery.rewrite(reader); if (sq != subQuery) { - clone = (CustomScoreQuery) clone(); + clone = clone(); clone.subQuery = sq; } for(int i = 0; i < scoringQueries.length; i++) { final Query v = scoringQueries[i].rewrite(reader); if (v != scoringQueries[i]) { - if (clone == null) clone = (CustomScoreQuery) clone(); + if (clone == null) clone = clone(); clone.scoringQueries[i] = v; } } @@ -116,10 +116,10 @@ public class CustomScoreQuery extends Query { @Override public CustomScoreQuery clone() { CustomScoreQuery clone = (CustomScoreQuery)super.clone(); - clone.subQuery = (Query) subQuery.clone(); + clone.subQuery = subQuery.clone(); clone.scoringQueries = new Query[scoringQueries.length]; for(int i = 0; i < scoringQueries.length; i++) { - clone.scoringQueries[i] = (Query) scoringQueries[i].clone(); + clone.scoringQueries[i] = scoringQueries[i].clone(); } return clone; } diff --git a/modules/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java b/modules/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java index ba278516881..1d05de3dd81 100644 --- a/modules/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java +++ b/modules/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java @@ -438,7 +438,7 @@ private int jjMoveNfa_2(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -604,7 +604,7 @@ private int jjMoveNfa_0(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -777,7 +777,7 @@ private int jjMoveNfa_1(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; diff --git a/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java b/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java index aaa1aa7db23..7909dd45540 100644 --- a/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java +++ b/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java @@ -374,7 +374,7 @@ private int jjMoveNfa_2(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -494,7 +494,7 @@ private int jjMoveNfa_0(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -667,7 +667,7 @@ private int jjMoveNfa_1(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; diff --git a/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java b/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java index e702d601a2c..4848b3f2f7a 100644 --- a/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java +++ b/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java @@ -37,12 +37,11 @@ public class OpenRangeQueryNodeProcessor extends QueryNodeProcessorImpl { if (node instanceof TermRangeQueryNode) { TermRangeQueryNode rangeNode = (TermRangeQueryNode) node; - FieldQueryNode lowerNode = (FieldQueryNode) rangeNode.getLowerBound(); - FieldQueryNode upperNode = (FieldQueryNode) rangeNode.getUpperBound(); + FieldQueryNode lowerNode = rangeNode.getLowerBound(); + FieldQueryNode upperNode = rangeNode.getUpperBound(); CharSequence lowerText = lowerNode.getText(); CharSequence upperText = upperNode.getText(); - if (OPEN_RANGE_TOKEN.equals(upperNode.getTextAsString()) && (!(upperText instanceof UnescapedCharSequence) || !((UnescapedCharSequence) upperText) .wasEscaped(0))) { @@ -57,7 +56,6 @@ public class OpenRangeQueryNodeProcessor extends QueryNodeProcessorImpl { lowerNode.setText(lowerText); upperNode.setText(upperText); - } return node; diff --git a/modules/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java b/modules/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java index dfbe431d03a..cf30bdf7427 100644 --- a/modules/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java +++ b/modules/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java @@ -348,7 +348,7 @@ private int jjMoveNfa_1(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; @@ -468,7 +468,7 @@ private int jjMoveNfa_0(int startState, int curPos) } else { - int hiByte = (int)(curChar >> 8); + int hiByte = (curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; diff --git a/modules/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java b/modules/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java index 114e9c789e9..bcffd7c0a6a 100644 --- a/modules/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java +++ b/modules/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java @@ -54,7 +54,7 @@ public class FieldsQuery extends SrndQuery { /* mostly untested */ Iterator fni = getFieldNames().listIterator(); SrndQuery qc; while (fni.hasNext()) { - qc = (SrndQuery) q.clone(); + qc = q.clone(); queries.add( new FieldsQuery( qc, fni.next(), fieldOp)); } OrQuery oq = new OrQuery(queries, diff --git a/solr/core/src/java/org/apache/solr/analysis/CommonGramsFilterFactory.java b/solr/core/src/java/org/apache/solr/analysis/CommonGramsFilterFactory.java index 1cd17bbfbc7..f0604b4a65d 100644 --- a/solr/core/src/java/org/apache/solr/analysis/CommonGramsFilterFactory.java +++ b/solr/core/src/java/org/apache/solr/analysis/CommonGramsFilterFactory.java @@ -58,7 +58,7 @@ public class CommonGramsFilterFactory extends BaseTokenFilterFactory implements throw new RuntimeException(e); } } else { - commonWords = (CharArraySet) StopAnalyzer.ENGLISH_STOP_WORDS_SET; + commonWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET; } } diff --git a/solr/core/src/java/org/apache/solr/analysis/CommonGramsQueryFilterFactory.java b/solr/core/src/java/org/apache/solr/analysis/CommonGramsQueryFilterFactory.java index 3dad726aa2b..46025f99079 100644 --- a/solr/core/src/java/org/apache/solr/analysis/CommonGramsQueryFilterFactory.java +++ b/solr/core/src/java/org/apache/solr/analysis/CommonGramsQueryFilterFactory.java @@ -65,7 +65,7 @@ public class CommonGramsQueryFilterFactory extends BaseTokenFilterFactory throw new RuntimeException(e); } } else { - commonWords = (CharArraySet) StopAnalyzer.ENGLISH_STOP_WORDS_SET; + commonWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET; } } diff --git a/solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.java index db5a0cfe1d5..7ad030bc6ee 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.java +++ b/solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.java @@ -60,7 +60,7 @@ public final class MaxFieldValueUpdateProcessorFactory extends FieldValueSubsetU Collection result = values; try { result = Collections.singletonList - (Collections.max((Collection)values)); + (Collections.max(values)); } catch (ClassCastException e) { throw new SolrException (BAD_REQUEST, diff --git a/solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.java index 0cce90f42e4..995d4bde30a 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.java +++ b/solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.java @@ -60,7 +60,7 @@ public final class MinFieldValueUpdateProcessorFactory extends FieldValueSubsetU Collection result = values; try { result = Collections.singletonList - (Collections.min((Collection)values)); + (Collections.min(values)); } catch (ClassCastException e) { throw new SolrException (BAD_REQUEST, diff --git a/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java b/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java index 28ce2ea6af7..b98e7909cb2 100644 --- a/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java +++ b/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java @@ -321,7 +321,7 @@ public class ConcurrentLRUCache { // this loop so far. queue.myMaxSize = sz - lowerWaterMark - numRemoved; while (queue.size() > queue.myMaxSize && queue.size() > 0) { - CacheEntry otherEntry = (CacheEntry) queue.pop(); + CacheEntry otherEntry = queue.pop(); newOldestEntry = Math.min(otherEntry.lastAccessedCopy, newOldestEntry); } if (queue.myMaxSize <= 0) break; diff --git a/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java b/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java index 084637b383d..2cd1aea5195 100644 --- a/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java +++ b/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java @@ -207,10 +207,10 @@ public class DateFieldTest extends LuceneTestCase { public void testCreateField() { int props = FieldProperties.INDEXED ^ FieldProperties.STORED; SchemaField sf = new SchemaField( "test", f, props, null ); - IndexableField out = (Field)f.createField(sf, "1995-12-31T23:59:59Z", 1.0f ); + IndexableField out = f.createField(sf, "1995-12-31T23:59:59Z", 1.0f ); assertEquals(820454399000l, f.toObject( out ).getTime() ); - out = (Field)f.createField(sf, new Date(820454399000l), 1.0f ); + out = f.createField(sf, new Date(820454399000l), 1.0f ); assertEquals(820454399000l, f.toObject( out ).getTime() ); } }