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
class Foo { | |
val quux = "quux" | |
def bar(baz: () => Unit): Foo = { | |
baz() | |
this | |
} | |
} | |
// I would like to write in fluent style like this but I can't reference the | |
// previous object in the chain |
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
class Bar(i: Int) { | |
val lst = List.empty[Int] | |
def copy(i: Int = i, lst: List[Int] = lst) = { | |
val b = new Bar(i = i) | |
b.lst = lst | |
} | |
} |
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
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
def runWithTimeout[T](timeoutMs: Long)(f: => Future[T]) : T = { | |
Await.result(f, timeoutMs.millis) | |
} | |
runWithTimeout(50) { Future { "result" } } |
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
class LoggerLikeStub extends LoggerLike { | |
import scala.collection.mutable.Buffer | |
val logMessages: Buffer[String] = Buffer() | |
override val logger: Logger = null | |
override def warn(msg: => String) = { | |
logMessages += msg |
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
trait A { | |
protected def f : Boolean | |
} | |
object A extends A { | |
protected def f : Boolean = true | |
} | |
object B extends A { |
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
(defprotocol PStack | |
"A stack protocol" | |
(push [this val] "Push element in") | |
(pop* [this] "Pop element from stack") | |
(top [this] "Get top element from stack")) | |
(defrecord FStack [coll] | |
PStack | |
(push [_ val] | |
"Return the stack with the new element inserted" |
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
(def ddl-parser | |
(insta/parser | |
"ddl = (createtable* (!createtable <any>)*)+ | |
<any> = #'\\S+' | |
createtable = 'CREATE TABLE' table cols | |
cols = <'('> columns <','> constraint <');'> | |
table = identifier | |
identifier = #'[a-zA-Z_0-9\\.]+' | |
columns = column (',' column)* | |
column = name type nullable? |
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
(def foo-parser | |
(insta/parser | |
"grammar = foo | other | |
foo = 'FOO' | |
other = !foo" | |
:auto-whitespace :standard)) | |
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
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@60acc399 | |
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.326 sec <<< FAILURE! | |
shouldMapHashMapToFoo(org.me.modelmapper.JsonModelMapperTest) Time elapsed: 0.186 sec <<< FAILURE! | |
org.modelmapper.ConfigurationException: ModelMapper configuration errors: | |
1) Invalid source method java.util.HashMap.get(). Ensure that method has zero parameters and does not return void. | |
2) Invalid source method java.util.HashMap.get(). Ensure that method has zero parameters and does not return void. | |
2 errors |
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
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package org.me.modelmapper; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.google.gson.JsonElement; |