All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.pojo.tester.internal.field.collections.StreamValueChanger Maven / Gradle / Ivy

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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy