JAVA語義增強:Style

jopen 9年前發布 | 8K 次閱讀 Style Java開發

Style 給 Java 8 帶來其他語言高效的編程風格。

Style 通過精心挑選的方法/類名來模擬其他語言。

Style 致力于讓你的編碼更加美觀,進行更少的重復編碼,以及提升可讀性。

代碼示例:

// define a function to see if list contain a person with given name:
def<Boolean> check = $(
        (List<Person> ls, String name) -> null != $(list).forEach(e -> {
            if (e.name().equals(name))
                return true;
            return null;
        }));
check.apply(list, "cass");

// If expression with return value:
System.out.println(If(
    $(list).findOne(e -> e.name().equals("cass")),
        res -> {
            return res.id();
        }).Else(() -> "Not Found!"));

// forEach with iterator info
$(list).forEach((e, i) -> System.out.println(
        "Element is:" + e + " Index is:" + $(i)));

// dozens of new features waiting for you to explore.

項目主頁:http://www.baiduhome.net/lib/view/home/1440314626867

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!