mardi 26 avril 2016

Multiple ifs in a stream using filters

How can we represent the following using streams and filters. Thanks.

for (UIDisplayItem uiDisplayItem : uiDisplayItems) {
    if ("8929".equals(uiDisplayItem.getProductSpecCharacteristicID())) {
        type1 = uiDisplayItem.getValue();
    }
    if ("5121".equals(uiDisplayItem.getProductSpecCharacteristicID())) {
        type2 = uiDisplayItem.getValue();
    }
    if ("4981".equals(uiDisplayItem.getProductSpecCharacteristicID())) {
        type3 = uiDisplayItem.getValue();
    }
    if ("501".equals(uiDisplayItem.getProductSpecCharacteristicID())) {
        type4 = uiDisplayItem.getValue();
    }
}

Aucun commentaire:

Enregistrer un commentaire