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 class that calculates the optimal thread pool boundaries. It takes the desired target utilization and the desired | |
* work queue memory consumption as input and retuns thread count and work queue capacity. | |
* | |
* @author Niklas Schlimm | |
* | |
*/ | |
public abstract class PoolSizeCalculator { | |
/** |
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 class ThreadLocalUtil { | |
private final static ThreadLocal<ThreadVariables> THREAD_VARIABLES = new ThreadLocal<ThreadVariables>() { | |
/** | |
* @see java.lang.ThreadLocal#initialValue() | |
*/ | |
@Override | |
protected ThreadVariables initialValue() { | |
return new ThreadVariables(); |
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 class SomePojo<T> { | |
private String someProperty; | |
private String anotherProperty; | |
private SomePojo(Builder<T> builder) { | |
this.someProperty = builder.someProperty; | |
this.anotherProperty = builder.anotherProperty; | |
} | |
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
// shopping basket with state pattern | |
public static class ShoppingBasket { | |
private String orderNo; | |
private List<String> articleNumbers = new ArrayList<>(); | |
private UpdateState state = UpdateState.UPDATEABLE; | |
public void add(String articleNumber) { | |
articleNumbers.add(state.set(articleNumber)); | |
} | |
public String getOrderNo() { | |
return orderNo; |
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 enum UpdateState { | |
UPDATEABLE(()->Validate.validState(true)), READONLY(()->Validate.validState(false)); | |
private Runnable action; | |
private UpdateState(Runnable action) { | |
this.action=action; | |
} | |
public <T> T set(T value) { | |
action.run(); | |
return value; | |
} |
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 static class ShoppingBasket1 { | |
private String orderNo; | |
private List<String> articleNumbers = new ArrayList<>(); | |
public void add(String articleNumber) { | |
articleNumbers.add(articleNumber); | |
} | |
public String getOrderNo() { | |
return orderNo; | |
} | |
public void setOrderNo(String orderNo) { |
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
Predicates predicates = new Predicates("SSH"); | |
System.getenv().keySet().stream().filter(predicates::containsPattern).collect(Collectors.toSet()); |
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 static class Predicates { | |
private String pattern; | |
public boolean containsPattern(String string) { | |
return string.contains(pattern); | |
} | |
public Predicates(String pattern) { | |
this.pattern = pattern; | |
} | |
} |
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<!-- WARNING: Eclipse auto-generated file. | |
Any modifications will be overwritten. | |
To include a user specific buildfile here, simply create one in the same | |
directory with the processing instruction <?eclipse.ant.import?> | |
as the first entry and export the buildfile again. --> | |
<project basedir="." default="runtests" name="testng_tests"> | |
<property environment="env" /> | |
<property name="M2_REPO" value="C:/Users/nschlimm/.m2/repository" /> | |
<property name="ECLIPSE_HOME" value="../../../../eclipse-3.6" /> |
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
protected class ConcurrentTransformer { | |
private final Lock lock = new ReentrantLock(); | |
private URL url = null; | |
private volatile Templates template = null; | |
private long lastCompileTime = Long.MAX_VALUE; | |
protected Templates generateTemplate(long ladezeitProzessApp) throws TransformerFactoryConfigurationError, TransformerConfigurationException, InterruptedException { | |
if (!mustCompile(loadTimeApplication)) { | |
return template; |
NewerOlder