abstract class ApiSubError { } @Data @EqualsAndHashCode(callSuper = false) @AllArgsConstructor class ApiValidationError extends ApiSubError { private String object; private String field; private Object rejectedValue; private String message; ApiValidationError(String object, String message) { this.object = object; this.message = message; } }
Loading
Mohamed Azarudeen ZPosted May 15, 2023, 10:53 AM
The code you provided defines an abstract class `ApiSubError` and a concrete class `ApiValidationError` that extends `ApiSubError`. The `ApiValidationError` class has several fields (`object`, `field`, `rejectedValue`, and `message`) along with corresponding getters and setters.
The `@Data` annotation is from the Lombok library and generates boilerplate code such as getters, setters, `equals()`, `hashCode()`, and `toString()` methods for the class.
The `@EqualsAndHashCode(callSuper = false)` annotation excludes the superclass (`ApiSubError`) from the generated `equals()` and `hashCode()` methods.
The `@AllArgsConstructor` annotation generates a constructor with parameters for all fields in the class.
Additionally, there is a constructor `ApiValidationError(String object, String message)` that initializes the `object` and `message` fields.
Overall, this code defines a class hierarchy for representing validation errors in an API, with `ApiValidationError` being a concrete subclass of `ApiSubError`.