Guest User

Untitled

a guest
Jan 23rd, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. public enum ORFMatch
  2. {
  3.    PERMIT(0),
  4.    DENY(1);
  5.    private int code;
  6.  
  7.    ORFMatch(int code)
  8.    {
  9.       this.code = code;
  10.    }
  11.  
  12.    public int getCode()
  13.    {
  14.       return code;
  15.    }
  16.  
  17.    public static ORFMatch fromCode(int code)
  18.    {
  19.       return Arrays.stream(ORFMatch.values())
  20.             .filter(orfMatch -> orfMatch.getCode() == code)
  21.             .findFirst()
  22.             .orElseThrow(() -> new IllegalArgumentException("unknown ORF action code: " + code));
  23.    }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment