001: package org.drools.common;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.io.Serializable;
020:
021: import org.drools.RuleBaseConfiguration;
022: import org.drools.reteoo.BetaMemory;
023: import org.drools.reteoo.FactHandleMemory;
024: import org.drools.reteoo.ReteTuple;
025: import org.drools.util.FactHashTable;
026: import org.drools.util.FactList;
027: import org.drools.util.LinkedList;
028: import org.drools.util.TupleHashTable;
029:
030: public class EmptyBetaConstraints implements Serializable,
031: BetaConstraints {
032:
033: private static final BetaConstraints INSTANCE = new EmptyBetaConstraints();
034:
035: public static BetaConstraints getInstance() {
036: return EmptyBetaConstraints.INSTANCE;
037: }
038:
039: /**
040: *
041: */
042: private static final long serialVersionUID = 400L;
043:
044: private EmptyBetaConstraints() {
045: }
046:
047: /* (non-Javadoc)
048: * @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
049: */
050: public void updateFromTuple(
051: final InternalWorkingMemory workingMemory,
052: final ReteTuple tuple) {
053: }
054:
055: /* (non-Javadoc)
056: * @see org.drools.common.BetaNodeConstraints#updateFromFactHandle(org.drools.common.InternalFactHandle)
057: */
058: public void updateFromFactHandle(
059: final InternalWorkingMemory workingMemory,
060: final InternalFactHandle handle) {
061: }
062:
063: /* (non-Javadoc)
064: * @see org.drools.common.BetaNodeConstraints#isAllowedCachedLeft(java.lang.Object)
065: */
066: public boolean isAllowedCachedLeft(final Object object) {
067: return true;
068: }
069:
070: /* (non-Javadoc)
071: * @see org.drools.common.BetaNodeConstraints#isAllowedCachedRight(org.drools.reteoo.ReteTuple)
072: */
073: public boolean isAllowedCachedRight(final ReteTuple tuple) {
074: return true;
075: }
076:
077: public boolean isIndexed() {
078: return false;
079: }
080:
081: public int getIndexCount() {
082: return 0;
083: }
084:
085: public boolean isEmpty() {
086: return true;
087: }
088:
089: public BetaMemory createBetaMemory(
090: final RuleBaseConfiguration config) {
091: final BetaMemory memory = new BetaMemory(
092: config.isSequential() ? null : new TupleHashTable(),
093: config.isSequential() ? (FactHandleMemory) new FactList()
094: : (FactHandleMemory) new FactHashTable());
095:
096: return memory;
097: }
098:
099: public int hashCode() {
100: return 1;
101: }
102:
103: /* (non-Javadoc)
104: * @see org.drools.common.BetaNodeConstraints#getConstraints()
105: */
106: public LinkedList getConstraints() {
107: final LinkedList list = new LinkedList();
108: return list;
109: }
110:
111: /**
112: * Determine if another object is equal to this.
113: *
114: * @param object
115: * The object to test.
116: *
117: * @return <code>true</code> if <code>object</code> is equal to this,
118: * otherwise <code>false</code>.
119: */
120: public boolean equals(final Object object) {
121: if (this == object) {
122: return true;
123: }
124:
125: return (object != null && (object instanceof EmptyBetaConstraints));
126: }
127:
128: }
|