Skip to content

Instantly share code, notes, and snippets.

View jelinski's full-sized avatar

Krzysztof Jeliński jelinski

View GitHub Profile
trait Bindable {
def label: String
}
case class Port(label: String) extends Bindable
case class Net(label: String) extends Bindable
case class Binding(from: Bindable, to: Bindable){
override def toString: String = s"$from -> $to"
}
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.caffeine.CaffeineCache;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static java.time.Duration.ofHours;
import static java.time.Duration.ofMinutes;
@Configuration
public class CacheConfiguration {
@jelinski
jelinski / MethodReferenceSemanticChangeTest.java
Created September 7, 2018 06:37
Draft for code that will be used to demonstrate how changing lambda to method reference can change the program behaviour
package pl.jellysoft;
import org.junit.Test;
import java.util.Arrays;
public class MethodReferenceSemanticChangeTest {
// final will solve it
private BusinessObject businessObject = new BusinessObject();
@jelinski
jelinski / initializer_blocks_order.java
Created March 19, 2018 16:58
Initialization blocks order in Java. Especially useful for anonymous classes in order to mimic constructor behavior
package pl.jellysoft;
public class Main {
public static void main(String[] args) {
// Create anonymous class
new Child() {
/* THIS WON'T COMPILE
@jelinski
jelinski / iterable_regexp.java
Created February 7, 2018 10:31
Iterable from regex processing
private <T> Iterable<List<T>> iteratePoints(String dataPointsString, final Transformer<String, T> parser) {
final Matcher matcherPoints = PATTERN_POINTS.matcher(dataPointsString);
return new Iterable<List<T>>() {
@Override
public Iterator<List<T>> iterator() {
return new Iterator<List<T>>() {
@Override
public boolean hasNext() {