MySQLを使用して、私が開発しているゲームのアカウントのロードを行いたいのですが、
Java
1account.rank = Rank.valueOf(resultLoadAccount.getString("rank")); 2account.prefix = resultLoadAccount.getString("prefix"); 3account.firstLogin = resultLoadAccount.getLong("firstLogin"); 4account.karma = resultLoadAccount.getLong("karma"); 5account.networkExp = resultLoadAccount.getLong("networkExp"); 6account.channel = Channel.valueOf(resultLoadAccount.getString("channel")); 7 8if (resultLoadAccount.getString("ignores") == null || resultLoadAccount.getString("ignores").split(",").length == 1) { 9 account.ignores = new ArrayList<>(); 10} else { 11 account.ignores = Arrays.stream(resultLoadAccount.getString("ignores").split(",")).map(UUID::fromString).collect(Collectors.toList()); 12} 13 14account.allowFriendRequests = resultLoadAccount.getBoolean("allowFriendRequests"); 15account.playerVisibility = resultLoadAccount.getBoolean("playerVisibility"); 16account.privateMessagePrivacy = Privacy.valueOf(resultLoadAccount.getString("privateMessagePrivacy")); 17account.duelInvitePrivacy = Privacy.valueOf(resultLoadAccount.getString("duelInvitePrivacy")); 18account.friendRequestPrivacy = Privacy.valueOf(resultLoadAccount.getString("friendRequestPrivacy")); 19account.partyInvitePrivacy = Privacy.valueOf(resultLoadAccount.getString("partyInvitePrivacy"));
上記のように行うことでロードは可能です。しかし、こちらの方法ですと、いちいちgetStringのような形で読み出すことしかできず、新しい値を追加するときにも非常に不便です。
そこで、GoogleのJson Paser/LoaderであるGsonのように、自動でパースしてくれるライブラリがほしいのですが、なにか解決方法はありませんでしょうか?
ぜひよろしくお願い申し上げます。
回答1件
あなたの回答
tips
プレビュー