Skip to content

Instantly share code, notes, and snippets.

View odrotbohm's full-sized avatar
👨‍💻
@ home

Oliver Drotbohm odrotbohm

👨‍💻
@ home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am odrotbohm on github.
  • I am odrotbohm (https://keybase.io/odrotbohm) on keybase.
  • I have a public key ASBAoaL1ovuekChAwlljeBmx1owaUCg5zwckYgcSGiGeAQo

To claim this, I am signing this object:

@Component
public class MockPostProcessor implements BeanPostProcessor {
/*
* (non-Javadoc)
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
public class Sample {
public static void main(String[] args) {
Foo<? extends Bar<?>> foo = new Foo<>();
// Compiles
Iterable<?> first = foo.someMethod();
DedicatedWrapper<? extends Bar<?>> dedicatedWrapper = foo.someOtherMethod();
@odrotbohm
odrotbohm / using-annotation-based-null-checks-in-eclipse.adoc
Last active June 27, 2017 12:28
Using annotation based null checks in Eclipse

Using annotation based null checks in Eclipse

Found issues

Calls to remote API not using nullability annotations cause warnings

Assume you call some external API (e.g. JDK API) that doesn’t use the nullability annotations:

@odrotbohm
odrotbohm / LambdaTypeDetectionSample.java
Last active January 28, 2023 09:54
Lambda type detection sample
public class LambdaTypeDetectionSample {
public static void main(String[] args) {
Function<Integer, String> lambdaFunction = i -> i.toString();
Function<Integer, String> oldschoolFunction = new Function<Integer, String>() {
public String apply(Integer t) {
return t.toString();
}
@odrotbohm
odrotbohm / extended-screenshot.png
Last active December 16, 2016 19:04
Auditorium screenshot
extended-screenshot.png
@odrotbohm
odrotbohm / MyBenchmark.java
Last active November 28, 2016 12:38
Benchmark showing differences between formatting JDK 8 dates and legacy Date instances
package org.sample;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.TimeZone;
import org.openjdk.jmh.annotations.Benchmark;
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@odrotbohm
odrotbohm / AmbiguitySample.java
Created November 15, 2016 15:50
Compiler ambiguity when compiling with target JDK 8
public class AmbiguitySample {
/**
* This compiles when using a JDK 8 with target JDK 6 but fails when the target is JDK 8.
*/
public static void main(String[] args) {
CriteriaBuilder builder;
Expression<Object> objectExpression;
Expression<Collection<Object>> collectionOfObjectExpression;
@RequiredArgsConstructor
public class ViewModel {
private final @NonNull YourService service;
public boolean yourDescriptiveMethod() {
return service.someMethod()
}
// … more methods