Skip to content

Instantly share code, notes, and snippets.

private Map<Integer,? extends Address> getAddressIndex(Optional<SubjectData> currentSubjectData) {
return currentSubjectData
.map(subjectData -> subjectData
.getAddresses()
.stream()
.filter(address -> address.getEsoId() != null)
.collect(toMap(Address::getEsoId, t -> t))
)
.orElse(emptyMap())
;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
import java.util.List;
import java.util.Arrays;
import com.google.common.collect.Lists;
// javac -classpath c:\java\m2\repository\com\google\guava\guava\17.0\guava-17.0.jar X.java
// java -classpath .;c:\java\m2\repository\com\google\guava\guava\17.0\guava-17.0.jar X
public class X {
package anno;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.AnnotatedArrayType;
import java.lang.reflect.AnnotatedParameterizedType;
import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Field;
package anno;
import static java.util.stream.Collectors.toList;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.AnnotatedArrayType;
import java.lang.reflect.AnnotatedElement;
import java.io.IOException;
import org.apache.logging.log4j.core.appender.AbstractManager;
import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager;
import org.apache.logging.log4j.core.appender.rolling.RolloverDescription;
import org.apache.logging.log4j.core.appender.rolling.RolloverDescriptionImpl;
import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
import org.apache.logging.log4j.core.appender.rolling.action.AbstractAction;
import org.apache.logging.log4j.core.appender.rolling.action.Action;
import java.lang.reflect.*;
import java.util.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
public class AnnotationOnTypeArgument {
@tomaszalusky
tomaszalusky / Mapping.java
Created February 7, 2017 14:07
playing with collectors, requires guava 21.0
import com.google.common.collect.*;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static java.util.stream.Collectors.*;
public class Mapping {
@tomaszalusky
tomaszalusky / monksheets-show-textareas.js
Created March 29, 2018 19:26
Bookmarklet to show all work descriptions for current month
javascript:(function(){Array.from(document.getElementsByTagName("textarea")).forEach(function(el){el.parentNode.style.display='block';el.parentNode.style.position='relative';el.parentNode.parentNode.previousElementSibling.style.width='40px';});})();
import sun.misc.*;
public class Main {
public static void main(String[] args) {
Signal signal = new Signal("USR2");
System.out.println(signal);
}
}
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import org.joda.time.LocalDate;
public class Main {
static class Foo {
String name;