still very new to Java, my apologies if this has appeared before.
Basically here is the original code
public static MarketType[] convert(final String[] values) {
return ofNullable(values).map(v -> Stream.of(values))
.orElse(Stream.empty())
.map(v -> getMarketType(v))
.toArray(MarketType[]::new);
}
Since other functions changed, I really need the return type to be List<MarketType>
instead of MarketType[]
, but is there any way that can achieve this with the minimal amount of modification for the original code?
I have been trying to put different things in the toArray
function but nothing really worked.
Any help appreciated!