ValueConversionException.java
01 /*
02  * Copyright 2008-2017 the original author or authors.
03  *
04  * Licensed under the Apache License, Version 2.0 (the "License");
05  * you may not use this file except in compliance with the License.
06  * You may obtain a copy of the License at
07  *
08  *     http://www.apache.org/licenses/LICENSE-2.0
09  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package griffon.core.editors;
17 
18 import javax.annotation.Nonnull;
19 import javax.annotation.Nullable;
20 
21 /**
22  @author Andres Almiray
23  @since 2.0.0
24  */
25 public class ValueConversionException extends IllegalArgumentException {
26     private static final long serialVersionUID = 6344566641106178891L;
27 
28     private final transient Object value;
29     private Class<?> type;
30 
31     public ValueConversionException(Object value) {
32         this(value, (Exceptionnull);
33     }
34 
35     public ValueConversionException(Object value, Class<?> type) {
36         this(value, type, null);
37     }
38 
39     public ValueConversionException(Object value, Class<?> type, Exception cause) {
40         super("Can't convert '" + value + "' into " + type.getName(), cause);
41         this.value = value;
42         this.type = type;
43     }
44 
45     public ValueConversionException(Object value, Exception cause) {
46         super("Can't convert '" + value + "'", cause);
47         this.value = value;
48     }
49 
50     @Nonnull
51     public Object getValue() {
52         return value;
53     }
54 
55     @Nullable
56     public Class<?> getType() {
57         return type;
58     }
59 }