#print out the internal field name where the methode was returned too

1 messages · Page 1 of 1 (latest)

fossil bridge
#
    public static List<Species> jannaPokemonList(Predicate<Species> lambdacondition) {
        List<Species> all = getAll();
        all.removeIf(lambdacondition);

//TODO print the field?     
   System.out.println("§c["+all.size()+"]\n§f");
        all.stream().sorted(Comparator.comparingInt(Species::getDex)).forEach(a->System.out.println(a.getDex()+": "+ a.getName()));
        return all;
    }

basically i have this bad boy, and when i run the code i get nice long lists of data, the problem is. i dunno which list is what. so i want to somehow get the field name, so i know which list it is.

how would i able to do this?

haughty sailBOT
#

This post has been reserved for your question.

Hey @fossil bridge! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

stone ravine
#
    public static List<Species> jannaPokemonList(Predicate<Species> lambdacondition) {
        List<Species> all = getAll().removeIf(lambdacondition);

u can write it like this instead

also, it shouldnt be called 'lamdacondition' the name describes nothing

ignoreCondition?

#
    all.stream()
        .sorted(Comparator.comparingInt(Species::getDex))
        .forEach(a->System.out.println(a.getDex()+": "+ a.getName()));
    return all;
  }

u shouldnt write funcional pipelines in a single line
put each expression on its own line

#

and u should look at overriding the toString method on the Species class to be a.getDex()+": "+ a.getName()
that way u can write:

    all.stream()
        .sorted(Comparator.comparingInt(Species::getDex))
        .forEach(System::println);
    return all;
  }
#

and u should make Species implement Comparable so that u can change it to:

    all.stream()
        .sorted()
        .forEach(System::println);
    return all;
  }
#

as for knowing which field it is ....... i'm not even sure what ur asking
if u want to be able to identify each list seperately
then register each query and assign it an ID and print the ID out tooo