public static <T, T1> T1 first(Map<T, T1> map, JFuncTT<T, Boolean> func) { try { for (Map.Entry<T, T1> el : map.entrySet()) if (func.invoke(el.getKey())) return el.getValue(); } catch (Exception ignore) { } return null; }
public static <T, T1> Map<T, T1> where(Map<T, T1> map, JFuncTT<Map.Entry<T, T1>, Boolean> func) { try { Map<T, T1> result = new HashMap<>(); for (Map.Entry<T, T1> el : map.entrySet()) if (func.invoke(el)) result.put(el.getKey(), el.getValue()); return result; } catch (Exception ignore) { return new HashMap<>(); } }
public static <T, T1, T2> Map<T, T2> select(Map<T, T1> map, JFuncTT<T1, T2> func) { try { Map<T, T2> result = new HashMap<>(); for (Map.Entry<T, T1> el : map.entrySet()) result.put(el.getKey(), func.invoke(el.getValue())); return result; } catch (Exception ignore) { return new HashMap<>(); } }
public static <T, T1> T1 first(Map<T, T1> map) { for (Map.Entry<T, T1> el : map.entrySet()) return el.getValue(); return null; }