I have the following enums, which can fill an ArrayList:
public enum RewardType {
POINTS, MONEY, TOKENS, RANDOM;
}
and
public enum OfferType {
GIFT, DISCOUNT, LOTTERY;
}
To convert the ArrayList to String I use this method:
public static String arrayListToString(ArrayList<Enum> arrayList) {
String finalString = "";
for (int i = 0; i < arrayList.size(); i++) {
if (TextUtils.isEmpty(finalString)) {
finalString = arrayList.get(i).name();
} else {
finalString = finalString + ", " + arrayList.get(i).name();
}
}
return finalString;
}
and then I call it like this:
String rewardType = arrayListToString(mainModel.getRewardTypes());
//getRewardTypes returns an ArrayList<RewardType>
The problem is, that arrayListToString is called with ArrayList<Enum> and cannot be called with ArrayList<enum> parameter (which is the type of my classes). I also cannot create a class with type Enum. Since enum != Enum, how do I make arrayListToString method work with my enum classes?