- コンストラクターとは異なって、名前を持てる
- コンストラクターとは異なり、インスタンスを生成しなくても良い(同じインスタンスを使いまわしても良い)
- コンストラクターとは異なり、任意のサブタイプを返せる
- コンストラクターと異なり、パラメーターの個数等入力値によって実装を切り替えられる
- コンストラクターとは異なり、ほしいインターフェースの実装がなくてもよい(
ServiceLoader
パターン)
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
Benchmark Mode Cnt Score Error Units | |
c.e.list.ArrayList10000.listAdd thrpt 16 15.398 ± 0.118 ops/ms | |
c.e.list.ArrayList10000.listGet thrpt 16 52.297 ± 2.338 ops/ms | |
c.e.list.ArrayList10000.listInsert thrpt 16 6.930 ± 0.076 ops/ms | |
c.e.list.ArrayList10000.listIteration thrpt 16 75.450 ± 1.338 ops/ms | |
c.e.list.ArrayList10000.listRemove thrpt 16 15.037 ± 0.130 ops/ms | |
c.e.list.LinkedList10000.listAdd thrpt 16 13.765 ± 0.450 ops/ms | |
c.e.list.LinkedList10000.listGet thrpt 16 0.299 ± 0.003 ops/ms |
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 com.example; | |
import org.openjdk.jmh.annotations.*; | |
import java.util.ArrayList; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.function.Consumer; | |
import java.util.stream.Stream; |
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 groovy.transform.Canonical | |
import org.springframework.http.converter.json.* | |
import com.fasterxml.jackson.databind.* | |
@Canonical | |
class Bar { | |
String fooBar | |
} | |
@RestController |
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 groovy.transform.Canonical | |
import org.springframework.http.converter.json.* | |
import com.fasterxml.jackson.databind.* | |
@Canonical | |
class Bar { | |
String fooBar | |
} | |
@RestController |
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
``` | |
parent/ | |
├── sub | |
│ └── build.gradle | |
└── build.gradle | |
``` |
name |
---|
John |
Denny |
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 com.example | |
import io.r2dbc.h2.H2ConnectionConfiguration | |
import io.r2dbc.h2.H2ConnectionFactory | |
import io.r2dbc.spi.Result | |
import io.r2dbc.spi.Row | |
import io.r2dbc.spi.RowMetadata | |
import kotlinx.coroutines.GlobalScope | |
import kotlinx.coroutines.reactive.awaitLast | |
import kotlinx.coroutines.reactive.awaitSingle |
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
enum class TalkType { | |
PAIR, GROUP | |
} | |
data class Talk(val id: Int, val type: TalkType, val name: String?, val users: List<String>) | |
sealed class TalkBuilderState | |
object IdOfTalk: TalkBuilderState() | |
object TypeOfTalk: TalkBuilderState() |