1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.metapath.impl;
7   
8   import dev.metaschema.core.metapath.IErrorCode;
9   import edu.umd.cs.findbugs.annotations.NonNull;
10  
11  public class ErrorCodeImpl implements IErrorCode {
12    /**
13     * The error prefix which identifies what kind of error it is.
14     */
15    @NonNull
16    private final String prefix;
17  
18    /**
19     * The error code.
20     */
21    private final int code;
22  
23    /**
24     * Construct a new error code.
25     *
26     * @param prefix
27     *          the error code prefix, which indicates what type of error it is
28     * @param code
29     *          the error code value, which indicates the specific error
30     */
31    public ErrorCodeImpl(@NonNull String prefix, int code) {
32      this.prefix = prefix;
33      this.code = code;
34    }
35  
36    /**
37     * Get the error code prefix, which indicates what type of error it is.
38     *
39     * @return the error code prefix
40     */
41    @Override
42    public String getPrefix() {
43      return prefix;
44    }
45  
46    /**
47     * Get the error code value.
48     *
49     * @return the error code value
50     */
51    @Override
52    public int getCode() {
53      return code;
54    }
55  
56    /**
57     * Get a combination of the error code family and value.
58     *
59     * @return the full error code.
60     */
61    @Override
62    public final String toString() {
63      return getCodeAsString();
64    }
65  }