com.orientechnologies.orient.core.sql.parser.OOrBlock Maven / Gradle / Ivy
/* Generated By:JJTree: Do not edit this line. OOrBlock.java Version 4.3 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.executor.OResult;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class OOrBlock extends OBooleanExpression {
List subBlocks = new ArrayList();
public OOrBlock(int id) {
super(id);
}
public OOrBlock(OrientSql p, int id) {
super(p, id);
}
@Override
public boolean evaluate(OIdentifiable currentRecord, OCommandContext ctx) {
if (getSubBlocks() == null) {
return true;
}
for (OBooleanExpression block : subBlocks) {
if (block.evaluate(currentRecord, ctx)) {
return true;
}
}
return false;
}
@Override
public boolean evaluate(OResult currentRecord, OCommandContext ctx) {
if (getSubBlocks() == null) {
return true;
}
for (OBooleanExpression block : subBlocks) {
if (block.evaluate(currentRecord, ctx)) {
return true;
}
}
return false;
}
public boolean evaluate(Object currentRecord, OCommandContext ctx) {
if (currentRecord instanceof OResult) {
return evaluate((OResult) currentRecord, ctx);
} else if (currentRecord instanceof OIdentifiable) {
return evaluate((OIdentifiable) currentRecord, ctx);
} else if (currentRecord instanceof Map) {
ODocument doc = new ODocument();
doc.fromMap((Map) currentRecord);
return evaluate(doc, ctx);
}
return false;
}
public List getSubBlocks() {
return subBlocks;
}
public void setSubBlocks(List subBlocks) {
this.subBlocks = subBlocks;
}
public void addSubBlock(OBooleanExpression block) {
this.subBlocks.add(block);
}
public void toString(Map