This file contains hidden or 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 common; | |
| import java.util.HashMap; | |
| import java.util.function.Function; | |
| /** | |
| * How many times have you written code like this | |
| * <blockquote><pre> | |
| * List<Integer> value = map.get(key); | |
| * if(value == null) { |
This file contains hidden or 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 common; | |
| public class Format { | |
| private static final String[] BYTE_UNITS = new String[] { "b", "Kb", "Mb", "Gb" }; | |
| private static final int[] BYTE_STEPS = new int[] { 1024, 1024, 1024, 1024 }; | |
| private static final String[] TIME_UNITS = new String[] { "msec", "sec", "min", "h", "day", "week", "year" }; | |
| private static final int[] TIME_STEPS = new int[] { 1000, 60, 60, 24, 7, 52, 100 }; | |
| public static String format(String[] unit, int[] step, double value) { | |
| int i = 0; |
This file contains hidden or 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 common; | |
| import static java.util.Arrays.asList; | |
| import java.awt.Desktop.Action; | |
| import java.awt.Point; | |
| import java.lang.reflect.Array; | |
| import java.util.Arrays; | |
| import java.util.Collection; | |
| import java.util.Collections; |
This file contains hidden or 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 common; | |
| import java.util.Base64; | |
| import java.util.Random; | |
| public class Crypto { | |
| public static String base64encode(String text) { | |
| return Base64.getEncoder().encodeToString(text.getBytes()); | |
| } |
This file contains hidden or 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 common; | |
| import java.lang.reflect.InvocationHandler; | |
| import java.lang.reflect.InvocationTargetException; | |
| import java.lang.reflect.Method; | |
| import java.lang.reflect.Proxy; | |
| public class DuckType implements InvocationHandler { | |
| public static class Let { | |
| private Object object; |
This file contains hidden or 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 common; | |
| import java.io.File; | |
| import java.io.FilenameFilter; | |
| import java.net.MalformedURLException; | |
| import java.net.URL; | |
| import java.net.URLClassLoader; | |
| public class JarFileLoader extends URLClassLoader { |
This file contains hidden or 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 common; | |
| import java.sql.ResultSet; | |
| import java.sql.ResultSetMetaData; | |
| import java.sql.SQLException; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| public class JDBCDebug { | |
This file contains hidden or 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 common; | |
| import java.util.function.Consumer; | |
| import java.util.function.Function; | |
| public class Consumers { | |
| /** | |
| * <pre> |
This file contains hidden or 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 common; | |
| /** | |
| * <blockquote> | |
| * <pre> | |
| * Map<String, Integer> myMap = map("a", 1).with("b", 2); | |
| * </pre> | |
| * </blockquote> | |
| * | |
| * The first tuple determines the map type, so cast as appropriate: | |
| * <blockquote> |
This file contains hidden or 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.baloise.proxy; | |
| import static java.io.File.separator; | |
| import static java.lang.String.format; | |
| import static java.lang.System.getProperty; | |
| import static java.util.Arrays.asList; | |
| import static java.util.regex.Pattern.quote; | |
| import static java.util.stream.Collectors.joining; | |
| import java.io.File; | |
| import java.io.IOException; |
OlderNewer