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

com.groupbyinc.common.jackson.jq.internal.tree.binaryop.BooleanOrExpression Maven / Gradle / Ivy

There is a newer version: 198
Show newest version
package net.thisptr.jackson.jq.internal.tree.binaryop;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.BooleanNode;

import net.thisptr.jackson.jq.JsonQuery;
import net.thisptr.jackson.jq.Scope;
import net.thisptr.jackson.jq.exception.JsonQueryException;
import net.thisptr.jackson.jq.internal.misc.JsonNodeUtils;

public class BooleanOrExpression extends BinaryOperatorExpression {
	public BooleanOrExpression(final JsonQuery lhs, final JsonQuery rhs) {
		super(lhs, rhs, "or");
	}

	@Override
	public List apply(final Scope scope, final JsonNode in) throws JsonQueryException {
		final List out = new ArrayList<>();
		for (final JsonNode l : lhs.apply(scope, in)) {
			if (JsonNodeUtils.asBoolean(l)) {
				out.add(BooleanNode.TRUE);
				continue;
			}
			for (final JsonNode r : rhs.apply(scope, in))
				out.add(BooleanNode.valueOf(JsonNodeUtils.asBoolean(r)));
		}
		return out;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy