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

org.simpleflatmapper.map.context.impl.NullChecker Maven / Gradle / Ivy

package org.simpleflatmapper.map.context.impl;

import org.simpleflatmapper.map.context.KeySourceGetter;
import org.simpleflatmapper.util.ErrorHelper;
import org.simpleflatmapper.util.Predicate;

import java.util.List;

public class NullChecker implements Predicate {

    private final List keys;
    private final KeySourceGetter keySourceGetter;

    public NullChecker(List keys, KeySourceGetter keySourceGetter) {
        this.keys = keys;
        this.keySourceGetter = keySourceGetter;
    }

    @Override
    public boolean test(S s) {
        try {
            if (keys.isEmpty()) return false;
            for (int i = 0; i < keys.size(); i++) {
                if (keySourceGetter.getValue(keys.get(i), s) != null) {
                    return false;
                }
            }
            return true;
        } catch (Exception e) {
            ErrorHelper.rethrow(e);
            throw new IllegalStateException();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy