1 package org.oxerr.okcoin.rest.dto; 2 3 import java.util.Arrays; 4 5 /** 6 * Order status. 7 */ 8 public enum Status { 9 10 CANCELLED(-1), UNFILLED(0), PARTIALLY_FILLED(1), FULLY_FILLED(2), 11 CANCEL_REQUEST_IN_PROCESS(4); 12 13 public static Status of(int code) { 14 return Arrays 15 .stream(Status.values()) 16 .filter(status -> status.code == code) 17 .findFirst() 18 .get(); 19 } 20 21 private final int code; 22 23 Status(int code) { 24 this.code = code; 25 } 26 27 public int getCode() { 28 return code; 29 } 30 31 }