import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response;
* @param defaultValue value to be returned if source is {@code null}
* @return a new list, containing mappings of all of the items in the original list
*/
- public static <T> List<T> mapList(List<T> source, Function<T, T> mapFunc, List<T> defaultValue) {
+ public static <T> List<T> mapList(List<T> source, UnaryOperator<T> mapFunc, List<T> defaultValue) {
if (source == null) {
return defaultValue;
}
* @return a new list, containing mappings of all of the items in the original list,
* or {@code null} if the source is {@code null}
*/
- public static <T> List<T> mapList(List<T> source, Function<T, T> mapFunc) {
+ public static <T> List<T> mapList(List<T> source, UnaryOperator<T> mapFunc) {
return mapList(source, mapFunc, null);
}
* @param defaultValue value to be returned if source is {@code null}
* @return a new map, containing mappings of all of the items in the original map
*/
- public static <T> Map<String, T> mapMap(Map<String, T> source, Function<T, T> mapFunc,
+ public static <T> Map<String, T> mapMap(Map<String, T> source, UnaryOperator<T> mapFunc,
Map<String, T> defaultValue) {
if (source == null) {
return defaultValue;
* @return a new map, containing mappings of all of the items in the original map,
* or {@code null} if the source is {@code null}
*/
- public static <T> Map<String, T> mapMap(Map<String, T> source, Function<T, T> mapFunc) {
+ public static <T> Map<String, T> mapMap(Map<String, T> source, UnaryOperator<T> mapFunc) {
return mapMap(source, mapFunc, null);
}
@Test
public void test() {
- assertEquals("VM", ControlLoopTargetType.VM);
- assertEquals("VF", ControlLoopTargetType.VF);
- assertEquals("VFC", ControlLoopTargetType.VFC);
- assertEquals("VNF", ControlLoopTargetType.VNF);
- assertEquals("PNF", ControlLoopTargetType.PNF);
+ assertEquals(ControlLoopTargetType.VM, "VM");
+ assertEquals(ControlLoopTargetType.VF, "VF");
+ assertEquals(ControlLoopTargetType.VFC, "VFC");
+ assertEquals(ControlLoopTargetType.VNF, "VNF");
+ assertEquals(ControlLoopTargetType.PNF, "PNF");
}
}