mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-09 11:34:55 +00:00
Fix generics compiler warnings
This commit is contained in:
parent
2477d7970f
commit
47f699be39
@ -46,14 +46,15 @@ static String getFieldName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffResult diff(final SimpleClass obj) {
|
public DiffResult<SimpleClass> diff(final SimpleClass obj) {
|
||||||
return new DiffBuilder(this, obj, ToStringStyle.SHORT_PREFIX_STYLE)
|
return new DiffBuilder<>(this, obj, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||||
.append(getFieldName(), booleanField, obj.booleanField)
|
.append(getFieldName(), booleanField, obj.booleanField)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EmptyClass {
|
private static class EmptyClass {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -63,7 +64,7 @@ public void testListIsNonModifiable() {
|
|||||||
|
|
||||||
final List<Diff<?>> diffs = lhs.diff(rhs).getDiffs();
|
final List<Diff<?>> diffs = lhs.diff(rhs).getDiffs();
|
||||||
|
|
||||||
final DiffResult list = new DiffResult(lhs, rhs, diffs, SHORT_STYLE);
|
final DiffResult<SimpleClass> list = new DiffResult<>(lhs, rhs, diffs, SHORT_STYLE);
|
||||||
assertEquals(diffs, list.getDiffs());
|
assertEquals(diffs, list.getDiffs());
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
assertThrows(UnsupportedOperationException.class, () -> list.getDiffs().remove(0));
|
assertThrows(UnsupportedOperationException.class, () -> list.getDiffs().remove(0));
|
||||||
@ -77,7 +78,7 @@ public void testIterator() {
|
|||||||
final List<Diff<?>> diffs = lhs.diff(rhs).getDiffs();
|
final List<Diff<?>> diffs = lhs.diff(rhs).getDiffs();
|
||||||
final Iterator<Diff<?>> expectedIterator = diffs.iterator();
|
final Iterator<Diff<?>> expectedIterator = diffs.iterator();
|
||||||
|
|
||||||
final DiffResult list = new DiffResult(lhs, rhs, diffs, SHORT_STYLE);
|
final DiffResult<SimpleClass> list = new DiffResult<>(lhs, rhs, diffs, SHORT_STYLE);
|
||||||
final Iterator<Diff<?>> iterator = list.iterator();
|
final Iterator<Diff<?>> iterator = list.iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@ -88,7 +89,7 @@ public void testIterator() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToStringOutput() {
|
public void testToStringOutput() {
|
||||||
final DiffResult list = new DiffBuilder(new EmptyClass(), new EmptyClass(),
|
final DiffResult<EmptyClass> list = new DiffBuilder<>(new EmptyClass(), new EmptyClass(),
|
||||||
ToStringStyle.SHORT_PREFIX_STYLE).append("test", false, true)
|
ToStringStyle.SHORT_PREFIX_STYLE).append("test", false, true)
|
||||||
.build();
|
.build();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@ -98,7 +99,7 @@ public void testToStringOutput() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToStringSpecifyStyleOutput() {
|
public void testToStringSpecifyStyleOutput() {
|
||||||
final DiffResult list = SIMPLE_FALSE.diff(SIMPLE_TRUE);
|
final DiffResult<SimpleClass> list = SIMPLE_FALSE.diff(SIMPLE_TRUE);
|
||||||
assertEquals(list.getToStringStyle(), SHORT_STYLE);
|
assertEquals(list.getToStringStyle(), SHORT_STYLE);
|
||||||
|
|
||||||
final String lhsString = new ToStringBuilder(SIMPLE_FALSE,
|
final String lhsString = new ToStringBuilder(SIMPLE_FALSE,
|
||||||
@ -118,31 +119,31 @@ public void testToStringSpecifyStyleOutput() {
|
|||||||
@Test
|
@Test
|
||||||
public void testNullLhs() {
|
public void testNullLhs() {
|
||||||
assertThrows(NullPointerException.class,
|
assertThrows(NullPointerException.class,
|
||||||
() -> new DiffResult(null, SIMPLE_FALSE, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE));
|
() -> new DiffResult<>(null, SIMPLE_FALSE, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullRhs() {
|
public void testNullRhs() {
|
||||||
assertThrows(NullPointerException.class,
|
assertThrows(NullPointerException.class,
|
||||||
() -> new DiffResult(SIMPLE_TRUE, null, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE));
|
() -> new DiffResult<>(SIMPLE_TRUE, null, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullList() {
|
public void testNullList() {
|
||||||
assertThrows(NullPointerException.class,
|
assertThrows(NullPointerException.class,
|
||||||
() -> new DiffResult(SIMPLE_TRUE, SIMPLE_FALSE, null, SHORT_STYLE));
|
() -> new DiffResult<>(SIMPLE_TRUE, SIMPLE_FALSE, null, SHORT_STYLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullStyle() {
|
public void testNullStyle() {
|
||||||
final DiffResult diffResult = new DiffResult(SIMPLE_TRUE, SIMPLE_FALSE, SIMPLE_TRUE
|
final DiffResult<SimpleClass> diffResult = new DiffResult<>(SIMPLE_TRUE, SIMPLE_FALSE, SIMPLE_TRUE
|
||||||
.diff(SIMPLE_FALSE).getDiffs(), null);
|
.diff(SIMPLE_FALSE).getDiffs(), null);
|
||||||
assertEquals(ToStringStyle.DEFAULT_STYLE, diffResult.getToStringStyle());
|
assertEquals(ToStringStyle.DEFAULT_STYLE, diffResult.getToStringStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoDifferencesString() {
|
public void testNoDifferencesString() {
|
||||||
final DiffResult diffResult = new DiffBuilder(SIMPLE_TRUE, SIMPLE_TRUE,
|
final DiffResult<SimpleClass> diffResult = new DiffBuilder<>(SIMPLE_TRUE, SIMPLE_TRUE,
|
||||||
SHORT_STYLE).build();
|
SHORT_STYLE).build();
|
||||||
assertEquals(DiffResult.OBJECTS_SAME_STRING, diffResult.toString());
|
assertEquals(DiffResult.OBJECTS_SAME_STRING, diffResult.toString());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user