1

i have a collection i created of type Service

   Collection<Service> collection = serviceMap.values();

My data that is returned by the collection is of type param.

    Service first = collection.iterator().next();
    Set<Param> firstInputParam = first.getInputParamSet();
    Set<Param> firstOutputParam = first.getOutputParamSet();

An example of the outputs of firstInputParam and firstOutputParam:

    first.getInputParamSet: [J]
    first.getOutputParamSet: [C]

My goal and my issue is that i need to find a way to compare if the following outputParam is in the set of second.getInputParamSet.

For example i.getInputParamSet contains:

     Input ParamSet: [E, C]

ive tried the following

      if (i.getInputParamSet().equals(first.getOutputParamSet())){

&

      if (i.getInputParamSet().contains(first.getOutputParamSet())){

but neither of these two methods have worked can anyone assist me. Thank you!

KSM
  • 262
  • 2
  • 5
  • 16

1 Answers1

2

Make sure you have overridden hashCode and equals correctly in your Param class and use containsAll:

if (i.getInputParamSet().containsAll(first.getOutputParamSet()))
Community
  • 1
  • 1
Matt Eckert
  • 1,866
  • 14
  • 15