Skip to content

Commit

Permalink
[Java] Tidy up error messages and warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Aug 16, 2018
1 parent 797f16c commit e72a3b8
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private void increaseCapacity()
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static void validateLoadFactor(final float loadFactor)
{
if (loadFactor < 0.1f || loadFactor > 0.9f)
{
throw new IllegalArgumentException("Load factor must be in the range of 0.1 to 0.9: " + loadFactor);
throw new IllegalArgumentException("load factor must be in the range of 0.1 to 0.9: " + loadFactor);
}
}

Expand All @@ -96,7 +96,7 @@ public static void validatePositivePowerOfTwo(final int value)
{
if (value > 0 && 1 == (value & (value - 1)))
{
throw new IllegalStateException("Value must be a positive power of two");
throw new IllegalStateException("value must be a positive power of two");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public int put(final int key, final int value)
{
if (value == initialValue)
{
throw new IllegalArgumentException("Cannot accept initialValue");
throw new IllegalArgumentException("cannot accept initialValue");
}

final int[] entries = this.entries;
Expand Down Expand Up @@ -566,7 +566,7 @@ private void capacity(@DoNotSub final int newCapacity)
@DoNotSub final int entriesLength = newCapacity * 2;
if (entriesLength < 0)
{
throw new IllegalStateException("Max capacity reached at size=" + size);
throw new IllegalStateException("max capacity reached at size=" + size);
}

/*@DoNotSub*/ resizeThreshold = (int)(newCapacity * loadFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public int put(final int key, final int value)
{
if (value == missingValue)
{
throw new IllegalArgumentException("Cannot accept missingValue");
throw new IllegalArgumentException("cannot accept missingValue");
}

final int[] entries = this.entries;
Expand Down Expand Up @@ -657,7 +657,7 @@ private void capacity(@DoNotSub final int newCapacity)
@DoNotSub final int entriesLength = newCapacity * 2;
if (entriesLength < 0)
{
throw new IllegalStateException("Max capacity reached at size=" + size);
throw new IllegalStateException("max capacity reached at size=" + size);
}

/*@DoNotSub*/ resizeThreshold = (int)(newCapacity * loadFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public Int2ObjectCache(
{
validatePositivePowerOfTwo(numSets);
validatePositivePowerOfTwo(setSize);
requireNonNull(evictionConsumer, "Null values are not permitted");
requireNonNull(evictionConsumer, "null values are not permitted");

if (((long)numSets) * setSize > (Integer.MAX_VALUE - 8))
{
throw new IllegalArgumentException(
"Total capacity must be <= max array size: numSets=" + numSets + " setSize=" + setSize);
"total capacity must be <= max array size: numSets=" + numSets + " setSize=" + setSize);
}

this.setSize = setSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ public V setValue(final V value)
return Integer.hashCode(getIntKey()) ^ (v != null ? v.hashCode() : 0);
}

@DoNotSub public boolean equals(final Object o)
public boolean equals(final Object o)
{
if (!(o instanceof Entry))
{
Expand Down
6 changes: 3 additions & 3 deletions agrona/src/main/java/org/agrona/collections/IntArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ public void wrap(
if (initialSize < 0 || initialSize > initialElements.length)
{
throw new IllegalArgumentException(
"Illegal initial size " + initialSize + " for array length of " + initialElements.length);
"illegal initial size " + initialSize + " for array length of " + initialElements.length);
}

if (initialElements.length < INITIAL_CAPACITY)
{
throw new IllegalArgumentException(
"Illegal initial array length " + initialElements.length + ", minimum required is " + INITIAL_CAPACITY);
"illegal initial array length " + initialElements.length + ", minimum required is " + INITIAL_CAPACITY);
}

elements = initialElements;
Expand Down Expand Up @@ -603,7 +603,7 @@ private void ensureCapacityPrivate(@DoNotSub final int requiredCapacity)
{
if (currentCapacity == MAX_CAPACITY)
{
throw new IllegalStateException("Max capacity reached: " + MAX_CAPACITY);
throw new IllegalStateException("max capacity reached: " + MAX_CAPACITY);
}

newCapacity = MAX_CAPACITY;
Expand Down
6 changes: 3 additions & 3 deletions agrona/src/main/java/org/agrona/collections/IntHashSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void increaseCapacity()
@DoNotSub final int newCapacity = values.length * 2;
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 @@ -545,7 +545,7 @@ public void copy(final IntHashSet that)
{
if (this.values.length != that.values.length)
{
throw new IllegalArgumentException("Cannot copy object: masks not equal");
throw new IllegalArgumentException("cannot copy object: masks not equal");
}

System.arraycopy(that.values, 0, this.values, 0, this.values.length);
Expand Down Expand Up @@ -595,7 +595,7 @@ public <T> T[] toArray(final T[] into)
final Class<?> componentType = into.getClass().getComponentType();
if (!componentType.isAssignableFrom(Integer.class))
{
throw new ArrayStoreException("Cannot store Integers in array of type " + componentType);
throw new ArrayStoreException("cannot store Integers in array of type " + componentType);
}

@DoNotSub final int size = size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public int put(final K key, final int value)
{
if (value == missingValue)
{
throw new IllegalArgumentException("Cannot accept missingValue");
throw new IllegalArgumentException("cannot accept missingValue");
}

int oldValue = missingValue;
Expand Down Expand Up @@ -592,7 +592,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 @@ -989,7 +989,7 @@ public int setValue(final int value)
{
if (value == missingValue)
{
throw new IllegalArgumentException("Cannot accept missingValue");
throw new IllegalArgumentException("cannot accept missingValue");
}

@DoNotSub final int pos = position();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private V getMapped(final Object key)
public V put(final Object key, final Object value)
{
final Object val = mapNullValue(value);
requireNonNull(val, "Value cannot be null");
requireNonNull(val, "value cannot be null");

final Object[] entries = this.entries;
final int mask = entries.length - 1;
Expand Down Expand Up @@ -490,7 +490,7 @@ private void capacity(final int newCapacity)
final int entriesLength = newCapacity * 2;
if (entriesLength < 0)
{
throw new IllegalStateException("Max capacity reached at size=" + size);
throw new IllegalStateException("max capacity reached at size=" + size);
}

/*@DoNotSub*/ resizeThreshold = (int)(newCapacity * loadFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void increaseCapacity()
final int newCapacity = values.length * 2;
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 @@ -481,7 +481,7 @@ public void copy(final ObjectHashSet<T> that)
{
if (this.values.length != that.values.length)
{
throw new IllegalArgumentException("Cannot copy object: lengths not equal");
throw new IllegalArgumentException("cannot copy object: lengths not equal");
}

System.arraycopy(that.values, 0, this.values, 0, this.values.length);
Expand Down Expand Up @@ -660,7 +660,6 @@ public T next()
/**
* @return the next int value.
*/
@SuppressWarnings("unchecked")
public T nextValue()
{
if (!hasNext())
Expand All @@ -675,14 +674,14 @@ public T nextValue()
for (int i = positionCounter - 1; i >= stopCounter; i--)
{
final int index = i & mask;
final Object value = values[index];
final T value = values[index];
if (value != MISSING_VALUE)
{
positionCounter = i;
isPositionValid = true;
--remaining;

return (T)value;
return value;
}
}

Expand Down

0 comments on commit e72a3b8

Please sign in to comment.