Enum OperationResult

java.lang.Object
java.lang.Enum<OperationResult>
org.shoulder.log.operation.enums.OperationResult
All Implemented Interfaces:
Serializable, Comparable<OperationResult>, java.lang.constant.Constable

public enum OperationResult extends Enum<OperationResult>
业务操作结果: 成功或失败:1表示成功,0表示失败,2表示部分成功; 正确或不正确:1表示正确,0表示不正确;

操作结果在一个业务中哪怕输入相同结果也可能不确定,常用作函数参数,不在注解中出现,因此通过枚举类使用

Author:
lym
  • Enum Constant Details

    • SUCCESS

      public static final OperationResult SUCCESS
      成功 | 正确
    • FAIL

      public static final OperationResult FAIL
      失败 | 不正确
    • PARTIAL

      public static final OperationResult PARTIAL
      部分成功(适用于批量操作,如批量保存10条数据,5条成功,5条失败)
  • Field Details

    • code

      public final int code
  • Method Details

    • values

      public static OperationResult[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static OperationResult valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • of

      public static OperationResult of(boolean success)
    • of

      public static OperationResult of(boolean hasSuccess, boolean hasFail)
      如果 hasSuccess、hasFail 都为 false 则默认为操作成功
    • of

      public static OperationResult of(Collection<? extends OperateResult> results)
      如果操作结果为空默认为成功
    • getCode

      public int getCode()