Skip to content

Instantly share code, notes, and snippets.

View A-pZ's full-sized avatar

A-pZ A-pZ

  • Capybara(Oni-Tenjiku-nezumi)
  • Tokyo, shinagawa
View GitHub Profile
@Winged-Git
Winged-Git / BaseApplicationConfig.java
Created October 22, 2020 04:42
外部Jar化したコードの一部。
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@Configuration
public class BaseApplicationConfig implements WebMvcConfigurer {
@A-pZ
A-pZ / WebConfig.java
Created October 21, 2020 13:00
こうした上で、クエリ文字列に language=言語(JP)などを入れないと、クッキーに出力されない。
import javax.servlet.ServletContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
@nabbe
nabbe / Sandbox.java
Created March 20, 2016 16:09
Mapの要素をフィルターするのってめんどくさいよね
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import org.junit.Test;
// java.util.List の初期化を一行で書く
List<String> list = new ArrayList<String>() {{add("a"); add("b"); add("c");}};
// 変更不可能な List で良い場合は
List list = Arrays.asList("a", "b", "c");
// Arrays.asList をジェネリックスを使って書くと
List<Integer> list = Arrays.<Integer>asList(1, 2, 3);
// asList を使いつつ、追加可能な List を作るには、冗長だが以下のようにする
List<Integer> list = new ArrayList<Integer>(Arrays.<Integer>asList(1, 2, 3));