Пример #1
0
 private static void getAllReceiveMessages(Source input, List<ReceiveMessage> result) {
   if (input instanceof SimpleSource) {
     result.add(((SimpleSource) input).getMessage());
   } else if (input instanceof SourceComposition) {
     SourceComposition composition = (SourceComposition) input;
     for (Source s : composition.getSources()) {
       getAllReceiveMessages(s, result);
     }
   }
 }
Пример #2
0
 public static List<SimpleSource> allSimpleSources(Source input) {
   List<SimpleSource> result = new ArrayList<>();
   if (input instanceof SimpleSource) {
     result.add((SimpleSource) input);
   } else if (input instanceof SourceComposition) {
     SourceComposition composition = (SourceComposition) input;
     for (Source s : composition.getSources()) {
       result.addAll(allSimpleSources(s));
     }
   }
   return result;
 }