- ドメインクラスのインスタンスを持ち回ると、セッション外等で面倒なことになる
- だからといってDTOへの変換をするのはだるい(無駄なクラス、バインディングの手間、等)
- 同一の項目定義で異なるテーブルに対応づける構成が直感的ではない(継承等で可能ではあるが)
- 複数パターンのバリデーションルールを使い分けられない(2.xでプラグインはあったが)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait TraitA { | |
def propA = "AAA" | |
private privatePropA = "aaa" | |
def doA() { | |
propA + privatePropA | |
} | |
} | |
trait TraitB extends TraitA { | |
def propB = "BBB" | |
def doB() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parent { | |
def hoge() { | |
aaa() | |
} | |
def foo() { | |
aaa() | |
} | |
static aaa() { | |
"PARENT" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def opt = Optional.of("HOGE") | |
assert opt.get() == "HOGE" | |
assert opt.isPresent() | |
assert opt.map { it * 2 }.get() == "HOGEHOGE" | |
assert opt.flatMap { Optional.of(it * 2) }.get() == 'HOGEHOGE' | |
assert opt.map { null } == Optional.empty() | |
// Optional.of(null) // => NPE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static groovy.test.GroovyAssert.* | |
def hoge(x) { | |
switch (x) { | |
case 1: return "A" | |
case 2: return "B" | |
default: throw new Exception("HOGE") | |
} | |
} | |
def foo(x) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grails.databinding.SimpleDataBinder | |
import groovy.util.logging.Slf4j | |
/** | |
* XML文字列のタグ名の{@code snake_case}と{@code camelCase}を変換してから、対象オブジェクトにデータバインディングします。 | |
*/ | |
@Slf4j | |
class CaseConvertingXmlDataBinder { | |
void bind(Object object, String snakeCasedXml) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Immutable { | |
void setProperty(String property, Object o) { | |
throw new UnsupportedOperationException("$property is immutable: $o") | |
} | |
} | |
class Hello { | |
String hello(String name) { "$message, $name!" } | |
String getMessage() { "Hello" } | |
String setHoge(Object o) { "Set!(Duumy)" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var groupId = document.getElementById('groupId').value; | |
var artifactId = document.getElementById('artifactId').value; | |
var name = document.getElementById('name').value; | |
var description = document.getElementById('description').value; | |
var packageName = document.getElementById('packageName').value; | |
var type = document.getElementById('type').value; | |
var packaging = document.getElementById('packaging').value; | |
var javaVersion = document.getElementById('javaVersion').value; | |
var language = document.getElementById('language').value; | |
var bootVersion = document.getElementById('bootVersion').value; |