def annoyed_maggie(container_obj, attribute, filter_by) filters = filter_by.map do |x| comparator = x.comparator == ".equals" ? ".equals(#{x.value})" : "#{x.comparator} #{x.value}" "s.get#{attribute}()#{comparator}" end "return #{container_obj}.stream().filter(s -> #{filters.join "&&"})" end def func_find_all(container_obj, attribute, filter_by) "#{annoyed_maggie(container_obj, attribute, filter_by)}.collect(Collectors.toList());" end def find_whatever_of_something(container_obj, attribute, filter_by, aggregate_func) "#{annoyed_maggie(container_obj, attribute, filter_by)}.#{aggregate_func}();" end def find_whatever_of_variable(container_obj, attribute, filter_by, aggregate_func, variable) "#{annoyed_maggie(container_obj, attribute, filter_by)}.mapToInt(s -> s.get#{variable}()).#{aggregate_func}();" end def find_one(container_obj, attribute, filter_by) "#{annoyed_maggie(container_obj, attribute, filter_by)}.findAny().orElse(null);" end def find_best_value(container_obj, attribute, filter_by, min_or_max, based_on) "#{annoyed_maggie(container_obj, attribute, filter_by)}.mapToInt(s -> s.get#{based_on}()).#{min_or_max};" end def find_best_object(container_obj, attribute, filter_by, min_or_max, based_on) "#{annoyed_maggie(container_obj, attribute, filter_by)}.#{min_or_max}(Comparator.comparing(#{based_on.type}.get#{based_on.variable}()));" end