1 package com.atlassian.marketplace.client.encoding;
2
3 import static com.google.common.base.Preconditions.checkNotNull;
4
5 /**
6 * Base class for error descriptors that indicate that a response from the Marketplace server did
7 * not conform to the expected JSON schema, or that a model object constructed by the caller (to
8 * be sent to the server) was invalid.
9 * @since 2.0.0
10 */
11 public abstract class SchemaViolation
12 {
13 private final Class<?> schemaClass;
14
15 protected SchemaViolation(Class<?> schemaClass)
16 {
17 this.schemaClass = checkNotNull(schemaClass);
18 }
19
20 /**
21 * The class of the model object that was involved in the error.
22 */
23 public Class<?> getSchemaClass()
24 {
25 return schemaClass;
26 }
27
28 /**
29 * A human-readable string describing the error.
30 */
31 public abstract String getMessage();
32
33 @Override
34 public String toString()
35 {
36 return getMessage();
37 }
38 }