|
@@ -56,15 +56,14 @@ public final class MapUtils {
|
|
|
return new MMapProjection<>(map, function);
|
|
return new MMapProjection<>(map, function);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //@todo (assira #4) MapUtils #wrap - takie coś, co nam będzie mapowało na Wrapper
|
|
|
|
|
- // to znaczy w zasadzie to inaczej. Będzie brało klucz z mapy za pomocą get (zawsze)
|
|
|
|
|
- // a następnie na typ obiekcie zapuszczało funkcję GetAction albo SetAction
|
|
|
|
|
- //
|
|
|
|
|
- // podstawowa implementacja jest. napisać wszystkie overloads
|
|
|
|
|
public static <K, TV, RV> Map<K,RV> wrap(Map<K,TV> map, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
|
|
public static <K, TV, RV> Map<K,RV> wrap(Map<K,TV> map, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
|
|
|
return new MapWrapper<>(map, getter, setter);
|
|
return new MapWrapper<>(map, getter, setter);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static <K, TV, RV> MultiMap<K,RV> wrap(MultiMap<K,TV> map, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
|
|
|
|
|
+ return new MMapWrapper<>(map, getter, setter);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static class MMapAdapter<K, TV, RV> extends MapAdapter<K, TV, RV> implements MultiMap<K, RV> {
|
|
private static class MMapAdapter<K, TV, RV> extends MapAdapter<K, TV, RV> implements MultiMap<K, RV> {
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
private static final long serialVersionUID = 1L;
|
|
@@ -349,6 +348,24 @@ public final class MapUtils {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static class MMapWrapper<K, TV, RV> extends MapWrapper<K,TV,RV> implements MultiMap<K, RV> {
|
|
|
|
|
+
|
|
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
|
|
+
|
|
|
|
|
+ private final MultiMap<K, TV> mcontent;
|
|
|
|
|
+
|
|
|
|
|
+ public MMapWrapper(MultiMap<K, TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
|
|
|
|
|
+ super(content, getter, setter);
|
|
|
|
|
+ this.mcontent = content;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Collection<RV> getAll(Object key) {
|
|
|
|
|
+ return CollectionUtils.map(mcontent.getAll(key), getter);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static class MapWrapper<K, TV, RV> extends AMap<K, RV> implements Map<K, RV> {
|
|
private static class MapWrapper<K, TV, RV> extends AMap<K, RV> implements Map<K, RV> {
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
private static final long serialVersionUID = 1L;
|