com.rey.jsonbatch.function.OrFunction Maven / Gradle / Ivy
package com.rey.jsonbatch.function;
import com.rey.jsonbatch.JsonBuilder.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
@SuppressWarnings("unchecked")
public class OrFunction extends Function {
private Logger logger = LoggerFactory.getLogger(OrFunction.class);
@Override
public String getName() {
return "or";
}
@Override
public boolean isReduceFunction() {
return true;
}
@Override
public Result handle(Type type, Object argument, Result prevResult) {
Result result = prevResult == null ? Result.of(false, false) : prevResult;
if(argument instanceof Boolean) {
result.value = (Boolean)argument;
result.isDone = result.value;
return result;
}
else if(argument instanceof Collection) {
result.value = isTrue((Collection) argument);
result.isDone = result.value;
return result;
}
logger.error("Cannot process [{}] type", argument.getClass());
throw new IllegalArgumentException("Cannot process item");
}
private Boolean isTrue(Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy