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 loadOrder of rules to resolve
24: * conflict.
25: *
26: * @see #getInstance
27: * @see org.drools.rule.Rule#getLoadOrder
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: LoadOrderConflictResolver.java,v 1.1 2004/06/25 01:55:16
33: * mproctor Exp $
34: */
35: public class LoadOrderConflictResolver extends AbstractConflictResolver {
36: // ----------------------------------------------------------------------
37: // Class members
38: // ----------------------------------------------------------------------
39:
40: /**
41: *
42: */
43: private static final long serialVersionUID = 400L;
44: /** Singleton instance. */
45: private static final LoadOrderConflictResolver INSTANCE = new LoadOrderConflictResolver();
46:
47: // ----------------------------------------------------------------------
48: // Class methods
49: // ----------------------------------------------------------------------
50:
51: /**
52: * Retrieve the singleton instance.
53: *
54: * @return The singleton instance.
55: */
56: public static ConflictResolver getInstance() {
57: return LoadOrderConflictResolver.INSTANCE;
58: }
59:
60: // ----------------------------------------------------------------------
61: // Constructors
62: // ----------------------------------------------------------------------
63:
64: /**
65: * Construct.
66: */
67: public LoadOrderConflictResolver() {
68: // intentionally left blank
69: }
70:
71: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72:
73: /**
74: * @see ConflictResolver
75: */
76: public int compare(final Activation lhs, final Activation rhs) {
77: return (int) (lhs.getRule().getLoadOrder() - rhs.getRule()
78: .getLoadOrder());
79: }
80: }
|