Created
November 11, 2016 11:36
-
-
Save alex859/b2d1893f5fc58617638a916530b7c5ee to your computer and use it in GitHub Desktop.
Another kind of dsl option
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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