A bunch of functional functions
This commit is contained in:
parent
5b8bb1168f
commit
4e58a48b92
|
@ -6,3 +6,36 @@ def func_find_all(container_obj, attribute, filter_by)
|
|||
"return #{container_obj}.stream().filter(s -> #{filters.join "&&"}).collect(Collectors.toList());"
|
||||
|
||||
end
|
||||
|
||||
def find_whatever_of_something(container_obj, attribute, filter_by, aggregate_func)
|
||||
filters = filter_by.map do |x|
|
||||
"s.get#{attribute}() #{x.comparator} #{x.value}"
|
||||
end
|
||||
# TODO: Consider also having an "or" here
|
||||
"return #{container_obj}.stream().filter(s -> #{filters.join "&&"}).#{aggregate_func}();"
|
||||
end
|
||||
|
||||
def find_one(container_obj, attribute, filter_by)
|
||||
filters = filter_by.map do |x|
|
||||
"s.get#{attribute}() #{x.comparator} #{x.value}"
|
||||
end
|
||||
# TODO: Consider also having an "or" here
|
||||
"return #{container_obj}.stream().filter(s -> #{filters.join "&&"}).findAny().orElse(null);"
|
||||
end
|
||||
|
||||
def find_best_value(container_obj, attribute, filter_by, min_or_max, based_on)
|
||||
filters = filter_by.map do |x|
|
||||
"s.get#{attribute}() #{x.comparator} #{x.value}"
|
||||
end
|
||||
# TODO: Consider also having an "or" here
|
||||
"return #{container_obj}.stream().filter(s -> #{filters.join "&&"}).mapToInt(s -> s.get#{based_on}()).#{min_or_max};"
|
||||
end
|
||||
|
||||
def find_best_object(container_obj, attribute, filter_by, min_or_max, based_on)
|
||||
filters = filter_by.map do |x|
|
||||
"s.get#{attribute}() #{x.comparator} #{x.value}"
|
||||
end
|
||||
# TODO: Consider also having an "or" here
|
||||
"return #{container_obj}.stream().filter(s -> #{filters.join "&&"}).#{min_or_max}(Comparator.comparing(#{based_on.type}.get#{based_on.variable}()));"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user