Код: Выделить всё
public interface System {
public String getConfigKey();
}
Код: Выделить всё
public enum SystemA implements System {
ABC_CONFIG("ABC");
private SystemA(String configKey) {
this.configKey = configKey;
}
private String configKey;
public String getConfigKey() {
return configKey;
}
}
public enum SystemB implements System {
DEF_CONFIG("DEF");
private SystemB(String configKey) {
this.configKey = configKey;
}
private String configKey;
public String getConfigKey() {
return configKey;
}
}
Код: Выделить всё
Set configKeys = Stream.of(SystemA.values(),
SystemB.values()).forEach(config -> config.getConfigKey()).collect(toSet());
Поэтому я попробовал следующую модификацию: -
Код: Выделить всё
Set configKeys = Stream.of(SystemA.values(),
SystemB.values()).forEach(config -> config.getConfigKey()).collect(toSet());
Может кто-нибудь помочь, как я могу изменить часть forEach? Или как я могу использовать карту()/
Код: Выделить всё
flatmap()
Подробнее здесь: https://stackoverflow.com/questions/661 ... to-one-set