add helper methods to ReturnCode

This commit is contained in:
Taner Sener 2021-02-16 16:33:28 +00:00
parent 06a736fda4
commit bdb9601069
3 changed files with 20 additions and 0 deletions

View File

@ -31,6 +31,14 @@ public class ReturnCode {
this.value = value; this.value = value;
} }
public static boolean isSuccess(final ReturnCode returnCode) {
return (returnCode != null && returnCode.getValue() == SUCCESS);
}
public static boolean isCancel(final ReturnCode returnCode) {
return (returnCode != null && returnCode.getValue() == CANCEL);
}
public int getValue() { public int getValue() {
return value; return value;
} }

View File

@ -31,6 +31,10 @@ typedef NS_ENUM(NSUInteger, ReturnCodeEnum) {
- (instancetype)init:(int)value; - (instancetype)init:(int)value;
+ (BOOL)isSuccess:(ReturnCode*)value;
+ (BOOL)isCancel:(ReturnCode*)value;
- (int)getValue; - (int)getValue;
- (BOOL)isSuccess; - (BOOL)isSuccess;

View File

@ -32,6 +32,14 @@
return self; return self;
} }
+ (BOOL)isSuccess:(ReturnCode*)value {
return (value != nil) && ([value getValue] == ReturnCodeSuccess);
}
+ (BOOL)isCancel:(ReturnCode*)value {
return (value != nil) && ([value getValue] == ReturnCodeCancel);
}
- (int)getValue { - (int)getValue {
return _value; return _value;
} }