i've got google guava inside stream:
this.map.entryset().stream() .filter(entity -> !strings.isnullorempty(entity.getvalue())) .map(obj -> string.format("%s=%s", obj.getkey(), obj.getvalue())) .collect(collectors.joining(",")) as see there statement !string.isnullorempty(entity) inside filter function.
i don't want use guava anymore in project, want replace by:
string == null || string.length() == 0; how can more elegant?
you can write own predicate:
final predicate<map.entry<?, string>> valuenotnullorempty = e -> e.getvalue() != null && !e.getvalue().isempty(); then use valuenotnullorempty filter argument.
Comments
Post a Comment