/*
 * The MIT License
 *
 * Copyright (c) 2015 Misakura.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package jp.gr.java_conf.kgd.example.blog.crossgenerics;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.utils.Layout;

public class WidgetExample {

    public static <T extends Actor & Layout> void doSomething1(T widget) {
        // Actorのメソッド。Layoutでは使えない。
        widget.act(0);

        // Layoutのメソッド。Actorでは使えない。
        widget.getPrefWidth();
    }

    // ジェネリクス無しで実現する場合はこんな風になる。
    // （actorViewとlayoutViewに同じインスタンスを渡して呼び出す）
    public static void doSomething2(Actor actorView, Layout layoutView) {
        // 同じ処理
        actorView.act(0);
        layoutView.getPrefWidth();
    }

    public static void main(String[] args) {
        WidgetGroup widgetGroup = new WidgetGroup();

        // こんな風に呼べる
        doSomething1(widgetGroup);

        // 一応、ジェネリクスを使わなくてもこんな感じの呼び出しで実現できる
        doSomething2(widgetGroup, widgetGroup); // ←おかしすぎんよ～
    }
}

@@ -1275,27 +1275,21 @@
 ne2d.ui.
-WidgetGroup
+Table
 ;%0Aimport
@@ -1582,16 +1582,19 @@
 %0A    // 
+%E4%B8%80%E5%BF%9C%E3%80%81
 %E3%82%B8%E3%82%A7%E3%83%8D%E3%83%AA%E3%82%AF%E3%82%B9%E7%84%A1%E3%81%97
@@ -1742,16 +1742,196 @@
      // 
+%E9%81%95%E3%81%86%E3%82%A4%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%B3%E3%82%B9%E3%81%8C%E6%B8%A1%E3%81%9B%E3%81%A6%E3%81%97%E3%81%BE%E3%81%86%E3%81%AE%E3%81%A7%E3%80%81%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%81%99%E3%82%8B%0A        if (actorView != layoutView) %7B%0A            throw new IllegalArgumentException(%22actorView%E3%81%A8layoutView%E3%81%AF%E5%90%8C%E3%81%98%E3%82%A4%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%B3%E3%82%B9%E3%81%A7%E3%81%AA%E3%81%91%E3%82%8C%E3%81%B0%E3%81%84%E3%81%91%E3%81%BE%E3%81%9B%E3%82%93%22);%0A        %7D%0A%0A        // %E4%BB%A5%E4%B8%8B%E3%80%81
 %E5%90%8C%E3%81%98%E5%87%A6%E7%90%86%0A   
@@ -2047,16 +2047,19 @@
 %0A       
+ //
  WidgetG
@@ -2066,38 +2066,68 @@
 roup
- widgetGroup = new WidgetGroup
+%E3%81%AE%E6%B4%BE%E7%94%9F%E3%82%AF%E3%83%A9%E3%82%B9%E3%81%A7Scene2D%E3%81%AE%E3%82%A8%E3%83%BC%E3%82%B9Table%E3%81%95%E3%82%93%E3%81%A7%E3%81%99%EF%BC%81%0A        Table table = new Table
 ();%0A
@@ -2168,27 +2168,21 @@
 ething1(
-widgetGroup
+table
 );%0A%0A    
@@ -2246,32 +2246,20 @@
 ng2(
-widgetGroup, widgetGroup
+table, table
 ); /

change ジェネリクス使わないバージョンにインスタンスの比較を追加。