Skip to content

Commit

Permalink
Remove some redundant modifiers from code (#12880)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamvishu authored Dec 11, 2023
1 parent c0fd440 commit 1630ed4
Show file tree
Hide file tree
Showing 27 changed files with 60 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ public void testNoSubAndTokenInDictionary() throws Exception { // LUCENE-8183
assertTokenStreamContents(tf8, new String[] {"fußball"});
}

public static interface MockRetainAttribute extends Attribute {
public interface MockRetainAttribute extends Attribute {
void setRetain(boolean attr);

boolean getRetain();
Expand Down
4 changes: 2 additions & 2 deletions lucene/core/src/java/org/apache/lucene/index/IndexReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public abstract sealed class IndexReader implements Closeable permits CompositeR
*
* @lucene.experimental
*/
public static interface CacheHelper {
public interface CacheHelper {

/**
* Get a key that the resource can be cached on. The given entry can be compared using identity,
Expand All @@ -139,7 +139,7 @@ public static final class CacheKey {
* @lucene.experimental
*/
@FunctionalInterface
public static interface ClosedListener {
public interface ClosedListener {
/**
* Invoked when the resource (segment core, or index reader) that is being cached on is closed.
*/
Expand Down
18 changes: 9 additions & 9 deletions lucene/core/src/java/org/apache/lucene/index/IndexableField.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
public interface IndexableField {

/** Field name */
public String name();
String name();

/** {@link IndexableFieldType} describing the properties of this field. */
public IndexableFieldType fieldType();
IndexableFieldType fieldType();

/**
* Creates the TokenStream used for indexing this field. If appropriate, implementations should
Expand All @@ -52,34 +52,34 @@ public interface IndexableField {
* @return TokenStream value for indexing the document. Should always return a non-null value if
* the field is to be indexed
*/
public TokenStream tokenStream(Analyzer analyzer, TokenStream reuse);
TokenStream tokenStream(Analyzer analyzer, TokenStream reuse);

/** Non-null if this field has a binary value */
public BytesRef binaryValue();
BytesRef binaryValue();

/** Non-null if this field has a string value */
public String stringValue();
String stringValue();

/** Non-null if this field has a string value */
default CharSequence getCharSequenceValue() {
return stringValue();
}

/** Non-null if this field has a Reader value */
public Reader readerValue();
Reader readerValue();

/** Non-null if this field has a numeric value */
public Number numericValue();
Number numericValue();

/**
* Stored value. This method is called to populate stored fields and must return a non-null value
* if the field stored.
*/
public StoredValue storedValue();
StoredValue storedValue();

/**
* Describes how this field should be inverted. This must return a non-null value if the field
* indexes terms and postings.
*/
public InvertableType invertableType();
InvertableType invertableType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ public interface TwoPhaseCommit {
* method, but avoid actual committing changes. If the 2-phase commit fails, {@link #rollback()}
* is called to discard all changes since last successful commit.
*/
public long prepareCommit() throws IOException;
long prepareCommit() throws IOException;

/**
* The second phase of a 2-phase commit. Implementations should ideally do very little work in
* this method (following {@link #prepareCommit()}, and after it returns, the caller can assume
* that the changes were successfully committed to the underlying storage.
*/
public long commit() throws IOException;
long commit() throws IOException;

/**
* Discards any changes that have occurred since the last commit. In a 2-phase commit algorithm,
* where one of the objects failed to {@link #commit()} or {@link #prepareCommit()}, this method
* is used to roll all other objects back to their previous state.
*/
public void rollback() throws IOException;
void rollback() throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public final void setCollectionProbability(double collectionProbability) {
}

/** A strategy for computing the collection language model. */
public static interface CollectionModel {
public interface CollectionModel {
/**
* Computes the probability {@code p(w|C)} according to the language model strategy for the
* current term.
*/
public double computeProbability(BasicStats stats);
double computeProbability(BasicStats stats);

/** The name of the collection model strategy. */
public String getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class ByteBufferGuard {
* this to allow unmapping of bytebuffers with private Java APIs.
*/
@FunctionalInterface
static interface BufferCleaner {
interface BufferCleaner {
void freeBuffer(String resourceDescription, ByteBuffer b) throws IOException;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public IndexInput openInput(String name, IOContext context) throws IOException {
*/
public static final String UNMAP_NOT_SUPPORTED_REASON;

static interface MMapIndexInputProvider {
interface MMapIndexInputProvider {
IndexInput openInput(Path path, IOContext context, int chunkSizePower, boolean preload)
throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
public interface RandomAccessInput {

/** The number of bytes in the file. */
public long length();
long length();

/**
* Reads a byte at the given position in the file
*
* @see DataInput#readByte
*/
public byte readByte(long pos) throws IOException;
byte readByte(long pos) throws IOException;

/**
* Reads a specified number of bytes starting at a given position into an array at the specified
Expand All @@ -53,21 +53,21 @@ default void readBytes(long pos, byte[] bytes, int offset, int length) throws IO
* @see DataInput#readShort
* @see BitUtil#VH_LE_SHORT
*/
public short readShort(long pos) throws IOException;
short readShort(long pos) throws IOException;

/**
* Reads an integer (LE byte order) at the given position in the file
*
* @see DataInput#readInt
* @see BitUtil#VH_LE_INT
*/
public int readInt(long pos) throws IOException;
int readInt(long pos) throws IOException;

/**
* Reads a long (LE byte order) at the given position in the file
*
* @see DataInput#readLong
* @see BitUtil#VH_LE_LONG
*/
public long readLong(long pos) throws IOException;
long readLong(long pos) throws IOException;
}
2 changes: 1 addition & 1 deletion lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ public static <T> T[] copyOfSubArray(T[] array, int from, int to) {

/** Comparator for a fixed number of bytes. */
@FunctionalInterface
public static interface ByteArrayComparator {
public interface ByteArrayComparator {

/**
* Compare bytes starting from the given offsets. The return value has the same contract as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ public interface AttributeReflector {
* method once using {@code org.apache.lucene.analysis.tokenattributes.CharTermAttribute.class} as
* attribute class, {@code "term"} as key and the actual value as a String.
*/
public void reflect(Class<? extends Attribute> attClass, String key, Object value);
void reflect(Class<? extends Attribute> attClass, String key, Object value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface ClassLoaderUtils {
* returned (this is fine, because if we get a {@code SecurityException} it is for sure no
* parent).
*/
public static boolean isParentClassLoader(final ClassLoader parent, final ClassLoader child) {
static boolean isParentClassLoader(final ClassLoader parent, final ClassLoader child) {
try {
ClassLoader cl = child;
while (cl != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Iterator<S> iterator() {
*
* <p>Names must be all ascii alphanumeric, and less than 128 characters in length.
*/
public static interface NamedSPI {
public interface NamedSPI {
String getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
public interface ResourceLoader {

/** Opens a named resource */
public InputStream openResource(String resource) throws IOException;
InputStream openResource(String resource) throws IOException;

/** Finds class of the name and expected type */
public <T> Class<? extends T> findClass(String cname, Class<T> expectedType);
<T> Class<? extends T> findClass(String cname, Class<T> expectedType);

/** Creates an instance of the name and expected type */
// TODO: fix exception handling
public default <T> T newInstance(String cname, Class<T> expectedType) {
default <T> T newInstance(String cname, Class<T> expectedType) {
Class<? extends T> clazz = findClass(cname, expectedType);
try {
return clazz.getConstructor().newInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
public abstract class RollingBuffer<T extends RollingBuffer.Resettable> {

/** Implement to reset an instance */
public static interface Resettable {
public void reset();
public interface Resettable {
void reset();
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface Unwrappable<T> {

/** Unwraps all {@code Unwrappable}s around the given object. */
@SuppressWarnings("unchecked")
public static <T> T unwrapAll(T o) {
static <T> T unwrapAll(T o) {
while (o instanceof Unwrappable) {
o = ((Unwrappable<T>) o).unwrap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ public interface AutomatonProvider {
* @return automaton
* @throws IOException if errors occur
*/
public Automaton getAutomaton(String name) throws IOException;
Automaton getAutomaton(String name) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int commonPrefixLengthN(byte[] a, int aOffset, byte[] b, int bOffset, int

/** Predicate for a fixed number of bytes. */
@FunctionalInterface
public static interface ByteArrayPredicate {
public interface ByteArrayPredicate {

/** Test bytes starting from the given offsets. */
boolean test(byte[] a, int aOffset, byte[] b, int bOffset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static Format byId(int id) {
throw new IllegalArgumentException("Unknown format id: " + id);
}

private Format(int id) {
Format(int id) {
this.id = id;
}

Expand Down Expand Up @@ -231,7 +231,7 @@ public static FormatAndBits fastestFormatAndBits(
}

/** A decoder for packed integers. */
public static interface Decoder {
public interface Decoder {

/**
* The minimum number of long blocks to encode in a single iteration, when using long encoding.
Expand Down Expand Up @@ -299,7 +299,7 @@ public static interface Decoder {
}

/** An encoder for packed integers. */
public static interface Encoder {
public interface Encoder {

/**
* The minimum number of long blocks to encode in a single iteration, when using long encoding.
Expand Down Expand Up @@ -400,7 +400,7 @@ public int get(int index, long[] arr, int off, int len) {
}

/** Run-once iterator interface, to decode previously saved PackedInts. */
public static interface ReaderIterator {
public interface ReaderIterator {
/** Returns next value */
long next() throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static void afterClass() throws Exception {
bigSearcher = null;
}

private static String[] docFields = {
private static final String[] docFields = {
"w1 w2 w3 w4 w5", "w1 w3 w2 w3", "w1 xx w2 yy w3", "w1 w3 xx w2 yy mm"
};

Expand Down Expand Up @@ -423,8 +423,8 @@ public void testRandomQueries() throws Exception {

// used to set properties or change every BooleanQuery
// generated from randBoolQuery.
public static interface Callback {
public void postCreate(BooleanQuery.Builder q);
public interface Callback {
void postCreate(BooleanQuery.Builder q);
}

// Random rnd is passed in so that the exact same random query may be created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
abstract class DocValuesTermsCollector<DV> extends SimpleCollector {

@FunctionalInterface
static interface Function<R> {
interface Function<R> {
R apply(LeafReader t) throws IOException;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testSetFieldBuilder() throws QueryNodeException {
assertEquals("OK", result);
}

private static interface DummyQueryNodeInterface extends QueryNode {}
private interface DummyQueryNodeInterface extends QueryNode {}

private abstract static class AbstractDummyQueryNode extends QueryNodeImpl
implements DummyQueryNodeInterface {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ public abstract class NumberRangePrefixTree extends SpatialPrefixTree {
*
* @lucene.experimental
*/
public static interface NRShape extends Shape, Cloneable {
public interface NRShape extends Shape, Cloneable {
/** The result should be parseable by {@link #parseShape(String)}. */
@Override
abstract String toString();
String toString();

/**
* Returns this shape rounded to the target level. If we are already more course than the level
* then the shape is simply returned. The result may refer to internal state of the argument so
* you may want to clone it.
*/
public NRShape roundToLevel(int targetLevel);
NRShape roundToLevel(int targetLevel);
}

//
Expand Down Expand Up @@ -234,7 +234,7 @@ public NRShape parseShape(String str) throws ParseException {
*
* @lucene.experimental
*/
public static interface UnitNRShape extends NRShape, Comparable<UnitNRShape> {
public interface UnitNRShape extends NRShape, Comparable<UnitNRShape> {
// note: formerly known as LevelledValue; thus some variables still use 'lv'

/** Get the prefix tree level, the higher the more precise. 0 means the world (universe). */
Expand Down
Loading

0 comments on commit 1630ed4

Please sign in to comment.