All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lotaris.jee.validation.ApiError Maven / Gradle / Ivy

Go to download

This library offers components that facilitate validation of arbitrary objects and how they are serialized towards a client. It focuses on the wiring of the proposed patterns and does not contain any concrete validator implementations.

There is a newer version: 0.5.2
Show newest version
package com.lotaris.jee.validation;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;

/**
 * Detailed error message concerning a JSON document submitted by an API client.
 *
 * 

The location should be a JSON Pointer (see * http://tools.ietf.org/html/rfc6901) indicating which value of the JSON * document is invalid.

* *

The code identifies the error type (e.g. invalid string length). It can be * used to look up a translation.

* * @author Simon Oulevay ([email protected]) */ public class ApiError implements IError { private String message; @JsonIgnore private IErrorCode code; @JsonIgnore private IErrorLocationType locationType; private String location; // public ApiError(String message, IErrorCode code) { this.message = message; this.code = code; } public ApiError(String message, IErrorCode code, IErrorLocationType locationType, String location) { this.message = message; this.code = code; this.locationType = locationType; this.location = location; } // @JsonProperty("code") public Integer getNumericCode() { return code != null ? code.getCode() : null; } @JsonProperty("locationType") public String getLocationTypeAsString() { return locationType != null ? locationType.getLocationType(): null; } // @Override public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } @Override public IErrorCode getCode() { return code; } public void setCode(IErrorCode code) { this.code = code; } @Override public IErrorLocationType getLocationType() { return locationType; } public void setLocationType(IErrorLocationType locationType) { this.locationType = locationType; } @Override public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } // }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy