Skip to content

Instantly share code, notes, and snippets.

@alex859
Created November 11, 2016 11:36
Show Gist options
  • Save alex859/b2d1893f5fc58617638a916530b7c5ee to your computer and use it in GitHub Desktop.
Save alex859/b2d1893f5fc58617638a916530b7c5ee to your computer and use it in GitHub Desktop.
Another kind of dsl option
package classes
import Condition._
import scala.beans.BeanProperty
object Test2 extends App {
val facts = new Facts()
facts.setBalance(23)
facts.setName("Ale")
print (facts.balance > 4 and facts.name != "Ale")
}
case class Condition(inner : Boolean) {
def and(other : Condition) : Condition = new Condition(inner && other.inner)
}
object Condition {
implicit def booleanToCondition(b: Boolean) : Condition = new Condition(b)
}
class Facts {
@BeanProperty var name: String = _
@BeanProperty var balance: Integer = _
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment