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
| package net.mojang.benchmark; | |
| import org.openjdk.jmh.annotations.Benchmark; | |
| import org.openjdk.jmh.annotations.Mode; | |
| import org.openjdk.jmh.annotations.Scope; | |
| import org.openjdk.jmh.annotations.Setup; | |
| import org.openjdk.jmh.annotations.State; | |
| import org.openjdk.jmh.infra.Blackhole; | |
| import org.openjdk.jmh.runner.Runner; | |
| import org.openjdk.jmh.runner.options.Options; |
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
| import net.minidev.json.JSONObject; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| public class ReproTest { | |
| public static void main(String[] args) { | |
| MyData data = new MyData("a"); | |
| Map<String, Object> m = new HashMap<>(); | |
| m.put("data", data); |
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
| import com.fasterxml.jackson.core.type.TypeReference; | |
| import com.fasterxml.jackson.databind.ObjectMapper; | |
| import java.io.IOException; | |
| import java.io.UncheckedIOException; | |
| import java.net.http.HttpResponse; | |
| import java.util.function.Function; | |
| public class JacksonBodyHandlers { | |
| private final ObjectMapper objectMapper; |
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
| var providesStubRemoteApi = new Factories(){ | |
| Optional<RemoteApi> remoteApi(){ | |
| RemoteApi remoteApi = MyStubRemoteApi(); | |
| return Optional.of(remoteApi); | |
| } | |
| } | |
| var app = bootstrapper.bootstrap(config, providesStubRemoteApi); |
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
| class Bootstrapper { | |
| public Application bootStrap(Config cfg, Factories factories){ | |
| var someDependency = constructTheDependency(); | |
| var myService = factories.myService().orElseGet(() -> constructTheRealThing(someDependency)); | |
| } | |
| } |
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
| interface Factories { | |
| default Optional<MyService> myService(){return Optional.empty();} | |
| default Optional<RemoteApi> remoteApi(){return Optional.empty();} | |
| static Factories factories(){return new Factories(){};} | |
| } |
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
| import kotlinx.coroutines.experimental.* | |
| import kotlinx.coroutines.experimental.channels.Channel | |
| import kotlinx.coroutines.experimental.channels.actor | |
| class RequestCollapser<in ARGUMENT, BATCH_RESP, out RETURN_TYPE>( | |
| private val threshold: Int, | |
| private val fn: suspend (Collection<ARGUMENT>) -> BATCH_RESP, | |
| private val remapper: (ARGUMENT, BATCH_RESP) -> RETURN_TYPE | |
| ) { |
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
| #!/usr/bin/env jjs | |
| /*#################################################################################################################################### | |
| # As Nashorn does not have http capabilities through XMLHttpRequest (DOM API), we have to use regular Java classes instead. | |
| # This sample shows how this can be acheived without depending on any third party libraries. Just a standard Java 8 JDK. | |
| # Make sure to have JAVA_HOME/bin on your PATH for the shebang to work. Then just chmod +x away and run... | |
| # Alternatively if you're on a non *nix OS, start with jjs -scritping httpsample.js | |
| ####################################################################################################################################*/ | |
| var url = "https://api.github.com/users/billybong/repos"; | |
| var response; |