Skip to content

Commit

Permalink
[Java] Maker parameters final that can be.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Feb 3, 2017
1 parent 428e6db commit 854e52b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public class Int2IntCounterMap

private int[] entries;


/**
* Construct a new counter map with the initial value for the counter provided.
*
* @param initialValue to be used for each counter.
*/
public Int2IntCounterMap(final int initialValue)
{
this(8, 0.67f, initialValue);
Expand Down Expand Up @@ -193,7 +197,7 @@ public int decrementAndGet(final int key)
* @return the new value associated with the specified key, or
* {@link #initialValue()} + amount if there was no mapping for the key.
*/
public int addAndGet(final int key, int amount)
public int addAndGet(final int key, final int amount)
{
return getAndAdd(key, amount) + amount;
}
Expand Down Expand Up @@ -229,7 +233,7 @@ public int getAndDecrement(final int key)
* @return the previous value associated with the specified key, or
* {@link #initialValue()} if there was no mapping for the key.
*/
public int getAndAdd(final int key, int amount)
public int getAndAdd(final int key, final int amount)
{
final int[] entries = this.entries;
final int initialValue = this.initialValue;
Expand Down Expand Up @@ -529,7 +533,7 @@ public String toString()
return (index + 2) & mask;
}

private void capacity(@DoNotSub int newCapacity)
private void capacity(@DoNotSub final int newCapacity)
{
@DoNotSub final int entriesLength = newCapacity * 2;
if (entriesLength < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public int replace(final int key, final int value)
* @param newValue value to be associated with the specified key
* @return {@code true} if the value was replaced
*/
public boolean replace(final int key, int oldValue, int newValue)
public boolean replace(final int key, final int oldValue, final int newValue)
{
final int curValue = get(key);
if (curValue != oldValue || curValue == missingValue)
Expand All @@ -547,7 +547,7 @@ public boolean replace(final int key, int oldValue, int newValue)
return (index + 2) & mask;
}

private void capacity(@DoNotSub int newCapacity)
private void capacity(@DoNotSub final int newCapacity)
{
@DoNotSub final int entriesLength = newCapacity * 2;
if (entriesLength < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public V replace(final int key, final V value)
* @param newValue value to be associated with the specified key
* @return {@code true} if the value was replaced
*/
public boolean replace(final int key, V oldValue, V newValue)
public boolean replace(final int key, final V oldValue, final V newValue)
{
final Object curValue = get(key);
if (curValue == null || !Objects.equals(curValue, oldValue))
Expand Down
4 changes: 4 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

<module name="ConstantName"/>

<module name="FinalParameters">
<property name="tokens" value="CTOR_DEF"/>
</module>

<module name="FinalLocalVariable"/>

<module name="LocalFinalVariableName"/>
Expand Down

0 comments on commit 854e52b

Please sign in to comment.