Tabnine Logo
BaseCondition.evaluate
Code IndexAdd Tabnine to your IDE (free)

How to use
evaluate
method
in
io.yawp.repository.query.condition.BaseCondition

Best Java code snippets using io.yawp.repository.query.condition.BaseCondition.evaluate (Showing top 11 results out of 315)

origin: feroult/yawp

private boolean evaluateOr(Object object) {
  for (BaseCondition condition : conditions) {
    if (condition.evaluate(object)) {
      return true;
    }
  }
  return false;
}
origin: feroult/yawp

private boolean evaluateAnd(Object object) {
  for (BaseCondition condition : conditions) {
    if (!condition.evaluate(object)) {
      return false;
    }
  }
  return true;
}
origin: feroult/yawp

  @Override
  public boolean evaluate(Object object) {
    return condition.evaluate(object);
  }
}
origin: feroult/yawp

  public <T> List<T> applyPostFilter(List<T> objects) {
    List<T> result = new ArrayList<>();

    for (T object : objects) {
      if (!evaluate(object)) {
        continue;
      }
      result.add(object);
    }

    return result;
  }
}
origin: feroult/yawp

private boolean evaluateExisting() {
  if (condition == null) {
    return true;
  }
  if (objects == null) {
    return condition.evaluate(id.fetch());
  }
  return evaluateObjects(new EvaluateExisting());
}
origin: feroult/yawp

  @Override
  public boolean evaluate(Object object) {
    ObjectHolder objectHolder = new ObjectHolder(object);
    IdRef<?> id = objectHolder.getId();
    if (id == null) {
      return true;
    }
    Object existingObject;
    try {
      existingObject = id.fetch();
    } catch (NoResultException e) {
      return true;
    }
    return condition.evaluate(existingObject);
  }
}
origin: feroult/yawp

@Test
public void testSimpleConditions() {
  BasicObject object = new BasicObject();
  object.setIntValue(10);
  assertTrue(c("intValue", "=", 10).evaluate(object));
  assertTrue(c("intValue", ">", 9).evaluate(object));
  assertTrue(c("intValue", ">=", 9).evaluate(object));
  assertTrue(c("intValue", ">=", 10).evaluate(object));
  assertTrue(c("intValue", "<", 11).evaluate(object));
  assertTrue(c("intValue", "<=", 11).evaluate(object));
  assertTrue(c("intValue", "<=", 10).evaluate(object));
  assertTrue(c("intValue", "!=", 5).evaluate(object));
  assertTrue(c("intValue", "IN", Arrays.asList(9, 10, 11)).evaluate(object));
  assertFalse(c("intValue", "IN", Arrays.asList(9, 11)).evaluate(object));
}
origin: feroult/yawp

private List<Object> queryWhere(QueryBuilder<?> builder) {
  List<Object> objectsInStore = MockStore.list(builder.getModel().getClazz(), builder.getParentId());
  BaseCondition condition = builder.getCondition();
  List<Object> result = new ArrayList<Object>();
  for (Object object : objectsInStore) {
    if (condition != null && !condition.evaluate(object)) {
      continue;
    }
    result.add(object);
  }
  return result;
}
origin: feroult/yawp

@Test
public void testJoinedConditions() {
  BasicObject object = new BasicObject();
  object.setIntValue(10);
  object.setStringValue("ccc");
  object.setLongValue(100l);
  assertTrue(c("intValue", "=", 10).and(c("stringValue", "=", "ccc")).evaluate(object));
  assertFalse(c("intValue", "=", 10).and(c("stringValue", "!=", "ccc")).evaluate(object));
  assertTrue(c("intValue", "=", 9).or(c("stringValue", "=", "ccc")).evaluate(object));
  assertFalse(c("intValue", "=", 10).not().evaluate(object));
  assertTrue(c("intValue", "=", 9).not().evaluate(object));
  assertTrue(c("intValue", "=", 9).or(c("stringValue", "=", "bbb").or(c("longValue", "=", 100l))).evaluate(object));
}
origin: feroult/yawp

@Test
public void testParentRef() {
  Parent parent = new Parent("parent");
  yawp.save(parent);
  Child child = new Child("child", parent.getId());
  yawp.save(child);
  Grandchild grandchild = new Grandchild("grandchild", child.getId());
  yawp.save(grandchild);
  BaseCondition c = c("parent->parent->name", "=", "parent");
  c.init(yawp, Grandchild.class);
  assertTrue(c.evaluate(grandchild));
  assertTrue(c.evaluate(child));
  assertTrue(c.evaluate(parent));
}
origin: feroult/yawp

  @Test
  public void testIgnoreConditionForChildFields() {
    Parent parent = new Parent("parent");
    yawp.save(parent);

    Child child = new Child("child", parent.getId());
    yawp.save(child);

    Grandchild grandchild = new Grandchild("grandchild", child.getId());
    grandchild.setAge(10);
    yawp.save(grandchild);

    BaseCondition c = c("age", "=", 11);
    c.init(yawp, Grandchild.class);

    assertFalse(c.evaluate(grandchild));
    assertTrue(c.evaluate(child));
    assertTrue(c.evaluate(parent));

  }
}
io.yawp.repository.query.conditionBaseConditionevaluate

Popular methods of BaseCondition

  • hasPreFilter
  • init
  • not
  • and
  • applyPostFilter
  • hasPostFilter
  • or
  • toMap

Popular in Java

  • Reactive rest calls using spring rest template
  • setScale (BigDecimal)
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now