pl.pojo.tester.internal.field.collections.StreamValueChanger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pojo-tester Show documentation
Show all versions of pojo-tester Show documentation
Java pojo-methods testing library.
The newest version!
package pl.pojo.tester.internal.field.collections;
import pl.pojo.tester.internal.field.AbstractFieldValueChanger;
import java.util.Arrays;
import java.util.stream.Stream;
class StreamValueChanger extends AbstractFieldValueChanger> {
@Override
public boolean areDifferentValues(final Stream sourceValue, final Stream targetValue) {
if (sourceValue == targetValue) {
return false;
}
if (sourceValue == null || targetValue == null) {
return true;
} else {
final Object[] sourceValuesArray = sourceValue.toArray();
final Object[] targetValuesArray = targetValue.toArray();
return !Arrays.deepEquals(sourceValuesArray, targetValuesArray);
}
}
@Override
protected boolean canChange(final Class> type) {
return type.isAssignableFrom(getGenericTypeClass());
}
@Override
protected Stream> increaseValue(final Stream> value, final Class> type) {
return value == null
? Stream.empty()
: null;
}
}