@Override public boolean cond(String name) { Object val = get(name); return val != null && !Boolean.FALSE.equals(val) && !"".equals(val) && (!Coll.isCollection(val) || !U.isEmpty((Collection<?>) val)) && (!Coll.isMap(val) || !U.isEmpty((Map<?, ?>) val)); }
@SuppressWarnings("unchecked") public static Set<String> getRolesFor(String username) { if (U.isEmpty(username)) { return U.set(); } Config user = Conf.USERS.sub(username); if (user.isEmpty()) { return U.set(); } Object roles = user.entry("roles").getOrNull(); if (Coll.isCollection(roles)) { Set<String> roleSet = U.set(); for (String role : (Collection<String>) roles) { roleSet.add(role.toLowerCase()); } return roleSet; } else if (roles instanceof String) { Set<String> roleSet = U.set(); for (String role : ((String) roles).toLowerCase().split("\\s*\\,\\s*")) { role = role.trim(); if (U.notEmpty(role)) { roleSet.add(role); } } return roleSet; } else { return Collections.emptySet(); } }
@SuppressWarnings("unchecked") public static Object copyOf(Object source, Mapper<Object, ?> transformation) { Err.argMust(source != null, "source cannot be null!"); if (Coll.isCollection(source)) { return copyOf((Collection<?>) source, transformation); } else if (Coll.isMap(source)) { return copyOf((Map<?, ?>) source, transformation); } else if (source instanceof Object[]) { // FIXME support primitive arrays return copyOf((Object[]) source, transformation); } else { try { return transformation != null ? transformation.map(source) : source; } catch (Exception e) { throw new RuntimeException("Transformation error!", e); } } }
@Override public boolean cond(String name) { Object val = get(name); return val != null && !Boolean.FALSE.equals(val) && !"".equals(val) && (!Coll.isCollection(val) || !U.isEmpty((Collection<?>) val)) && (!Coll.isMap(val) || !U.isEmpty((Map<?, ?>) val)); }