-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from footaku/exclude-enum-methods
Exclude enum methods
- Loading branch information
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.footaku; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum EnumClass { | ||
NONE(0), | ||
ONE(1), | ||
TWO(2); | ||
|
||
private final int id; | ||
|
||
EnumClass(int id) { | ||
this.id = id; | ||
} | ||
|
||
public int id() { | ||
return id; | ||
} | ||
|
||
@lombok.NonNull | ||
public static EnumClass from(int id) { | ||
return Arrays.stream(EnumClass.values()).filter(v -> v.id == id).findFirst().orElseThrow(); | ||
} | ||
} |