Skip to content

Instantly share code, notes, and snippets.


Stefan Oehme oehme

View GitHub Profile
oehme / Stacktrace
Created Oct 7, 2016
IDEA hanging during sync
View Stacktrace
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.pickClosureMethod(
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(
at groovy.lang.MetaClassImpl.invokeMethod(
at org.gradle.api.specs.internal.ClosureSpec.isSatisfiedBy(
at org.gradle.api.internal.collections.CollectionFilter.filter(
at org.gradle.api.internal.collections.FilteredCollection$FilteringIterator.findNext(
at org.gradle.api.internal.collections.FilteredCollection$FilteringIterator.<init>(
at org.gradle.api.internal.collections.FilteredCollection.iterator(
oehme /
Created Jul 12, 2016
Why ignoring type safety warnings is bad
List<Foo> specialThings = Lists.newArrayList(); //Foo extends Base
Bean bean = new Bean();
// normally you would correctly get a compile error here,
//but the setter in your example does an unsafe cast that makes this line compile
List<Base> things = bean.getStuff();
things.add(new Bar()); // Bar extends Base
View build.groovy
plugins {
id 'java'
id 'com.github.oehme.sobula.bintray-release' version '0.4.1'
group = ""
description = "My really cool project"
contacts {
"" {
View set-variables.rb
require 'travis'
Travis.access_token = Travis.github_auth(ENV['TRAVIS_TOKEN'])
repos = Travis::Repository.find_all(owner_name: 'oehme')
keys = ['ORG_GRADLE_PROJECT_bintrayApiKey', 'ORG_GRADLE_PROJECT_signingPassword', 'ORG_GRADLE_PROJECT_sonatypePassword']
repos.each do |repo|
keys.each do |key|
puts "Setting env var '#{key}' on project '#{repo.slug}'"
repo.env_vars.upsert(key, "'#{ENV[key]}'", public: false)
View MyMessages.xtend
@Messages class MyMessages {}
class Test {
def static void main(String[] args) {
val messages = new MyMessages(Locale.GERMAN)
println(messages.hello("Stefan", new Date))
oehme / Helpers.xtend
Created Nov 28, 2014
Helper functions for the method name and parameter types
View Helpers.xtend
def keyToMethodName(String key) {, key).toFirstLower
def argumentType(Format format, extension TypeReferenceProvider typeRefs) {
switch format {
NumberFormat: Number.newTypeReference
DateFormat: Date.newTypeReference
default: object
oehme / MessageMethods.xtend
Created Nov 28, 2014
Generating Methods from Messagekeys
View MessageMethods.xtend
Iterators.forEnumeration(resourceBundle.keys).forEach [ key |
cls.addMethod(key.keyToMethodName) [
patternVariables.forEach [ patternVariable, index |
addParameter("arg" + index, patternVariable.argumentType(context))
returnType = string
body = '''
«String» pattern = bundle.getString("«key»");
«MessageFormat» format = new «MessageFormat»(pattern);
return format.format(new «Object»[]{«parameters.join(", ")[simpleName]»});
oehme / ReadingPropertiesInCompiler.xtend
Created Nov 28, 2014
Loading the ResourceBundle in the Compiler
View ReadingPropertiesInCompiler.xtend
val propertyFile = cls.compilationUnit.filePath.parent.append(cls.simpleName + ".properties")
if (!propertyFile.exists) {
cls.addError('''Property file «propertyFile» does not exist''')
val resourceBundle = new PropertyResourceBundle(propertyFile.contentsAsStream)
oehme /
Last active Aug 29, 2015
Localization ResourceBundle
public class MyMessages {
private ResourceBundle bundle;
public MyMessages(Locale locale) {
this.bundle = ResourceBundle.getBundle("MyMessages", locale);
public String trains(Number arg0) {
String pattern = bundle.getString("Trains");
MessageFormat format = new MessageFormat(pattern);
oehme /
Created Nov 28, 2014
Localization properties
Hello=Hello {0}, the time currently is {1, time}!
Trains={0,number} trains spotted.