Skip to content

Commit

Permalink
[Java] Clean up after merge of PR #154.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Aug 16, 2018
1 parent c7db581 commit 6414d29
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public Int2NullableObjectHashMap()
}

public Int2NullableObjectHashMap(
@DoNotSub final int initialCapacity,
final float loadFactor)
@DoNotSub final int initialCapacity, final float loadFactor)
{
super(initialCapacity, loadFactor);
}
Expand All @@ -42,9 +41,7 @@ public Int2NullableObjectHashMap(
* @param shouldAvoidAllocation should allocation be avoided by caching iterators and map entries.
*/
public Int2NullableObjectHashMap(
@DoNotSub final int initialCapacity,
final float loadFactor,
final boolean shouldAvoidAllocation)
@DoNotSub final int initialCapacity, final float loadFactor, final boolean shouldAvoidAllocation)
{
super(initialCapacity, loadFactor, shouldAvoidAllocation);
}
Expand All @@ -59,13 +56,12 @@ public Int2NullableObjectHashMap(final Int2ObjectHashMap<V> mapToCopy)
super(mapToCopy);
}

@Override
protected Object mapNullValue(final Object value)
{
return value == null ? NullReference.INSTANCE : value;
}

@Override
@SuppressWarnings("unchecked")
protected V unmapNullValue(final Object value)
{
return value == NullReference.INSTANCE ? null : (V)value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public V put(final Integer key, final V value)
public V put(final int key, final V value)
{
final V val = (V)mapNullValue(value);
requireNonNull(val, "Value cannot be null");
requireNonNull(val, "value cannot be null");

V oldValue = null;
@DoNotSub final int mask = values.length - 1;
Expand Down Expand Up @@ -520,6 +520,7 @@ protected Object mapNullValue(final Object value)
return value;
}

@SuppressWarnings("unchecked")
protected V unmapNullValue(final Object value)
{
return (V)value;
Expand Down Expand Up @@ -570,7 +571,7 @@ private void increaseCapacity()
@DoNotSub final int newCapacity = values.length << 1;
if (newCapacity < 0)
{
throw new IllegalStateException("Max capacity reached at size=" + size);
throw new IllegalStateException("max capacity reached at size=" + size);
}

rehash(newCapacity);
Expand Down Expand Up @@ -756,7 +757,7 @@ public void clear()
public boolean contains(final Object o)
{
final Entry entry = (Entry)o;
final int key = ((Integer)entry.getKey()).intValue();
final int key = (Integer)entry.getKey();
final V value = getMapped(key);
return value != null && value.equals(mapNullValue(entry.getValue()));
}
Expand Down Expand Up @@ -965,7 +966,7 @@ public V getValue()
public V setValue(final V value)
{
final V val = (V)mapNullValue(value);
requireNonNull(val, "Value cannot be null");
requireNonNull(val, "value cannot be null");

if (!this.isPositionValid)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ public Object2NullableObjectHashMap()
{
}

public Object2NullableObjectHashMap(
final int initialCapacity,
final float loadFactor)
public Object2NullableObjectHashMap(final int initialCapacity, final float loadFactor)
{
super(initialCapacity, loadFactor);
}
Expand All @@ -37,20 +35,17 @@ public Object2NullableObjectHashMap(
* @param shouldAvoidAllocation should allocation be avoided by caching iterators and map entries.
*/
public Object2NullableObjectHashMap(
final int initialCapacity,
final float loadFactor,
final boolean shouldAvoidAllocation)
final int initialCapacity, final float loadFactor, final boolean shouldAvoidAllocation)
{
super(initialCapacity, loadFactor, shouldAvoidAllocation);
}

@Override
protected Object mapNullValue(final Object value)
{
return value == null ? NullReference.INSTANCE : value;
}

@Override
@SuppressWarnings("unchecked")
protected V unmapNullValue(final Object value)
{
return value == NullReference.INSTANCE ? null : (V)value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ protected Object mapNullValue(final Object value)
return value;
}

@SuppressWarnings("unchecked")
protected V unmapNullValue(final Object value)
{
return (V)value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public void shouldIterateValues()

for (final String s : intToObjectMap.values())
{
//noinspection UseBulkOperation
copyToSet.add(s);
}

Expand Down Expand Up @@ -273,6 +274,7 @@ private void assertIterateKeys(final Collection<Integer> initialSet)
final Collection<Integer> copyToSet = new HashSet<>();
for (final Integer aInteger : intToObjectMap.keySet())
{
//noinspection UseBulkOperation
copyToSet.add(aInteger);
}

Expand Down Expand Up @@ -385,13 +387,11 @@ public void shouldAllowNullValuesWithNullMapping()
{
private final Object nullRef = new Object();

@Override
protected Object mapNullValue(final Object value)
{
return value == null ? nullRef : value;
}

@Override
protected String unmapNullValue(final Object value)
{
return value == nullRef ? null : (String)value;
Expand Down

0 comments on commit 6414d29

Please sign in to comment.