View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.model;
17  
18  /**
19   * Representing an integrity rule validation failure.
20   *
21   * @author Christian Bauer
22   */
23  public class ValidationError {
24      private Class clazz;
25      private String propertyName;
26      private String message;
27  
28      public ValidationError(Class clazz, String message) {
29          this.clazz = clazz;
30          this.message = message;
31      }
32  
33      public ValidationError(Class clazz, String propertyName, String message) {
34          this.clazz = clazz;
35          this.propertyName = propertyName;
36          this.message = message;
37      }
38  
39      public Class getClazz() {
40          return clazz;
41      }
42  
43      public String getPropertyName() {
44          return propertyName;
45      }
46  
47      public String getMessage() {
48          return message;
49      }
50  
51      @Override
52      public String toString() {
53          return getClass().getSimpleName()
54                  + " (Class: " + getClazz().getSimpleName()
55                  + ", propertyName: " + getPropertyName() + "): "
56                  + message;
57      }
58  }