2019-10-13 12:08:50 +00:00
|
|
|
def find_best(container_obj, based_on, compare, type)
|
|
|
|
"
|
|
|
|
#{type} result = null;
|
|
|
|
for (var pls : #{container_obj}) {
|
|
|
|
if (result == null || pls.get#{based_on}() #{compare} result.get#{based_on}()) {
|
|
|
|
result = pls;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2019-10-22 09:47:33 +00:00
|
|
|
def find_best_with_extra_parameter(container_obj, based_on, compare, type, extra_based_on, extra_compare, extra_param)
|
2019-10-13 12:08:50 +00:00
|
|
|
|
|
|
|
|
2019-10-22 09:47:33 +00:00
|
|
|
result_init = compare == '>' ? 'Integer.MIN_VALUE' : 'Integer.MAX_VALUE'
|
2019-10-17 11:44:22 +00:00
|
|
|
steffan = extra_compare == ".equals" ? ".equals(#{extra_param}" : " #{extra_compare} #{extra_param}"
|
2019-10-13 12:08:50 +00:00
|
|
|
|
2019-10-17 11:44:22 +00:00
|
|
|
"#{type} result = null;
|
|
|
|
\t\tint result_maggie = #{result_init};
|
|
|
|
\t\tfor (var pls : #{container_obj}) {
|
|
|
|
\t\t\tif (pls.get#{extra_based_on}()#{steffan}) && pls.get#{based_on}() #{compare} result_maggie) {
|
|
|
|
\t\t\t\tresult = pls;
|
|
|
|
\t\t\t\tresult_maggie = pls.get#{based_on}();
|
|
|
|
\t\t\t}
|
|
|
|
\t\t}
|
|
|
|
\t\treturn result;"
|
2019-10-13 12:08:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def find_all(container_obj, based_on, compare, type, parameter)
|
2019-10-17 11:44:22 +00:00
|
|
|
alex = compare=='.equals' ? ".equals(#{parameter})" : " #{compare} #{parameter}"
|
|
|
|
"ArrayList<#{type}> result = new ArrayList<>();
|
|
|
|
\t\tfor (var pls : #{container_obj}) {
|
|
|
|
\t\t\tif (pls.get#{based_on}()#{alex}) {
|
|
|
|
\t\t\t\tresult.add(pls);
|
|
|
|
\t\t\t}
|
|
|
|
\t\t}
|
|
|
|
\t\treturn result;"
|
2019-10-13 12:08:50 +00:00
|
|
|
end
|
|
|
|
|
2019-10-22 09:47:33 +00:00
|
|
|
def find_amount_of_variable_based_on(container_obj, based_on, compare, parameter, of_variable)
|
|
|
|
alex = compare=='.equals' ? ".equals(#{parameter})" : " #{compare} #{parameter}"
|
|
|
|
"int result = 0;
|
|
|
|
\t\tfor (var pls : #{container_obj}) {
|
|
|
|
\t\t\tif (pls.get#{based_on}()#{alex}) {
|
|
|
|
\t\t\t\tresult += pls.get#{of_variable}();
|
|
|
|
\t\t\t}
|
|
|
|
\t\t}
|
|
|
|
\t\treturn result;"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-13 12:08:50 +00:00
|
|
|
def add_method(container_name, name)
|
2019-10-17 11:44:22 +00:00
|
|
|
"#{container_name}.add(#{name});"
|
2019-10-13 12:08:50 +00:00
|
|
|
end
|
|
|
|
|