package com.perforce.hws.util; import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; /** * Created by tristan on 4/5/16. */ public interface MapUtils { /** * Will set the value in the map if it's been set. * * @param map The map to update * @param key The key to use for the map * @param supplier The value generation * @param <T> Our type, typically string */ default <T> void putIfSet(Map<String, Object> map, String key, Supplier<T> supplier) { T value = supplier.get(); if (value != null) { map.put(key, value); } } default void putsIfSet(Map<String, String> map, String key, Supplier<String> supplier) { String value = supplier.get(); if (value != null) { map.put(key, value); } } /** * @param consumer * @param key * @param map * @param <T> */ default <T> void setIfExists(Consumer<T> consumer, String key, Map<String, Object> map) { if (map.containsKey(key)) { consumer.accept((T) map.get(key)); } } default void setsIfExists(Consumer<String> consumer, String key, Map<String, String> map) { if (map.containsKey(key)) { consumer.accept(map.get(key)); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19535 | drobins | Refactor package names to hws | ||
//guest/perforce_software/helix-web-services/main/source/jdk_extensions/src/main/java/com/perforce/helix_web_services/jdk_extensions/MapUtils.java | |||||
#1 | 18905 | tjuricek |
Add Git Fusion environent configuration and testing, and altered the implementation to use the newly defined API. Note: only runs on linux. We use latest GF production for testing and GF packages are linux only. The "integration" is pretty "light" at this point. This does require the test machine to have our package repository setup. |