- をオーバーライドして実装し
equals
ます。hashcode
OccupancyType
- のキーセットをループして
roomPrice
、フィルターに含まれる要素を収集します。
このようなもの:
Map<OccupancyType, BigDecimal> filteredPrices = new HashMap<OccupancyType, BigDecimal>();
for(OccupancyType key : roomPrice.keySet()) {
if(policy.contains(key) {
filteredPrices.put(key, roomPrice.get(key));
}
}
アップデート
Google Guavaを少し読んだ後、次のようなことができるはずです。
Predicate<OccupancyType> priceFilter = new Predicate<OccupancyType>() {
public boolean apply(OccupancyType i) {
return policy.contains(i);
}
};
その後
return Maps.filterValues(roomPrice, priceFlter);
トリックを行う必要があります。