@Test public void findHighestPriorityTest() { String expected = "Aa"; Set<PrioritizedProperty> set = new TreeSet<>(Comparator.comparing(PrioritizedProperty::getProperty)); set.add(new PrioritizedProperty(PrioritizedPropertyNameEnum.COLLECTOR_NAME, 1, "Aa")); set.add(new PrioritizedProperty(PrioritizedPropertyNameEnum.COLLECTOR_NAME, 1, "Bb")); set.add(new PrioritizedProperty(PrioritizedPropertyNameEnum.COLLECTOR_NAME, 1, "Cc")); String result = PropertyPrioritizer.findHighestPriority(set); Assert.assertEquals(expected, result); }
protected static String findHighestPriority(Set<PrioritizedProperty> props) { return props.stream() .min( Comparator.comparing(PrioritizedProperty::getPriority) .thenComparing(PrioritizedProperty::getProperty)) .map(PrioritizedProperty::getProperty) .orElse(null); }
PropertyPrioritizer { protected static String findHighestPriority(Set<PrioritizedProperty> props) { return props.stream() .min( Comparator.comparing(PrioritizedProperty::getPriority) .thenComparing(PrioritizedProperty::getProperty)) .map(PrioritizedProperty::getProperty) .orElse(null); } }
PropertyPrioritizer { protected static String findHighestPriority(Set<PrioritizedProperty> props) { return props.stream() .min( Comparator.comparing(PrioritizedProperty::getPriority) .thenComparing(PrioritizedProperty::getProperty)) .map(PrioritizedProperty::getProperty) .orElse(null); }  }
PropertyPrioritizer { protected static String findHighestPriority(Set<PrioritizedProperty> props) { return props.stream() .min( Comparator.comparing(PrioritizedProperty::getPriority) .thenComparing(PrioritizedProperty::getProperty)) .map(PrioritizedProperty::getProperty) .orElse(null); }  abstract void resolvePriorities(); void addPrioritizedProperty(PrioritizedProperty prop); }
PropertyPrioritizer { protected static String findHighestPriority(Set<PrioritizedProperty> props) { return props.stream() .min( Comparator.comparing(PrioritizedProperty::getPriority) .thenComparing(PrioritizedProperty::getProperty)) .map(PrioritizedProperty::getProperty) .orElse(null); }  abstract void resolvePriorities(); void addPrioritizedProperty(PrioritizedProperty prop);  }