title: Represent simple conditional statements in Java
body: <p>I'm working on a project in which I need to represent conditional statements on object attributes and [booleans|integers|float...] because I need to store the results of these conditions (whether they are true or false) so that I don't have to check them again in the future (there are many conditions, it's actually an optimization).</p>
  
  <pre><code>class Foo {
      public String getThing() {
          return this.thing;
      }
      private String thing;
  
      public int getBob() {
          return this.bob;
      }
      private int bob;
  }
  
  class Bar {
      public String getStuff() {
          return this.stuff
      }
      private String stuff;
  }
  
  Foo foo = new Foo();
  Bar bar = new Bar();
  </code></pre>
  
  <p>Here I would like to store the condition that <code>foo.thing != bar.stuff</code> and the condition that <code>foo.bob &lt; 3</code>. I would like to be able to store all 4 main operations <code>&lt;, &gt;, ==, !=</code> (the objects compared will implement Java's <code>Comparable</code> interface).</p>
  
  <p>I imagined I could store a conditional statement in a</p>
  
  <p><code>Triplet&lt;getAttr1(), Operator.[Equal|GreaterThan...], getAttr2()</code></p>
  
  <p>(with an evalution function and where <code>Operator</code> is a class I would have defined)</p>
  
  <p>The attributes could be stored as functions since the value of the attribute will always be given by its getter. Thing is I also want to compare with other types, like <code>boolean, int, float</code>...</p>
  
  <p><strong>How can I represent these conditional statements?</strong></p>