Code Refactoring in Field [LUCENE-8486]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
1) Remove Unnecessary Boxing
As I know, Explicit manual boxing is unnecessary after Java 5.
It can be safely removed.
Before :
```java
// After Line 352
public void setByteValue(byte value) {
...
fieldsData = Byte.valueOf(value);
}
public void setShortValue(short value) {
...
fieldsData = Short.valueOf(value);
}
public void setIntValue(int value) {
...
fieldsData = Integer.valueOf(value);
}
public void setLongValue(long value) {
...
fieldsData = Long.valueOf(value);
}
public void setFloatValue(float value) {
...
fieldsData = Float.valueOf(value);
}
public void setDoubleValue(double value) {
...
fieldsData = Double.valueOf(value);
}
```
After :
```java
// After Line 352
public void setByteValue(byte value) {
...
fieldsData = value;
}
public void setShortValue(short value) {
...
fieldsData = value;
}
public void setIntValue(int value) {
...
fieldsData = value;
}
public void setLongValue(long value) {
...
fieldsData = value;
}
public void setFloatValue(float value) {
...
fieldsData = value;
}
public void setDoubleValue(double value) {
...
fieldsData = value;
}
```
2) Unnecessary static deletion in Store enum
According to ,
"A nested enum type is implicitly `static`. It is permitted for the declaration of a nested enum type to redundantly specify the `static` modifier."
So I made the following changes.
Before:
```java
// Line 600 method
public static enum Store {
YES,
NO
}
```
After:
```java
// Line 600 method
public enum Store {
YES,
NO
}
```
---
Migrated from [LUCENE-8486](https://issues.apache.org/jira/browse/LUCENE-8486) by Namgyu Kim (@danmuzi)
Attachments: [LUCENE-8486.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-8486/LUCENE-8486.patch)
Contributor guide
Research direction
Start by reviewing the attached LUCENE-8486.patch and locating the class containing setByteValue through setDoubleValue and the nested Store enum. Remove the explicit wrapper calls and redundant static modifier shown in the issue, then verify the project still compiles and its existing tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100