「Java」staticメソッドでprotected classを呼び出すサンプル
構文
protected static class クラス名{
// some code
}
public static Map<String, Boolean> 関数名{
// some code
}
Javaコード
package com.arkgame.java.study; import java.util.HashMap; import java.util.Map; public class MpBooleanDemo { protected static final String UPDATE_FLG = "update_auth"; protected static final String CREATE_FLG = "create_auth"; protected static final String DELETE_FLG = "delete_auth"; protected static class User { Map<String, Boolean> cftMp = new HashMap<String, Boolean>(); public Map<String, Boolean> getCftMp() { return cftMp; } public void setCftMp(Map<String, Boolean> cftMp) { this.cftMp = cftMp; } } public static void main(String[] args) { Map<String, Boolean> cft = new HashMap<String, Boolean>(); cft = testFunc(); for (String tt : cft.keySet()) { System.out.println("KEY: " + tt + " VALUE: " + cft.get(tt)); } } public static Map<String, Boolean> testFunc() { User user = new User(); user.getCftMp().put(UPDATE_FLG, true); user.getCftMp().put(CREATE_FLG, false); user.getCftMp().put(DELETE_FLG, true); return user.getCftMp(); } }
実行結果
KEY: delete_auth VALUE: true
KEY: update_auth VALUE: true
KEY: create_auth VALUE: false