View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2011-2025 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.qulice.spi;
6   
7   import lombok.EqualsAndHashCode;
8   import lombok.ToString;
9   
10  /**
11   * Validation result.
12   *
13   * @since 0.17
14   */
15  public interface Violation extends Comparable<Violation> {
16  
17      /**
18       * Name of the validator that generated this violation information.
19       * @return Name of the validator
20       */
21      String validator();
22  
23      /**
24       * Name of the failed check.
25       * @return Name of the failed check
26       */
27      String name();
28  
29      /**
30       * Validated file.
31       * @return Validated file.
32       */
33      String file();
34  
35      /**
36       * Lines with the problem.
37       * @return Lines with the problem
38       */
39      String lines();
40  
41      /**
42       * Validation message.
43       * @return Validation message.
44       */
45      String message();
46  
47      /**
48       * Default validation result.
49       *
50       * @since 0.1
51       */
52      @EqualsAndHashCode
53      @ToString
54      final class Default implements Violation {
55  
56          /**
57           * Name of the validator that generated this violation information.
58           */
59          private final String vldtr;
60  
61          /**
62           * Name of the failed check.
63           */
64          private final String name;
65  
66          /**
67           * Lines with the problem.
68           */
69          private final String lns;
70  
71          /**
72           * Validated file.
73           */
74          private final String file;
75  
76          /**
77           * Validation message.
78           */
79          private final String msg;
80  
81          /**
82           * Constructor.
83           * @param vldtr Name of the validator
84           * @param name Name of the failed check
85           * @param file Validated file
86           * @param lns Lines with the problem
87           * @param msg Validation message
88           * @checkstyle ParameterNumber (3 lines)
89           */
90          public Default(final String vldtr, final String name,
91              final String file, final String lns, final String msg) {
92              this.vldtr = vldtr;
93              this.name = name;
94              this.file = file;
95              this.lns = lns;
96              this.msg = msg;
97          }
98  
99          @Override
100         public String validator() {
101             return this.vldtr;
102         }
103 
104         @Override
105         public String name() {
106             return this.name;
107         }
108 
109         @Override
110         public String file() {
111             return this.file;
112         }
113 
114         @Override
115         public String lines() {
116             return this.lns;
117         }
118 
119         @Override
120         public String message() {
121             return this.msg;
122         }
123 
124         @Override
125         public int compareTo(final Violation other) {
126             return this.vldtr.compareToIgnoreCase(other.validator());
127         }
128     }
129 
130 }