Controllerのメソッド引数にOptional<ID<User>>のような Generic な独自型を指定したい。- 独自型の変換時に
Validationと連携したい。
- 独自型の変換時に
- Java8 の javac option
-parametersを使用して、Controllerメソッドの引数名からRequest Parameter名やPathParameter名を解決したい。- こちらは Java8 専用機能になるし、また Ninja の思想から若干外れている気もするので Ninja 本体に手を入れるよりは plugin なりで提供できればよいと考えている。
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
| scala> 5 & 6 | |
| res0: Int = 4 | |
| scala> 5 | 6 | |
| res1: Int = 7 | |
| scala> 10 & 13 | |
| res2: Int = 8 | |
| scala> 10 | 13 |
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
| scala> val list: Seq[PartialFunction[Int, String]] = Seq({case 1 => "a"}, {case 2 => "b"}, {case 3 => "c"}) | |
| list: Seq[PartialFunction[Int,String]] = List(<function1>, <function1>, <function1>) | |
| scala> list.reduceLeft(_ orElse _).apply(100) | |
| scala.MatchError: 100 (of class java.lang.Integer) | |
| at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:248) | |
| at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:246) | |
| at $anonfun$3.applyOrElse(<console>:7) | |
| at $anonfun$3.applyOrElse(<console>:7) | |
| at scala.runtime.AbstractPartialFunction$mcLI$sp.apply$mcLI$sp(AbstractPartialFunction.scala:33) |
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
| package skinny | |
| import org.joda.time.{ DateTime => JDateTime, LocalDate => JLocalDate, LocalTime => JLocalTime, _ } | |
| import skinny.util.DateTimeUtil | |
| /** | |
| * Strong parameter type definition. | |
| */ | |
| trait ParamType { |
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
| scala> Iterator.iterate(0)(_ + 1).take(10).addString(new StringBuilder, ",") | |
| res7: StringBuilder = 0,1,2,3,4,5,6,7,8,9 | |
| scala> Stream.iterate(0)(_ + 1).take(10).addString(new StringBuilder, ",") | |
| res8: StringBuilder = 0,? | |
| scala> Iterator.iterate(0)(_ + 1).take(10).toString | |
| res9: String = non-empty iterator | |
| scala> Stream.iterate(0)(_ + 1).take(10).toString |
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 java.util.stream.Collectors.toList; | |
| import java.util.stream.IntStream; | |
| public class FizzBuzz { | |
| public String chooseWord(final int i) { | |
| if (i % 15 == 0) return "FizzBuzz"; | |
| if (i % 3 == 0) return "Fizz"; | |
| if (i % 5 == 0) return "Buzz"; | |
| return String.valueOf(i); |
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
| [trace] Stack trace suppressed: run last root/*:publishSignedConfiguration for the full output. | |
| [trace] Stack trace suppressed: run last sample/*:publishSignedConfiguration for the full output. | |
| [error] (root/*:publishSignedConfiguration) Repository for publishing is not specified. | |
| [error] (sample/*:publishSignedConfiguration) Repository for publishing is not specified. | |
| [error] Total time: 13 s, completed 2014/06/04 20:34:58 | |
| > reload |
ApplicativeBuilder
(a |@| b |@| c |@| d apply f1)
|@| (e |@| f |@| g |@| h apply f2)
apply f3Haskell like Applicative Style
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
| val (u, g) = (User.syntax("u"), Group.syntax("g")) | |
| val groupId: Option[GroupId] = ... | |
| // getOrElse | |
| sql""" | |
| SELECT | |
| ${u.result.*} | |
| ${groupId.map(v => sqls", ${g.result.name}") getOrElse sqls""} | |
| FROM | |
| ${User as u} |
OlderNewer