01: //////////////////////////////////////////////////////////////////////////////
02: // Clirr: compares two versions of a java library for binary compatibility
03: // Copyright (C) 2003 - 2005 Lars Kühne
04: //
05: // This library is free software; you can redistribute it and/or
06: // modify it under the terms of the GNU Lesser General Public
07: // License as published by the Free Software Foundation; either
08: // version 2.1 of the License, or (at your option) any later version.
09: //
10: // This library is distributed in the hope that it will be useful,
11: // but WITHOUT ANY WARRANTY; without even the implied warranty of
12: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: // Lesser General Public License for more details.
14: //
15: // You should have received a copy of the GNU Lesser General Public
16: // License along with this library; if not, write to the Free Software
17: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: //////////////////////////////////////////////////////////////////////////////
19:
20: package net.sf.clirr.core.internal.checks;
21:
22: import net.sf.clirr.core.Severity;
23: import net.sf.clirr.core.Message;
24: import net.sf.clirr.core.internal.AbstractDiffReporter;
25: import net.sf.clirr.core.internal.ApiDiffDispatcher;
26: import net.sf.clirr.core.internal.ClassChangeCheck;
27: import net.sf.clirr.core.spi.JavaType;
28:
29: /**
30: * Detects gender changes (a class became an interface or vice versa).
31: *
32: * @author lkuehne
33: */
34: public final class GenderChangeCheck extends AbstractDiffReporter
35: implements ClassChangeCheck {
36: private static final Message MSG_GENDER_CLASS_TO_INTERFACE = new Message(
37: 2000);
38: private static final Message MSG_GENDER_INTERFACE_TO_CLASS = new Message(
39: 2001);
40:
41: /**
42: * Create a new instance of this check.
43: * @param dispatcher the diff dispatcher that distributes the detected changes to the listeners.
44: */
45: public GenderChangeCheck(ApiDiffDispatcher dispatcher) {
46: super (dispatcher);
47: }
48:
49: /** {@inheritDoc} */
50: public boolean check(JavaType baseLine, JavaType current) {
51: if (!baseLine.isInterface() && current.isInterface()) {
52: log(MSG_GENDER_CLASS_TO_INTERFACE, getSeverity(baseLine,
53: Severity.ERROR), baseLine.getName(), null, null,
54: null);
55: } else if (baseLine.isInterface() && !current.isInterface()) {
56: log(MSG_GENDER_INTERFACE_TO_CLASS, getSeverity(baseLine,
57: Severity.ERROR), baseLine.getName(), null, null,
58: null);
59: }
60:
61: return true;
62: }
63: }
|