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