org.xbib.interlibrary.common.predicate.SelfPredicate 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.Requester;
import java.util.function.BiPredicate;
/**
*
*/
public class SelfPredicate implements BiPredicate {
private final String group;
private final String isil;
public SelfPredicate(String isil) {
this(null, isil);
}
public SelfPredicate(String group, String isil) {
this.group = group;
this.isil = isil;
}
@Override
public boolean test(Requester requester, String isil) {
return (requester.getGroup() == null || group == null || requester.getGroup().equals(group)) &&
(requester.getISIL().equals(isil) ||
isil.startsWith(requester.getISIL() + "-") ||
requester.getISIL().startsWith(isil + "-") ||
this.isil.equals(isil));
}
}