View Javadoc
1   /*
2    * Copyright 2018-2022 the original author or authors.
3    *
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    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
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  
17  package org.bremersee.exception.model;
18  
19  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
20  import com.fasterxml.jackson.annotation.JsonInclude;
21  import com.fasterxml.jackson.annotation.JsonInclude.Include;
22  import io.swagger.v3.oas.annotations.media.Schema;
23  import java.io.Serial;
24  import java.io.Serializable;
25  import lombok.Builder;
26  import lombok.EqualsAndHashCode;
27  import lombok.Getter;
28  import lombok.NoArgsConstructor;
29  import lombok.Setter;
30  import lombok.ToString;
31  
32  /**
33   * A stack trace element of an exception.
34   *
35   * @author Christian Bremer
36   */
37  @Schema(description = "A stack trace element of an exception.")
38  @JsonIgnoreProperties(ignoreUnknown = true)
39  @JsonInclude(Include.NON_EMPTY)
40  @EqualsAndHashCode
41  @ToString
42  @Getter
43  @Setter
44  @NoArgsConstructor
45  public class StackTraceItem implements Serializable {
46  
47    @Serial
48    private static final long serialVersionUID = 1L;
49  
50    /**
51     * The declaring class.
52     */
53    @Schema(description = "The declaring class.")
54    private String declaringClass;
55  
56    /**
57     * The method name.
58     */
59    @Schema(description = "The method name.")
60    private String methodName;
61  
62    /**
63     * The file name.
64     */
65    @Schema(description = "The file name.")
66    private String fileName;
67  
68    /**
69     * The line number.
70     */
71    @Schema(description = "The line number.")
72    private Integer lineNumber;
73  
74    /**
75     * Instantiates a new stack trace item.
76     *
77     * @param declaringClass the declaring class
78     * @param methodName the method name
79     * @param fileName the file name
80     * @param lineNumber the line number
81     */
82    @Builder(toBuilder = true)
83    protected StackTraceItem(
84        String declaringClass,
85        String methodName,
86        String fileName,
87        Integer lineNumber) {
88      this.declaringClass = declaringClass;
89      this.methodName = methodName;
90      this.fileName = fileName;
91      this.lineNumber = lineNumber;
92    }
93  
94  }