View Javadoc

1   package com.atlassian.marketplace.client.impl;
2   
3   import com.atlassian.marketplace.client.encoding.SchemaViolation;
4   
5   import com.google.common.base.Joiner;
6   import com.google.common.collect.ImmutableList;
7   
8   /**
9    * Used internally to wrap {@link SchemaViolation}s in an unchecked exception.
10   * 
11   * @since 2.0.0
12   */
13  @SuppressWarnings("serial")
14  public class SchemaViolationException extends RuntimeException
15  {
16      private final ImmutableList<SchemaViolation> schemaViolations;
17  
18      public SchemaViolationException(Iterable<SchemaViolation> schemaViolations)
19      {
20          this.schemaViolations = ImmutableList.copyOf(schemaViolations);
21      }
22      
23      public SchemaViolationException(SchemaViolation schemaViolation)
24      {
25          this(ImmutableList.of(schemaViolation));
26      }
27  
28      public Iterable<SchemaViolation> getSchemaViolations()
29      {
30          return schemaViolations;
31      }
32      
33      @Override
34      public String getMessage()
35      {
36          return Joiner.on(", ").join(schemaViolations);
37      }
38  }