org.xbib.interlibrary.common.predicate.LibraryMapPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of interlibrary-common Show documentation
Show all versions of interlibrary-common Show documentation
Interlibrary services in Java for search and availbiity of resources
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;
}
}