Use long literals (closes #248)
This patch replaces int literals that were cast to longs (e.g., "(long) 1)" with long literals (e.g., "1L"), making the code cleaner and easier to maintain.
This commit is contained in:
parent
4670a941be
commit
6597c19652
|
@ -1158,53 +1158,53 @@ public class ArrayUtilsRemoveMultipleTest {
|
|||
public void testRemoveElementLongArray() {
|
||||
long[] array;
|
||||
|
||||
array = ArrayUtils.removeElements((long[]) null, (long) 1);
|
||||
array = ArrayUtils.removeElements((long[]) null, 1L);
|
||||
assertNull(array);
|
||||
|
||||
array = ArrayUtils.removeElements(ArrayUtils.EMPTY_LONG_ARRAY, (long) 1);
|
||||
array = ArrayUtils.removeElements(ArrayUtils.EMPTY_LONG_ARRAY, 1L);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1 }, (long) 1);
|
||||
array = ArrayUtils.removeElements(new long[] { 1 }, 1L);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2 }, (long) 1);
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2 }, 1L);
|
||||
assertTrue(Arrays.equals(new long[] { 2 }, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2, 1 }, (long) 1);
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2, 1 }, 1L);
|
||||
assertTrue(Arrays.equals(new long[] { 2, 1 }, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements((long[]) null, (long) 1, (long) 1);
|
||||
array = ArrayUtils.removeElements((long[]) null, 1L, 1L);
|
||||
assertNull(array);
|
||||
|
||||
array = ArrayUtils.removeElements(ArrayUtils.EMPTY_LONG_ARRAY, (long) 1, (long) 1);
|
||||
array = ArrayUtils.removeElements(ArrayUtils.EMPTY_LONG_ARRAY, 1L, 1L);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1 }, (long) 1, (long) 1);
|
||||
array = ArrayUtils.removeElements(new long[] { 1 }, 1L, 1L);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2 }, (long) 1, (long) 2);
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2 }, 1L, 2L);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2 }, (long) 1, (long) 1);
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2 }, 1L, 1L);
|
||||
assertTrue(Arrays.equals(new long[] { 2 }, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2, 1 }, (long) 1, (long) 1);
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2, 1 }, 1L, 1L);
|
||||
assertTrue(Arrays.equals(new long[] { 2 }, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2, 1 }, (long) 1, (long) 2);
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2, 1 }, 1L, 2L);
|
||||
assertTrue(Arrays.equals(new long[] { 1 }, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2, 1 }, (long) 1, (long) 1, (long) 1, (long) 1);
|
||||
array = ArrayUtils.removeElements(new long[] { 1, 2, 1 }, 1L, 1L, 1L, 1L);
|
||||
assertTrue(Arrays.equals(new long[] { 2 }, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
}
|
||||
|
|
|
@ -447,18 +447,18 @@ public class ArrayUtilsRemoveTest {
|
|||
@SuppressWarnings("cast")
|
||||
public void testRemoveElementLongArray() {
|
||||
long[] array;
|
||||
array = ArrayUtils.removeElement((long[]) null, (long) 1);
|
||||
array = ArrayUtils.removeElement((long[]) null, 1L);
|
||||
assertNull(array);
|
||||
array = ArrayUtils.removeElement(ArrayUtils.EMPTY_LONG_ARRAY, (long) 1);
|
||||
array = ArrayUtils.removeElement(ArrayUtils.EMPTY_LONG_ARRAY, 1L);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
array = ArrayUtils.removeElement(new long[] {1}, (long) 1);
|
||||
array = ArrayUtils.removeElement(new long[] {1}, 1L);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
array = ArrayUtils.removeElement(new long[] {1, 2}, (long) 1);
|
||||
array = ArrayUtils.removeElement(new long[] {1, 2}, 1L);
|
||||
assertTrue(Arrays.equals(new long[] {2}, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
array = ArrayUtils.removeElement(new long[] {1, 2, 1}, (long) 1);
|
||||
array = ArrayUtils.removeElement(new long[] {1, 2, 1}, 1L);
|
||||
assertTrue(Arrays.equals(new long[] {2, 1}, array));
|
||||
assertEquals(Long.TYPE, array.getClass().getComponentType());
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class RangeTest {
|
|||
byteRange3 = Range.between((byte) 0, (byte) 10);
|
||||
|
||||
intRange = Range.between(10, 20);
|
||||
longRange = Range.between((long) 10, (long) 20);
|
||||
longRange = Range.between(10L, 20L);
|
||||
floatRange = Range.between((float) 10, (float) 20);
|
||||
doubleRange = Range.between((double) 10, (double) 20);
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public class MutableLongTest {
|
|||
|
||||
@Test
|
||||
public void testIncrementAndGet() {
|
||||
final MutableLong mutNum = new MutableLong((long) 1);
|
||||
final MutableLong mutNum = new MutableLong(1L);
|
||||
final long result = mutNum.incrementAndGet();
|
||||
|
||||
assertEquals(2, result);
|
||||
|
@ -154,7 +154,7 @@ public class MutableLongTest {
|
|||
|
||||
@Test
|
||||
public void testGetAndIncrement() {
|
||||
final MutableLong mutNum = new MutableLong((long) 1);
|
||||
final MutableLong mutNum = new MutableLong(1L);
|
||||
final long result = mutNum.getAndIncrement();
|
||||
|
||||
assertEquals(1, result);
|
||||
|
@ -173,7 +173,7 @@ public class MutableLongTest {
|
|||
|
||||
@Test
|
||||
public void testDecrementAndGet() {
|
||||
final MutableLong mutNum = new MutableLong((long) 1);
|
||||
final MutableLong mutNum = new MutableLong(1L);
|
||||
final long result = mutNum.decrementAndGet();
|
||||
|
||||
assertEquals(0, result);
|
||||
|
@ -183,7 +183,7 @@ public class MutableLongTest {
|
|||
|
||||
@Test
|
||||
public void testGetAndDecrement() {
|
||||
final MutableLong mutNum = new MutableLong((long) 1);
|
||||
final MutableLong mutNum = new MutableLong(1L);
|
||||
final long result = mutNum.getAndDecrement();
|
||||
|
||||
assertEquals(1, result);
|
||||
|
@ -211,38 +211,38 @@ public class MutableLongTest {
|
|||
|
||||
@Test
|
||||
public void testGetAndAddValuePrimitive() {
|
||||
final MutableLong mutableLong = new MutableLong((long)0);
|
||||
final long result = mutableLong.getAndAdd((long) 1);
|
||||
final MutableLong mutableLong = new MutableLong(0L);
|
||||
final long result = mutableLong.getAndAdd(1L);
|
||||
|
||||
assertEquals((long) 0, result);
|
||||
assertEquals((long) 1, mutableLong.longValue());
|
||||
assertEquals(0L, result);
|
||||
assertEquals(1L, mutableLong.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAndAddValueObject() {
|
||||
final MutableLong mutableLong = new MutableLong((long)0);
|
||||
final long result = mutableLong.getAndAdd(Long.valueOf((long) 1));
|
||||
final MutableLong mutableLong = new MutableLong(0L);
|
||||
final long result = mutableLong.getAndAdd(Long.valueOf(1L));
|
||||
|
||||
assertEquals((long) 0, result);
|
||||
assertEquals((long) 1, mutableLong.longValue());
|
||||
assertEquals(0L, result);
|
||||
assertEquals(1L, mutableLong.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAndGetValuePrimitive() {
|
||||
final MutableLong mutableLong = new MutableLong((long)0);
|
||||
final long result = mutableLong.addAndGet((long) 1);
|
||||
final MutableLong mutableLong = new MutableLong(0L);
|
||||
final long result = mutableLong.addAndGet(1L);
|
||||
|
||||
assertEquals((long) 1, result);
|
||||
assertEquals((long) 1, mutableLong.longValue());
|
||||
assertEquals(1L, result);
|
||||
assertEquals(1L, mutableLong.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAndGetValueObject() {
|
||||
final MutableLong mutableLong = new MutableLong((long)0);
|
||||
final long result = mutableLong.addAndGet(Long.valueOf((long) 1));
|
||||
final MutableLong mutableLong = new MutableLong(0L);
|
||||
final long result = mutableLong.addAndGet(Long.valueOf(1L));
|
||||
|
||||
assertEquals((long) 1, result);
|
||||
assertEquals((long) 1, mutableLong.longValue());
|
||||
assertEquals(1L, result);
|
||||
assertEquals(1L, mutableLong.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue