Created
April 30, 2020 09:13
-
-
Save ruurtjan/846421b0b4a1f8a444a39464ee96d800 to your computer and use it in GitHub Desktop.
functional-dsl-blog-3.scala
This file contains hidden or 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
val always: EmailFilter = Always | |
val never: EmailFilter = always.negate | |
def senderIs(sender: Address): EmailFilter = SenderEquals(sender) | |
def senderIsNot(sender: Address): EmailFilter = SenderEquals(sender).negate | |
def recipientIs(recipient: Address): EmailFilter = RecipientEquals(recipient) | |
def recipientIsNot(recipient: Address): EmailFilter = RecipientEquals(recipient).negate | |
def senderIn(senders: Set[Address]): EmailFilter = senders.foldLeft(never)(_ || senderIs(_)) | |
def recipientIn(recipients: Set[Address]): EmailFilter = recipients.foldLeft(never)(_ || recipientIs(_)) | |
def bodyContains(phrase: String): EmailFilter = BodyContains(phrase) | |
def bodyDoesNotContain(phrase: String): EmailFilter = BodyContains(phrase).negate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment