/** * Returns the error for the supplied integer constant. * * @param code to find error for * @return error */ public static Error valueOf(final int code) { for (Error e : Error.values()) { if (e.getCode() == code) { return e; } } return null; }
public static Error findByCode(int code) { for (Error e : Error.class.getEnumConstants()) { if (e.getCode() == code) { return e; } } throw new IllegalArgumentException("Unknown " + Error.class.getName() + " enum code:" + code); }
public Builder fromOperationErrorDetail(Error in) { return new Builder() .code(in.getCode()) .location(in.getLocation().orNull()) .message(in.getMessage().orNull()); }