Skip to content

Instantly share code, notes, and snippets.

@ctranxuan
ctranxuan / Java-HowTos.md
Created May 19, 2017 13:59
Some Java HowTos

Enum reverse lookup pattern

import com.google.common.collect.ImmutableMap;

import java.io.File;
import java.util.Map;

import static com.google.common.base.Preconditions.checkNotNull;
@ctranxuan
ctranxuan / Configurations.md
Last active November 21, 2017 23:32
SpringBoot things

How to load @ConfigurationProperties manually from a Yaml configuration file

Let's say we have the following yaml configuration file:

foo:
    apis:
      -
        name: Happy Api
 path: /happyApi.json?v=bar
@ctranxuan
ctranxuan / gist:8afc010b3327fac73655
Last active August 29, 2015 14:17
Some reminders
// Spring RestController: how to deal with exception and http status
@ResponseStatus(HttpStatus.NOT_FOUND)
class UserNotFoundException extends RuntimeException {
public UserNotFoundException(String userId) {
super("could not find user '" + userId + "'.");
}
}