0
How do I get the Enum object with an ID I passed as parameter check an Enum object element if true?
My builder:
private WeaponInterface(int[] weaponId, int speed,
FightType[] fightType) {
this.setWeaponIds(weaponId);
this.speed = speed;
this.fightType = fightType;
}
What I’m trying to do :
public static WeaponInterface forId(Item item){
return Arrays.asList(WeaponInterface.values()).stream().
filter(i -> i.getWeaponIds() == item.getId()).collect(n faço idéia);
}
@Diego suggest to edit your question because it is not clear what you want to check with streams and post attributes and modeling of Weaponinterface and Item.
– Daniela Morais
in view of the
.collect
try to use.findFirst().orElse(null)
for example– brow-joe
@Brow-joe I did this, but as you can see, the weaponIds is an array and the item id is a primary, I would have to have a way to Utlilize that you said by doing something in the filter
– Diogo
Cool, I think I know what you want to do
– brow-joe