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 java.util.Objects; | |
import java.util.function.Supplier; | |
public final class Lazy<T> implements Supplier<T> { | |
private final Supplier<T> initializer; | |
private volatile T value; | |
private volatile boolean initialized = false; | |
public Lazy(final Supplier<T> initializer) { |
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.mustafakoroglu.gist.virtualfuture; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.Future; | |
import java.util.function.Supplier; | |
import java.util.stream.StreamSupport; |
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
/** | |
* A functional interface for use cases with an input of type {@code Q} and an output of type {@code S}. | |
* It extends {@code java.util.function.Function} to provide functional interface compatibility. | |
* | |
* @param <Q> the type of the request | |
* @param <S> the type of the response | |
*/ | |
@FunctionalInterface | |
public interface UseCase<Q, S> extends java.util.function.Function<Q, S> { | |
/** |
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
public abstract class EventHandler<E extends Event> { | |
@SafeVarargs | |
protected EventHandler(final E... reifiedTypeArray) { | |
if (reifiedTypeArray.length > 0) { | |
throw new IllegalArgumentException(); | |
} | |
final var reifiedType = reifiedTypeArray.getClass().getComponentType(); | |
EventBus.registerHandler((Class<? extends Event>) reifiedType, this); | |
} |
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
fun table(block: Table.() -> Unit): Table { | |
val table = Table() | |
table.block() | |
return table | |
} | |
class Table : Iterable<Row>, WithMetadataFilter<Row> { | |
private val rows = hashSetOf<Row>() | |
fun row(index: Int? = null, block: Row.() -> Unit): Row { |
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
/** | |
* Usage | |
* ```ts | |
* const person = { name: "John", surname: "Doe", age: 35 }; | |
* console.log(pick(person, "surname", "age")); | |
* ``` | |
* | |
* Result | |
* ```json | |
* { surname: 'Doe', age: 35 } |
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
export default class Optional<T> { | |
private static readonly EMPTY = new Optional(null); | |
private readonly value: T | null; | |
private constructor(value: T | null) { | |
this.value = value; | |
} | |
public static empty<T>(): Optional<T> { |
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
version: '3' | |
volumes: | |
pg_0_data: | |
driver: local | |
pg_1_data: | |
driver: local | |
services: | |
pg-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
import "reflect-metadata"; | |
import { | |
Connection, | |
createConnection, | |
EntityTarget, | |
getConnectionManager, | |
Repository, | |
} from "typeorm"; | |
import { Post } from "./posts/Post"; |
NewerOlder