FieldStrategy.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Copyright (c) 2011-2014, hubin (jobob@qq.com).
  3. * <p>
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. * <p>
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * <p>
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.baomidou.mybatisplus.enums;
  17. /**
  18. * <p>
  19. * 字段策略枚举类
  20. * </p>
  21. *
  22. * @author hubin
  23. * @Date 2016-09-09
  24. */
  25. public enum FieldStrategy {
  26. IGNORED(0, "忽略判断"),
  27. NOT_NULL(1, "非 NULL 判断"),
  28. NOT_EMPTY(2, "非空判断");
  29. /**
  30. * 主键
  31. */
  32. private final int key;
  33. /**
  34. * 描述
  35. */
  36. private final String desc;
  37. FieldStrategy(final int key, final String desc) {
  38. this.key = key;
  39. this.desc = desc;
  40. }
  41. public static FieldStrategy getFieldStrategy(int key) {
  42. FieldStrategy[] fss = FieldStrategy.values();
  43. for (FieldStrategy fs : fss) {
  44. if (fs.getKey() == key) {
  45. return fs;
  46. }
  47. }
  48. return FieldStrategy.NOT_NULL;
  49. }
  50. public int getKey() {
  51. return this.key;
  52. }
  53. public String getDesc() {
  54. return this.desc;
  55. }
  56. }