01: package org.drools.conflict;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.drools.spi.Activation;
20: import org.drools.spi.ConflictResolver;
21:
22: /**
23: * <code>ConflictResolver</code> that uses the numConditions of rules to
24: * resolve conflict.
25: *
26: * @see #getInstance
27: * @see org.drools.rule.Rule#getConditionSize
28: *
29: * @author <a href="mailto:bob@werken.com">bob mcwhirter </a>
30: * @author <a href="mailto:simon@redhillconsulting.com.au">Simon Harris </a>
31: *
32: * @version $Id: SimplicityConflictResolver.java,v 1.9 2004/11/13 01:43:07 simon
33: * Exp $
34: */
35: public class SimplicityConflictResolver extends
36: AbstractConflictResolver {
37: // ----------------------------------------------------------------------
38: // Class members
39: // ----------------------------------------------------------------------
40:
41: /**
42: *
43: */
44: private static final long serialVersionUID = 400L;
45: /** Singleton instance. */
46: private static final SimplicityConflictResolver INSTANCE = new SimplicityConflictResolver();
47:
48: // ----------------------------------------------------------------------
49: // Class methods
50: // ----------------------------------------------------------------------
51:
52: /**
53: * Retrieve the singleton instance.
54: *
55: * @return The singleton instance.
56: */
57: public static ConflictResolver getInstance() {
58: return SimplicityConflictResolver.INSTANCE;
59: }
60:
61: // ----------------------------------------------------------------------
62: // Constructors
63: // ----------------------------------------------------------------------
64:
65: /**
66: * Construct.
67: */
68: public SimplicityConflictResolver() {
69: // intentionally left blank
70: }
71:
72: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
73:
74: /**
75: * @see ConflictResolver
76: */
77: public int compare(final Activation lhs, final Activation rhs) {
78: return lhs.getRule().getSpecifity()
79: - rhs.getRule().getSpecifity();
80: }
81: }
|