{"type":"rich","url":"https://int128.hatenablog.com/entry/2014/12/30/235746","height":"190","title":"Use trait with generics in Groovy","version":"1.0","author_name":"int128","categories":["groovy"],"width":"100%","provider_url":"https://hatena.blog","published":"2014-12-30 23:57:46","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fint128.hatenablog.com%2Fentry%2F2014%2F12%2F30%2F235746\" title=\"Use trait with generics in Groovy - GeekFactory\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_name":"Hatena Blog","description":"Groovy\u3067\u30b8\u30a7\u30cd\u30ea\u30af\u30b9\u4ed8\u304d\u306etrait\u3092\u4f7f\u3046\u5834\u5408\u306b\u3061\u3087\u3063\u3068\u30cf\u30de\u3063\u305f\u306e\u3067\u30e1\u30e2\u3092\u6b8b\u3057\u307e\u3059\u3002 \u524d\u63d0 Groovy 2.3.6 JDK 7u72 \u4f8b \u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002 @groovy.transform.Immutable class Person { final String name final int age } trait NamedMap<T> { boolean add(T item) { put(item.name, item) ? false : true } } def peoples = [:] as NamedMap<Person> assert peoples\u2026","image_url":null,"author_url":"https://blog.hatena.ne.jp/int128/","blog_url":"https://int128.hatenablog.com/","blog_title":"GeekFactory"}