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 orders rules on a First-In-First-Out
24: * basis.
25: *
26: * @see #getInstance
27: *
28: * @author <a href="mailto:simon@redhillconsulting.com.au">Simon Harris </a>
29: *
30: * @version $Id: RandomConflictResolver.java,v 1.1 2004/06/25 01:55:16 mproctor
31: * Exp $
32: */
33: public class FifoConflictResolver extends AbstractConflictResolver {
34: // ----------------------------------------------------------------------
35: // Class members
36: // ----------------------------------------------------------------------
37:
38: /**
39: *
40: */
41: private static final long serialVersionUID = 400L;
42: /** Singleton instance. */
43: private static final FifoConflictResolver INSTANCE = new FifoConflictResolver();
44:
45: // ----------------------------------------------------------------------
46: // Class methods
47: // ----------------------------------------------------------------------
48:
49: /**
50: * Retrieve the singleton instance.
51: *
52: * @return The singleton instance.
53: */
54: public static ConflictResolver getInstance() {
55: return FifoConflictResolver.INSTANCE;
56: }
57:
58: // ----------------------------------------------------------------------
59: // Constructors
60: // ----------------------------------------------------------------------
61:
62: /**
63: * Construct.
64: */
65: public FifoConflictResolver() {
66: // intentionally left blank
67: }
68:
69: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70:
71: /**
72: * @see ConflictResolver
73: */
74: public int compare(final Activation lhs, final Activation rhs) {
75: return (int) (lhs.getActivationNumber() - rhs
76: .getActivationNumber());
77: }
78: }
|