Skip to content

Instantly share code, notes, and snippets.

version: 2.1
jobs:
say-hello:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Say hello from external config.yml"
We couldn’t find that file to show.
int switchSample1(DayOfWeek dayOfWeek) {
return switch (dayOfWeek) {
case MONDAY, TUESDAY:
yield 1;
case WEDNESDAY, THURSDAY, FRIDAY:
yield 2;
case SATURDAY:
yield 3;
case SUNDAY:
yield 4;
@Test
void testInstanceof1() {
Object o = "";
if (o instanceof String s) {
assertTrue(s.isEmpty());
return;
}
fail("ここには来ないよ");
}
@Test
void testToList() {
List<String> list = Stream.of("a", "b").map(String::toUpperCase).toList();
assertEquals("[A, B]", list.toString());
}
record FullName(String firstName, String lastName) {}
@Test
void testRecords() {
var fullName = new FullName("Mitsuyuki", "Shiiba");
assertEquals("Mitsuyuki", fullName.firstName());
assertEquals("Shiiba", fullName.lastName());
assertEquals("FullName[firstName=Mitsuyuki, lastName=Shiiba]", fullName.toString());
}
@Test
void testTextBlocks1() {
String html1 = "<html>\n" +
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>\n";
String html2 = """
<html>
@Test
void testHelpfulNullPointerExceptions() {
NullPointerException npe = assertThrows(NullPointerException.class, () -> {
Object o = null;
o.toString();
});
assertEquals("Cannot invoke \"Object.toString()\" because \"o\" is null", npe.getMessage());
}
apiVersion: networking.gke.io/v1beta1
kind: ManagedCertificate
metadata:
name: helloweb-certificate
spec:
domains:
- gke.shiiba.dev
@bufferings
bufferings / Consumer.java
Last active May 29, 2019 21:09
http://d.hatena.ne.jp/taedium/20100314/p2 を読んで。自分だったらどうかくかなーと思って。こんな感じかな。のメモ。
Integer result = tx(new UnitWork<Integer>() {
@Override
public Integer run() {
Employee employee = dao.selectById(1);
employee.setName("hoge");
employee.setJobType(JobType.PRESIDENT);
return dao.update(employee);
}
});