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

org.xbib.interlibrary.common.predicate.LibraryMapPredicate Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package org.xbib.interlibrary.common.predicate;

import org.xbib.interlibrary.api.InterlibraryConfiguration;
import org.xbib.interlibrary.api.Library;
import org.xbib.interlibrary.api.Requester;

import java.util.function.BiPredicate;

/**
 *
 */
public class LibraryMapPredicate implements BiPredicate {

    private final InterlibraryConfiguration interlibraryConfiguration;

    private final String isil;

    public LibraryMapPredicate(InterlibraryConfiguration interlibraryConfiguration, String isil) {
        this.interlibraryConfiguration = interlibraryConfiguration;
        this.isil = isil;
    }

    @Override
    public boolean test(Requester requester, Library library) {
        if (isil == null || isil.isEmpty() || "*".equals(isil)) {
            return false;
        }
        Library newLibrary = interlibraryConfiguration.getLibraries().get(isil);
        if (newLibrary != null) {
            library.setISIL(newLibrary.getISIL());
            library.setName(newLibrary.getName());
            library.setDomain(newLibrary.getDomain());
        }
        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy