Peter Penzov
Peter Penzov

Reputation: 1754

Map enum elements

I have this Java enum structure:

public enum MOStatus {
    DRAFT, 
    ACTIVE,
    ARCHIVED
}

I would like to map the values with a list:

private static Predicate moStatusStatusIn(MOStatus... statuses) {
    List<String> status = Arrays.stream(statuses).map(MOStatus::values).collect(Collectors.toList());
}

But I get error Static method referenced through receiver for MOStatus::values

What is the proper way to map the values?

Upvotes: 0

Views: 106

Answers (1)

Robert Bain
Robert Bain

Reputation: 9596

Arrays.stream(statuses).map(Enum::name).collect(Collectors.toList())

Upvotes: 2

Related Questions