Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ErrorLevel.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. package com.dmdirc.logger;
  18. /** Specific error levels allowed by Logger. */
  19. public enum ErrorLevel {
  20. /** Fatal error. */
  21. FATAL("Fatal", "error"),
  22. /** High priority error. */
  23. HIGH("High", "error"),
  24. /** Medium priority error. */
  25. MEDIUM("Medium", "warning"),
  26. /** Low priority error. */
  27. LOW("Low", "info"),
  28. /** Unknown priority error. */
  29. UNKNOWN("Unknown", "info");
  30. /** Error level string. */
  31. private final String value;
  32. /** Error level icon. */
  33. private final String icon;
  34. /**
  35. * Instantiates the enum.
  36. *
  37. * @param value toString value
  38. * @param icon Error level icon
  39. */
  40. ErrorLevel(final String value, final String icon) {
  41. this.value = value;
  42. this.icon = icon;
  43. }
  44. @Override
  45. public String toString() {
  46. return value;
  47. }
  48. /**
  49. * Error levels icon.
  50. *
  51. * @return Error levels icon
  52. */
  53. public String getIcon() {
  54. return icon;
  55. }
  56. /**
  57. * Returns the more important error
  58. *
  59. * @param level1 Error level to compare
  60. * @param level2 Error level to compare
  61. *
  62. * @return true iff the error is more important
  63. */
  64. public static ErrorLevel getMoreImportant(final ErrorLevel level1, final ErrorLevel level2) {
  65. if (level1.ordinal() > level2.ordinal()) {
  66. return level2;
  67. } else {
  68. return level1;
  69. }
  70. }
  71. }