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
// UserEntity.kt | |
@Entity | |
@Table(name = "users") | |
class UserEntity( | |
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | |
@Column(name = "id") | |
val id: Long = 0L, | |
@Column(name = "isDeleted") | |
var isDeleted: Boolean = false, |
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
@Repository(UserReadonlyRepository.NAME) | |
interface UserReadonlyRepository { | |
suspend fun findById(userId: UUID): User? | |
companion object { | |
const val NAME = "a.b.c.UserReadonlyRepository" | |
} | |
} | |
@Repository(UserRepository.NAME) |
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
// given: | |
interface SomeController { | |
@RequestMapping(GET, "/someApi") | |
fun someApi(): Response1 | |
} | |
@RestController | |
class SomeControllerImpl : SomeController { | |
override fun someApi1(): Response1 { | |
// ... |
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 org.springframework.beans.factory.config.ConfigurableListableBeanFactory | |
import org.springframework.beans.factory.support.BeanDefinitionRegistry | |
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor | |
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider | |
import org.springframework.context.annotation.Configuration | |
import org.springframework.core.type.filter.AnnotationTypeFilter | |
@Configuration | |
class AnnotationConfig : BeanDefinitionRegistryPostProcessor { | |
override fun postProcessBeanFactory(beanFactory: ConfigurableListableBeanFactory) { |
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
//usr/bin/env jshell --show-version "$0" "$@"; exit $? | |
public class Runner { | |
public static void main(final String[] args) { | |
System.out.println("Runner#main"); | |
} | |
} | |
System.out.println("Executing class"); | |
Runner.main(new String[0]); |
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
console.log("%cGood to go!", "font: 2em roboto; color: yellow; background-color: green;"); |
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 Animal { } | |
class Reptile extends Animal { } | |
class Bird extends Animal { } | |
interface MobileLife { | |
// Every classes derived from this interface should implement common features on it. | |
void move(double displacement); | |
double getDistance(); |
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 Animal { } | |
class Reptile extends Animal { } | |
class Bird extends Animal { } | |
mixin MobileLife { | |
// We don't need to implement _move on every classes using this mixin, since mixin can include state. | |
var _distance = 0.0; | |
void _move(double displacement) { |
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
interface UserRepository : JpaRepository<User, Long>, UserRepositoryExtension | |
interface UserRepositoryExtension { | |
/* | |
* Here we get exception as following: | |
* | |
* Caused by: java.lang.IllegalArgumentException: Failed to create query for method | |
* public abstract User UserRepositoryExtension.getByRoleCriteria(java.lang.String,java.util.Set)! | |
* At least 2 parameter(s) provided but only 1 parameter(s) present in query. | |
* |
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
interface EnumWithKey<T, K> { | |
val T.key: K | |
} | |
/* | |
* The reified type parameter lets you call the function without explicitly | |
* passing the Class-object. | |
*/ | |
inline fun <reified T : Enum<T>, R> EnumWithKey<T, R>.byKey(key: R): T? { | |
return enumValues<T>().find { it.key == key } |
NewerOlder