-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial take at QRest-specific result codes
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
modules/qrest/src/main/java/org/jpos/qrest/ResultCode.java
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,64 @@ | ||
package org.jpos.qrest; | ||
|
||
import org.jpos.rc.IRC; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* QRest-specific internal result codes | ||
*/ | ||
public enum ResultCode implements IRC { | ||
OK (0, true), | ||
SYSTEM_ERROR (19000,false,true), | ||
MANDATORY_PARAM_NOT_PRESENT (19101), | ||
MANDATORY_JSON_NOT_PRESENT (19102), | ||
INVALID_PARAM (19103), | ||
INVALID_OPTIONAL_PARAM (19104), | ||
INVALID_MANDATORY_JSON (19105), | ||
INVALID_OPTIONAL_JSON (19106); | ||
|
||
int irc; | ||
boolean success; | ||
boolean inhibit; | ||
private static Map<Integer,IRC> lookup = new HashMap<>(); | ||
static { | ||
for (IRC irc : values()) | ||
lookup.put(irc.irc(), irc); | ||
} | ||
|
||
ResultCode(int irc) { | ||
this.irc = irc; | ||
this.success = false; | ||
this.inhibit = false; | ||
} | ||
ResultCode(int irc, boolean success) { | ||
this.irc = irc; | ||
this.success = success; | ||
this.inhibit = false; | ||
} | ||
|
||
ResultCode(int irc, boolean success, boolean inhibit) { | ||
this.irc = irc; | ||
this.success = success; | ||
this.inhibit = inhibit; | ||
} | ||
|
||
@Override | ||
public int irc() { | ||
return irc; | ||
} | ||
|
||
@Override | ||
public boolean success() { | ||
return success; | ||
} | ||
|
||
@Override | ||
public boolean inhibit() { return inhibit; } | ||
|
||
public static IRC valueOf(int i) { | ||
return lookup.get(i); | ||
} | ||
} | ||
|