View Javadoc
1   /*
2    * Copyright (C) 2007-2012 Argeo GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
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 org.argeo.slc.diff;
17  
18  import org.argeo.slc.SlcException;
19  
20  /** Diff issue where reached and expected values are different. */
21  public class DiffNotMatched extends DiffIssueKey {
22  
23  	// To enable hibernate persistance, these object cannot be final
24  	// private final Object expected;
25  	// private final Object reached;
26  
27  	private Object expected;
28  	private Object reached;
29  
30  	public DiffNotMatched(DiffPosition position, Object expected, Object reached) {
31  		super(position);
32  		this.expected = expected;
33  		this.reached = reached;
34  	}
35  
36  	public DiffNotMatched(DiffPosition position, Object expected,
37  			Object reached, DiffKey key) {
38  		super(position, key);
39  		this.expected = expected;
40  		this.reached = reached;
41  	}
42  
43  	public Object getExpected() {
44  		return expected;
45  	}
46  
47  	public Object getReached() {
48  		return reached;
49  	}
50  
51  	@Override
52  	public String toString() {
53  		String result = position + ": not matched " + expected + " <> "
54  				+ reached;
55  		if (super.key != null) {
56  			result = result + " - Key: " + super.toString();
57  		}
58  
59  		return result;
60  	}
61  
62  	@SuppressWarnings("unused")
63  	private String getExpectedStr() {
64  		if (expected instanceof String)
65  			return (String) expected;
66  		else
67  			throw new SlcException(
68  					"Object 'expected' is of wrong type. Must be a String");
69  	}
70  
71  	@SuppressWarnings("unused")
72  	private String getReachedStr() {
73  		if (reached instanceof String)
74  			return (String) reached;
75  		else
76  			throw new SlcException(
77  					"Object 'reached' is of wrong type. Must be a String");
78  	}
79  
80  	@SuppressWarnings("unused")
81  	private void setReachedStr(String reachedStr) {
82  		this.reached = reachedStr;
83  	}
84  
85  	@SuppressWarnings("unused")
86  	private void setExpectedStr(String expectedStr) {
87  		this.expected = expectedStr;
88  	}
89  
90  }