├── .gitignore ├── README.md ├── application ├── build.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── practice │ │ │ └── java │ │ │ └── modern │ │ │ └── tech │ │ │ └── sandbox │ │ │ └── app │ │ │ └── SandboxApplication.kt │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── example │ └── practice │ └── java │ └── modern │ └── tech │ └── sandbox │ └── app │ └── SandboxApplicationTests.kt ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── example │ │ └── practice │ │ └── java │ │ └── modern │ │ └── tech │ │ └── sandbox │ │ └── library │ │ └── hello │ │ └── HelloService.java │ └── test │ └── java │ └── com │ └── example │ └── practice │ └── java │ └── modern │ └── tech │ └── sandbox │ └── library │ └── hello │ ├── HelloServiceTest.java │ └── lambda │ ├── ImplementDataStructureByLambda.java │ └── ImplementDataStructureByLambda.kt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | out/ 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java™ modern tech practice sandbox 2 | 3 | ### More discussions/collections of [modern tech topics](https://github.com/oldratlee/java-modern-tech-practice/issues) see [the repo issues](https://github.com/oldratlee/java-modern-tech-practice/issues). 4 | 5 | - `kotlin`: Programming Language 6 | - `kotlin coroutines` 7 | - `Spring` 8 | - `Spring Boot` 9 | - `Spring 5` 10 | - `RP/Reactive Programming` 11 | - `Reactor` 12 | - `RxJava` 13 | - `RxKotlin` 14 | - `FP/Functional Programming` 15 | - `functional programming libs` 16 | - `vavr` 17 | - `jOOL` 18 | - `funKTionale` 19 | - `functional data structure`: 20 | - `Paguro` 21 | - `pcollections` 22 | - `gradle`: build tool 23 | -------------------------------------------------------------------------------- /application/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'org.springframework.boot' 2 | 3 | dependencies { 4 | implementation project(':library') 5 | 6 | implementation 'org.springframework.boot:spring-boot-starter-webflux' 7 | } 8 | 9 | -------------------------------------------------------------------------------- /application/src/main/java/com/example/practice/java/modern/tech/sandbox/app/SandboxApplication.kt: -------------------------------------------------------------------------------- 1 | package com.example.practice.java.modern.tech.sandbox.app 2 | 3 | import com.example.practice.java.modern.tech.sandbox.library.hello.HelloService 4 | import org.springframework.boot.autoconfigure.SpringBootApplication 5 | import org.springframework.boot.runApplication 6 | import org.springframework.web.bind.annotation.GetMapping 7 | import org.springframework.web.bind.annotation.RestController 8 | 9 | @SpringBootApplication(scanBasePackages = [ 10 | "com.example.practice.java.modern.tech.sandbox.app", 11 | "com.example.practice.java.modern.tech.sandbox.library.hello" 12 | ]) 13 | class SandboxApplication 14 | 15 | @RestController 16 | class DemoApplication(private val helloService: HelloService) { 17 | @GetMapping("/") 18 | fun home(): String { 19 | return helloService.message() 20 | } 21 | } 22 | 23 | fun main(args: Array) { 24 | runApplication(*args) 25 | } 26 | 27 | -------------------------------------------------------------------------------- /application/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oldratlee/java-modern-tech-practice/6bf90c9ee1392f59c8a79310a0433b6be9f0314a/application/src/main/resources/application.properties -------------------------------------------------------------------------------- /application/src/test/java/com/example/practice/java/modern/tech/sandbox/app/SandboxApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package com.example.practice.java.modern.tech.sandbox.app 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner::class) 9 | @SpringBootTest 10 | class SandboxApplicationTests { 11 | 12 | @Test 13 | fun contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | kotlinVersion = '1.3.11' 4 | kotlinCoroutinesVersion = '1.0.1' 5 | 6 | springBootVersion = '2.1.0.RELEASE' 7 | 8 | vavrVersion = '0.9.2' 9 | arrowVersion = "0.8.1" 10 | funktionaleVersion = '1.2' 11 | cyclopsVersion = '10.0.4' 12 | } 13 | repositories { 14 | maven { 15 | name 'Ali Repo' 16 | url 'https://maven.aliyun.com/nexus/content/groups/public/' 17 | } 18 | mavenCentral() 19 | } 20 | dependencies { 21 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 22 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 23 | classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") 24 | } 25 | } 26 | 27 | // https://github.com/ben-manes/gradle-versions-plugin 28 | plugins { 29 | id "com.github.ben-manes.versions" version "0.20.0" 30 | } 31 | 32 | subprojects { 33 | apply plugin: 'kotlin' 34 | apply plugin: 'kotlin-spring' 35 | apply plugin: 'io.spring.dependency-management' 36 | apply plugin: 'eclipse' 37 | 38 | group = 'com.example.practice.java.modern.tech.sandbox' 39 | version = '0.0.1-SNAPSHOT' 40 | 41 | sourceCompatibility = 1.8 42 | compileKotlin { 43 | kotlinOptions { 44 | freeCompilerArgs = ["-Xjsr305=strict"] 45 | jvmTarget = "1.8" 46 | } 47 | } 48 | compileTestKotlin { 49 | kotlinOptions { 50 | freeCompilerArgs = ["-Xjsr305=strict"] 51 | jvmTarget = "1.8" 52 | } 53 | } 54 | 55 | repositories { 56 | maven { 57 | name 'Ali Repo' 58 | url 'https://maven.aliyun.com/nexus/content/groups/public/' 59 | } 60 | mavenCentral() 61 | } 62 | 63 | dependencies { 64 | implementation 'org.springframework.boot:spring-boot-starter' 65 | implementation 'org.springframework.boot:spring-boot-starter-data-redis' 66 | implementation 'org.springframework.boot:spring-boot-starter-data-redis-reactive' 67 | 68 | implementation 'com.fasterxml.jackson.module:jackson-module-kotlin' 69 | implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}" 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion}" 71 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlinVersion}" 72 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}" 73 | implementation "org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}" 74 | 75 | /* 76 | * modern libs: Reactive/Kotlin Coroutines 77 | */ 78 | implementation 'io.reactivex.rxjava2:rxjava' 79 | implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0' 80 | // https://github.com/Kotlin/kotlinx.coroutines 81 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${kotlinCoroutinesVersion}" 82 | // kotlinx.coroutines integration 83 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${kotlinCoroutinesVersion}" 84 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:${kotlinCoroutinesVersion}" 85 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-reactor:${kotlinCoroutinesVersion}" 86 | 87 | /* 88 | * FP libs 89 | */ 90 | implementation "io.vavr:vavr:${vavrVersion}" 91 | implementation "io.vavr:vavr-kotlin:${vavrVersion}" 92 | annotationProcessor "io.vavr:vavr-match:${vavrVersion}" 93 | testAnnotationProcessor "io.vavr:vavr-match:${vavrVersion}" 94 | 95 | // cyclops 96 | implementation "com.oath.cyclops:cyclops:${cyclopsVersion}" 97 | // cyclops integrations 98 | implementation "com.oath.cyclops:cyclops-futurestream:${cyclopsVersion}" 99 | implementation "com.oath.cyclops:cyclops-rx2-integration:${cyclopsVersion}" 100 | implementation "com.oath.cyclops:cyclops-reactor-integration:${cyclopsVersion}" 101 | implementation "com.oath.cyclops:cyclops-reactive-collections:${cyclopsVersion}" 102 | implementation "com.oath.cyclops:cyclops-pure:${cyclopsVersion}" 103 | implementation "com.oath.cyclops:cyclops-anym:${cyclopsVersion}" 104 | implementation "com.oath.cyclops:cyclops-jackson-integration:${cyclopsVersion}" 105 | 106 | implementation 'com.google.guava:guava:27.0.1-jre' 107 | implementation 'org.functionaljava:functionaljava:4.8.1' 108 | implementation 'org.jooq:jool-java-8:0.9.14' 109 | 110 | // kotlin libs 111 | implementation "io.arrow-kt:arrow-core:$arrowVersion" 112 | implementation "io.arrow-kt:arrow-syntax:$arrowVersion" 113 | implementation "io.arrow-kt:arrow-typeclasses:$arrowVersion" 114 | implementation "io.arrow-kt:arrow-data:$arrowVersion" 115 | implementation "io.arrow-kt:arrow-instances-core:$arrowVersion" 116 | implementation "io.arrow-kt:arrow-instances-data:$arrowVersion" 117 | kapt "io.arrow-kt:arrow-annotations-processor:$arrowVersion" 118 | implementation "io.arrow-kt:arrow-free:$arrowVersion" //optional 119 | implementation "io.arrow-kt:arrow-instances-free:$arrowVersion" //optional 120 | implementation "io.arrow-kt:arrow-mtl:$arrowVersion" //optional 121 | implementation "io.arrow-kt:arrow-effects:$arrowVersion" //optional 122 | implementation "io.arrow-kt:arrow-effects-instances:$arrowVersion" //optional 123 | implementation "io.arrow-kt:arrow-effects-rx2:$arrowVersion" //optional 124 | implementation "io.arrow-kt:arrow-effects-rx2-instances:$arrowVersion" //optional 125 | implementation "io.arrow-kt:arrow-effects-reactor:$arrowVersion" //optional 126 | implementation "io.arrow-kt:arrow-effects-reactor-instances:$arrowVersion" //optional 127 | implementation "io.arrow-kt:arrow-effects-kotlinx-coroutines:$arrowVersion" //optional 128 | implementation "io.arrow-kt:arrow-effects-kotlinx-coroutines-instances:$arrowVersion" //optional 129 | implementation "io.arrow-kt:arrow-optics:$arrowVersion" //optional 130 | implementation "io.arrow-kt:arrow-generic:$arrowVersion" //optional 131 | implementation "io.arrow-kt:arrow-recursion:$arrowVersion" //optional 132 | implementation "io.arrow-kt:arrow-instances-recursion:$arrowVersion" //optional 133 | implementation "io.arrow-kt:arrow-integration-retrofit-adapter:$arrowVersion" //optional 134 | // funktionale 135 | // high-order function-ish 136 | implementation "org.funktionale:funktionale-composition:${funktionaleVersion}" 137 | implementation "org.funktionale:funktionale-currying:${funktionaleVersion}" 138 | implementation "org.funktionale:funktionale-partials:${funktionaleVersion}" 139 | implementation "org.funktionale:funktionale-pipe:${funktionaleVersion}" 140 | implementation "org.funktionale:funktionale-memoization:${funktionaleVersion}" 141 | implementation "org.funktionale:funktionale-reverse:${funktionaleVersion}" 142 | implementation "org.funktionale:funktionale-complement:${funktionaleVersion}" 143 | implementation "org.funktionale:funktionale-pairing:${funktionaleVersion}" 144 | implementation "org.funktionale:funktionale-utils:${funktionaleVersion}" 145 | // data container type/monad-ish 146 | implementation "org.funktionale:funktionale-either:${funktionaleVersion}" 147 | implementation "org.funktionale:funktionale-option:${funktionaleVersion}" 148 | implementation "org.funktionale:funktionale-try:${funktionaleVersion}" 149 | implementation "org.funktionale:funktionale-validation:${funktionaleVersion}" 150 | implementation "org.funktionale:funktionale-state:${funktionaleVersion}" 151 | // collection extension 152 | implementation "org.funktionale:funktionale-collections:${funktionaleVersion}" 153 | 154 | // functional data structure 155 | implementation 'org.organicdesign:Paguro:3.1.0' 156 | implementation 'org.pcollections:pcollections:3.0.3' 157 | implementation 'com.github.andrewoma.dexx:collection:0.7' 158 | 159 | /* 160 | * test libs 161 | */ 162 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 163 | testImplementation 'io.projectreactor:reactor-test' 164 | testImplementation "io.vavr:vavr-test:${vavrVersion}" 165 | } 166 | 167 | // Overriding deprecated dependencies: 168 | // kotlin-stdlib-jre7 -> kotlin-stdlib-jdk7 169 | // kotlin-stdlib-jre8 -> kotlin-stdlib-jdk8 170 | // how to, see: https://dzone.com/articles/gradle-overruling-third-party 171 | configurations.all { 172 | resolutionStrategy.eachDependency { DependencyResolveDetails details -> 173 | def requested = details.requested 174 | if (requested.group == 'org.jetbrains.kotlin' && requested.name == 'kotlin-stdlib-jre8') { 175 | details.useTarget("${requested.group}:kotlin-stdlib-jdk8:${requested.version}") 176 | } else if (requested.group == 'org.jetbrains.kotlin' && requested.name == 'kotlin-stdlib-jre7') { 177 | details.useTarget("${requested.group}:kotlin-stdlib-jdk7:${requested.version}") 178 | } 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oldratlee/java-modern-tech-practice/6bf90c9ee1392f59c8a79310a0433b6be9f0314a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Sep 01 23:45:17 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn ( ) { 37 | echo "$*" 38 | } 39 | 40 | die ( ) { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save ( ) { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | dependencyManagement { 2 | imports { 3 | mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /library/src/main/java/com/example/practice/java/modern/tech/sandbox/library/hello/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.example.practice.java.modern.tech.sandbox.library.hello; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class HelloService { 7 | 8 | public String message() { 9 | return "hello world"; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /library/src/test/java/com/example/practice/java/modern/tech/sandbox/library/hello/HelloServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.example.practice.java.modern.tech.sandbox.library.hello; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest 14 | public class HelloServiceTest { 15 | 16 | @Autowired 17 | private HelloService helloService; 18 | 19 | @Test 20 | public void contextLoads() { 21 | assertThat(helloService.message()).isEqualTo("hello world"); 22 | } 23 | 24 | @SpringBootApplication(scanBasePackageClasses = HelloService.class) 25 | static class TestApp { 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /library/src/test/java/com/example/practice/java/modern/tech/sandbox/library/hello/lambda/ImplementDataStructureByLambda.java: -------------------------------------------------------------------------------- 1 | package com.example.practice.java.modern.tech.sandbox.library.hello.lambda; 2 | 3 | import java.util.function.Function; 4 | 5 | public class ImplementDataStructureByLambda { 6 | public static void main(String[] args) { 7 | final Function intPair = createPair(1, 2); 8 | System.out.printf("Pair: %s %s%n", first(intPair), second(intPair)); 9 | 10 | final Function stringPair = createPair("hello", "world"); 11 | System.out.printf("Pair: %s %s%n", first(stringPair), second(stringPair)); 12 | 13 | final Function pair = createPair(1, "hello"); 14 | System.out.printf("Pair: %s %s%n", first(pair), second(pair)); 15 | } 16 | 17 | private static Function createPair(T first, T second) { 18 | return m -> { 19 | if (m) return first; 20 | else return second; 21 | }; 22 | } 23 | 24 | private static T first(Function pair) { 25 | return pair.apply(true); 26 | } 27 | 28 | 29 | private static T second(Function pair) { 30 | return pair.apply(false); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /library/src/test/java/com/example/practice/java/modern/tech/sandbox/library/hello/lambda/ImplementDataStructureByLambda.kt: -------------------------------------------------------------------------------- 1 | package com.example.practice.java.modern.tech.sandbox.library.hello.lambda 2 | 3 | fun main(args: Array) { 4 | val intPair = createPair(1, 2) 5 | println("Pair: ${first(intPair)} ${second(intPair)}") 6 | 7 | val stringPair = createPair("hello", "world") 8 | println("Pair: ${first(stringPair)} ${second(stringPair)}") 9 | 10 | val pair = createPair(1, "hello") 11 | println("Pair: ${first(pair)} ${second(pair)}") 12 | } 13 | 14 | fun createPair(first: T, second: T): Pair = { selector: Boolean -> 15 | if (selector) first else second 16 | } 17 | 18 | fun first(pair: Pair) = pair(true) 19 | fun second(pair: Pair) = pair(false) 20 | 21 | typealias Pair = (Boolean) -> T 22 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'sandbox' 2 | 3 | include 'library' 4 | include 'application' 5 | --------------------------------------------------------------------------------