Enable PMD rule UnnecessaryBoxing and fix violations
This commit is contained in:
parent
dd896347a2
commit
c73a8cebb8
6 changed files with 30 additions and 34 deletions
|
@ -419,7 +419,7 @@ public final class MicroCache2 extends MicroCache {
|
|||
nlinks++;
|
||||
|
||||
if (isInternal) {
|
||||
int nodeIdx = idx.intValue();
|
||||
int nodeIdx = idx;
|
||||
if (dodebug) System.out.println("*** target nodeIdx=" + nodeIdx);
|
||||
if (nodeIdx == n) throw new RuntimeException("ups: self ref?");
|
||||
nodeIdxDiff.encodeSignedValue(nodeIdx - n);
|
||||
|
|
|
@ -296,7 +296,7 @@ abstract class OsmPath implements OsmLinkHolder {
|
|||
// apply a start-direction if appropriate (by faking the origin position)
|
||||
if (isStartpoint) {
|
||||
if (rc.startDirectionValid) {
|
||||
double dir = rc.startDirection.intValue() * CheapRuler.DEG_TO_RAD;
|
||||
double dir = rc.startDirection * CheapRuler.DEG_TO_RAD;
|
||||
double[] lonlat2m = CheapRuler.getLonLatToMeterScales((lon0 + lat1) >> 1);
|
||||
lon0 = lon1 - (int) (1000. * Math.sin(dir) / lonlat2m[0]);
|
||||
lat0 = lat1 - (int) (1000. * Math.cos(dir) / lonlat2m[1]);
|
||||
|
|
|
@ -246,7 +246,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
public int getLookupKey(String name) {
|
||||
int res = -1;
|
||||
try {
|
||||
res = lookupNumbers.get(name).intValue();
|
||||
res = lookupNumbers.get(name);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return res;
|
||||
|
@ -438,7 +438,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
// first count
|
||||
for (String name : lookupNumbers.keySet()) {
|
||||
int cnt = 0;
|
||||
int inum = lookupNumbers.get(name).intValue();
|
||||
int inum = lookupNumbers.get(name);
|
||||
int[] histo = lookupHistograms.get(inum);
|
||||
// if ( histo.length == 500 ) continue;
|
||||
for (int i = 2; i < histo.length; i++) {
|
||||
|
@ -451,7 +451,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
String key = counts.lastEntry().getKey();
|
||||
String name = counts.get(key);
|
||||
counts.remove(key);
|
||||
int inum = lookupNumbers.get(name).intValue();
|
||||
int inum = lookupNumbers.get(name);
|
||||
BExpressionLookupValue[] values = lookupValues.get(inum);
|
||||
int[] histo = lookupHistograms.get(inum);
|
||||
if (values.length == 1000) continue;
|
||||
|
@ -508,7 +508,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
|
||||
public String variableName(int idx) {
|
||||
for (Map.Entry<String, Integer> e : variableNumbers.entrySet()) {
|
||||
if (e.getValue().intValue() == idx) {
|
||||
if (e.getValue() == idx) {
|
||||
return e.getKey();
|
||||
}
|
||||
}
|
||||
|
@ -545,9 +545,8 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
}
|
||||
|
||||
// look for that value
|
||||
int inum = num.intValue();
|
||||
BExpressionLookupValue[] values = lookupValues.get(inum);
|
||||
int[] histo = lookupHistograms.get(inum);
|
||||
BExpressionLookupValue[] values = lookupValues.get(num);
|
||||
int[] histo = lookupHistograms.get(num);
|
||||
int i = 0;
|
||||
boolean bFoundAsterix = false;
|
||||
for (; i < values.length; i++) {
|
||||
|
@ -559,7 +558,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
if (lookupData2 != null) {
|
||||
// do not create unknown value for external data array,
|
||||
// record as 'unknown' instead
|
||||
lookupData2[inum] = 1; // 1 == unknown
|
||||
lookupData2[num] = 1; // 1 == unknown
|
||||
if (bFoundAsterix) {
|
||||
// found value for lookup *
|
||||
//System.out.println( "add unknown " + name + " " + value );
|
||||
|
@ -653,11 +652,11 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
// found negative maxdraft values
|
||||
// no negative values
|
||||
// values are float with 2 decimals
|
||||
lookupData2[inum] = 1000 + (int) (Math.abs(Float.parseFloat(value)) * 100f);
|
||||
lookupData2[num] = 1000 + (int) (Math.abs(Float.parseFloat(value)) * 100f);
|
||||
} catch (Exception e) {
|
||||
// ignore errors
|
||||
System.err.println("error for " + name + " " + org + " trans " + value + " " + e.getMessage());
|
||||
lookupData2[inum] = 0;
|
||||
lookupData2[num] = 0;
|
||||
}
|
||||
}
|
||||
return newValue;
|
||||
|
@ -678,15 +677,15 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
histo = nhisto;
|
||||
newValue = new BExpressionLookupValue(value);
|
||||
values[i] = newValue;
|
||||
lookupHistograms.set(inum, histo);
|
||||
lookupValues.set(inum, values);
|
||||
lookupHistograms.set(num, histo);
|
||||
lookupValues.set(num, values);
|
||||
}
|
||||
|
||||
histo[i]++;
|
||||
|
||||
// finally remember the actual data
|
||||
if (lookupData2 != null) lookupData2[inum] = i;
|
||||
else lookupData[inum] = i;
|
||||
if (lookupData2 != null) lookupData2[num] = i;
|
||||
else lookupData[num] = i;
|
||||
return newValue;
|
||||
}
|
||||
|
||||
|
@ -701,11 +700,10 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
}
|
||||
|
||||
// look for that value
|
||||
int inum = num.intValue();
|
||||
int nvalues = lookupValues.get(inum).length;
|
||||
int nvalues = lookupValues.get(num).length;
|
||||
if (valueIndex < 0 || valueIndex >= nvalues)
|
||||
throw new IllegalArgumentException("value index out of range for name " + name + ": " + valueIndex);
|
||||
lookupData[inum] = valueIndex;
|
||||
lookupData[num] = valueIndex;
|
||||
}
|
||||
|
||||
|
||||
|
@ -722,9 +720,8 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
}
|
||||
|
||||
// look for that value
|
||||
int inum = num.intValue();
|
||||
int nvalues = lookupValues.get(inum).length;
|
||||
int oldValueIndex = lookupData[inum];
|
||||
int nvalues = lookupValues.get(num).length;
|
||||
int oldValueIndex = lookupData[num];
|
||||
if (oldValueIndex > 1 && oldValueIndex < valueIndex) {
|
||||
return;
|
||||
}
|
||||
|
@ -733,12 +730,12 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
}
|
||||
if (valueIndex < 0)
|
||||
throw new IllegalArgumentException("value index out of range for name " + name + ": " + valueIndex);
|
||||
lookupData[inum] = valueIndex;
|
||||
lookupData[num] = valueIndex;
|
||||
}
|
||||
|
||||
public boolean getBooleanLookupValue(String name) {
|
||||
Integer num = lookupNumbers.get(name);
|
||||
return num != null && lookupData[num.intValue()] == 2;
|
||||
return num != null && lookupData[num] == 2;
|
||||
}
|
||||
|
||||
public int getOutputVariableIndex(String name, boolean mustExist) {
|
||||
|
@ -850,7 +847,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
public void setVariableValue(String name, float value, boolean create) {
|
||||
Integer num = variableNumbers.get(name);
|
||||
if (num != null) {
|
||||
variableData[num.intValue()] = value;
|
||||
variableData[num] = value;
|
||||
} else if (create) {
|
||||
num = getVariableIdx(name, create);
|
||||
float[] readOnlyData = variableData;
|
||||
|
@ -859,13 +856,13 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
for (int i = 0; i < minWriteIdx; i++) {
|
||||
variableData[i] = readOnlyData[i];
|
||||
}
|
||||
variableData[num.intValue()] = value;
|
||||
variableData[num] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float getVariableValue(String name, float defaultValue) {
|
||||
Integer num = variableNumbers.get(name);
|
||||
return num == null ? defaultValue : getVariableValue(num.intValue());
|
||||
return num == null ? defaultValue : getVariableValue(num);
|
||||
}
|
||||
|
||||
float getVariableValue(int variableIdx) {
|
||||
|
@ -883,7 +880,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
return num.intValue();
|
||||
return num;
|
||||
}
|
||||
|
||||
int getMinWriteIdx() {
|
||||
|
@ -901,7 +898,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
|
||||
public int getLookupNameIdx(String name) {
|
||||
Integer num = lookupNumbers.get(name);
|
||||
return num == null ? -1 : num.intValue();
|
||||
return num == null ? -1 : num;
|
||||
}
|
||||
|
||||
public final void markLookupIdxUsed(int idx) {
|
||||
|
|
|
@ -15,7 +15,7 @@ public class IpAccessMonitor {
|
|||
synchronized (sync) {
|
||||
Long lastTime = ipAccess.get(ip);
|
||||
ipAccess.put(ip, t);
|
||||
return lastTime == null || t - lastTime.longValue() > MAX_IDLE;
|
||||
return lastTime == null || t - lastTime > MAX_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class IpAccessMonitor {
|
|||
private static void cleanup(long t) {
|
||||
Map<String, Long> newMap = new HashMap<>(ipAccess.size());
|
||||
for (Map.Entry<String, Long> e : ipAccess.entrySet()) {
|
||||
if (t - e.getValue().longValue() <= MAX_IDLE) {
|
||||
if (t - e.getValue() <= MAX_IDLE) {
|
||||
newMap.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class DenseLongMapTest {
|
|||
long k = (long) (rand.nextDouble() * keyrange);
|
||||
Long KK = k;
|
||||
Integer VV = hmap.get(KK);
|
||||
int hvalue = VV == null ? -1 : VV.intValue();
|
||||
int hvalue = VV == null ? -1 : VV;
|
||||
int dvalue = dmap.getInt(k);
|
||||
|
||||
if (hvalue != dvalue) {
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
<!-- <rule ref="category/java/bestpractices.xml/UnusedAssignment" /> -->
|
||||
<rule ref="category/java/codestyle.xml/UseDiamondOperator" />
|
||||
<!-- <rule ref="category/java/design.xml/ImmutableField" /> -->
|
||||
<!-- Will be added in PMD 7 -->
|
||||
<!-- <rule ref="category/java/codestyle.xml/UnnecessaryBoxing" /> -->
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryBoxing" />
|
||||
|
||||
</ruleset>
|
||||
|
|
Loading…
Reference in a new issue