01: /*
02: * Copyright 2006-2007, Unitils.org
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 org.unitils.reflectionassert;
17:
18: import java.util.Map;
19: import java.util.Stack;
20:
21: /**
22: * todo javadoc
23: *
24: * @author Tim Ducheyne
25: * @author Filip Neven
26: */
27: public class IgnoreDefaultsComparator extends ReflectionComparator {
28:
29: // todo javadoc
30: public IgnoreDefaultsComparator(
31: ReflectionComparator chainedComparator) {
32: super (chainedComparator);
33: }
34:
35: // todo javadoc
36: public boolean canHandle(Object left, Object right) {
37: // object types
38: if (left == null) {
39: return true;
40: }
41:
42: // primitive types
43: return (left instanceof Boolean && !(Boolean) left)
44: || (left instanceof Character && (Character) left == 0)
45: || (left instanceof Number && ((Number) left)
46: .doubleValue() == 0);
47: }
48:
49: // todo javadoc
50: @Override
51: protected Difference doGetDifference(Object left, Object right,
52: Stack<String> fieldStack,
53: Map<TraversedInstancePair, Boolean> traversedInstancePairs) {
54: return null;
55: }
56: }
|