Author: tirelli Date: 2006-04-26 10:56:28 -0400 (Wed, 26 Apr 2006) New Revision: 3974 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedRightMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultRightMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrRightMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrRightMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Chosen.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Context.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Count.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Guest.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Hobby.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Path.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Seating.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Sex.java Log: Improving performance Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaLeftMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaLeftMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -20,7 +20,6 @@ import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; -import org.drools.reteoo.FactHandleImpl; import org.drools.reteoo.ReteTuple; import org.drools.util.MultiLinkedListNodeWrapper; Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedLeftMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedLeftMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -21,7 +21,6 @@ import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; -import org.drools.reteoo.FactHandleImpl; import org.drools.reteoo.ReteTuple; import org.drools.rule.Declaration; import org.drools.spi.Evaluator; @@ -80,7 +79,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#add(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, ReteTuple tuple) { boolean select = ((Boolean) declaration.getValue( tuple.get( this.column ).getObject() )).booleanValue(); if ( select == true ) { @@ -100,7 +99,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#remove(org.drools.reteoo.ReteTuple) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, ReteTuple tuple) { if ( this.childMemory != null ) { this.childMemory.remove( workingMemory, @@ -114,7 +113,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#add(org.drools.reteoo.ReteTuple) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { boolean partition = ((Boolean) declaration.getValue( ((ReteTuple) tuple.getNode()).get( this.column ).getObject() )).booleanValue(); if ( partition == true ) { @@ -134,7 +133,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#remove(org.drools.reteoo.ReteTuple) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { if ( this.childMemory != null ) { this.childMemory.remove( workingMemory, @@ -148,7 +147,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#isEmpty() */ - public boolean isEmpty() { + public final boolean isEmpty() { return (trueList.isEmpty()) && (falseList.isEmpty()); } @@ -157,24 +156,26 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#iterator(org.drools.WorkingMemory, org.drools.reteoo.FactHandleImpl) */ - public Iterator iterator(final WorkingMemory workingMemory, + public final Iterator iterator(final WorkingMemory workingMemory, final InternalFactHandle handle) { this.selectPossibleMatches( workingMemory, handle ); Iterator iterator = new Iterator() { - Iterator it = selectedList.iterator(); - MultiLinkedListNode current = null; - MultiLinkedListNode next = null; + MultiLinkedListNode current = null; + MultiLinkedListNode next = null; + MultiLinkedListNode candidate = (MultiLinkedListNode) selectedList.getFirst(); - public boolean hasNext() { + public final boolean hasNext() { boolean hasnext = false; if ( next == null ) { - while ( it.hasNext() ) { - next = (MultiLinkedListNode) it.next(); - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) next.getChild() )) ) { + while ( candidate != null ) { + if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { hasnext = true; + next = candidate; + candidate = (MultiLinkedListNode) candidate.getNext(); break; } + candidate = (MultiLinkedListNode) candidate.getNext(); } } else { hasnext = true; @@ -182,7 +183,7 @@ return hasnext; } - public Object next() { + public final Object next() { if ( this.next == null ) { this.hasNext(); } @@ -194,7 +195,7 @@ return this.current; } - public void remove() { + public final void remove() { if ( this.current != null ) { BooleanConstrainedLeftMemory.this.remove( workingMemory, (ReteTuple) current ); @@ -210,7 +211,7 @@ /** * @inheritDoc */ - public Iterator iterator() { + public final Iterator iterator() { return new Iterator() { Iterator trueIt = trueList.iterator(); Iterator falseIt = falseList.iterator(); @@ -219,7 +220,7 @@ ReteTuple current = null; ReteTuple next = null; - public boolean hasNext() { + public final boolean hasNext() { boolean hasnext = false; if ( next == null ) { if ( (currentTrue == null) && (trueIt.hasNext()) ) { @@ -254,7 +255,7 @@ return hasnext; } - public Object next() { + public final Object next() { if ( this.next == null ) { this.hasNext(); } @@ -266,7 +267,7 @@ return this.current; } - public void remove() { + public final void remove() { throw new UnsupportedOperationException( "Not possible to call remove when iterating over all elements" ); } }; @@ -277,7 +278,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#selectPossibleMatches(org.drools.WorkingMemory, org.drools.reteoo.FactHandleImpl) */ - public void selectPossibleMatches(WorkingMemory workingMemory, + public final void selectPossibleMatches(WorkingMemory workingMemory, InternalFactHandle handle) { boolean select = ((Boolean) this.extractor.getValue( handle.getObject() )).booleanValue(); select = (evaluator.getOperator()) == Evaluator.EQUAL ? select : !select; @@ -297,7 +298,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#isPossibleMatch(org.drools.util.MultiLinkedListNodeWrapper) */ - public boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { + public final boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { boolean isPossible = ((this.selectedList != null) && (tuple.getLinkedList() == this.selectedList)); if ( (isPossible) && (this.childMemory != null) ) { isPossible = this.childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) tuple.getChild() ); @@ -305,7 +306,7 @@ return isPossible; } - public int size() { + public final int size() { return this.trueList.size() + this.falseList.size(); } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedRightMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedRightMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -81,7 +81,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#add(org.drools.WorkingMemory, org.drools.reteoo.ObjectMatches) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, ObjectMatches matches) { MultiLinkedList list = this.getMatchingList( workingMemory, matches.getFactHandle() ); @@ -101,7 +101,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#remove(org.drools.WorkingMemory, org.drools.reteoo.ObjectMatches) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, ObjectMatches matches) { if ( this.childMemory != null ) { this.childMemory.remove( workingMemory, @@ -116,7 +116,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#add(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, MultiLinkedListNodeWrapper wrapper) { ObjectMatches matches = (ObjectMatches) wrapper.getNode(); MultiLinkedList list = this.getMatchingList( workingMemory, @@ -136,7 +136,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#remove(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper wrapper) { if ( this.childMemory != null ) { this.childMemory.remove( workingMemory, @@ -150,24 +150,26 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#iterator(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public Iterator iterator(final WorkingMemory workingMemory, + public final Iterator iterator(final WorkingMemory workingMemory, final ReteTuple tuple) { this.selectPossibleMatches( workingMemory, tuple ); Iterator iterator = new Iterator() { - Iterator it = selectedList.iterator(); - ObjectMatches current = null; - ObjectMatches next = null; + ObjectMatches current = null; + ObjectMatches next = null; + ObjectMatches candidate = (ObjectMatches) selectedList.getFirst(); - public boolean hasNext() { + public final boolean hasNext() { boolean hasnext = false; if ( next == null ) { - while ( it.hasNext() ) { - next = (ObjectMatches) it.next(); - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) next.getChild() )) ) { + while ( candidate != null ) { + if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { hasnext = true; + next = candidate; + candidate = (ObjectMatches) candidate.getNext(); break; } + candidate = (ObjectMatches) candidate.getNext(); } } else { hasnext = true; @@ -175,7 +177,7 @@ return hasnext; } - public Object next() { + public final Object next() { if ( this.next == null ) { this.hasNext(); } @@ -187,7 +189,7 @@ return this.current; } - public void remove() { + public final void remove() { throw new UnsupportedOperationException( "Iterator.remove() should not be used to remove right side objects from right memory." ); } @@ -200,7 +202,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#isEmpty() */ - public boolean isEmpty() { + public final boolean isEmpty() { return this.trueList.isEmpty() && this.falseList.isEmpty(); } @@ -210,7 +212,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#selectPossibleMatches(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public void selectPossibleMatches(WorkingMemory workingMemory, + public final void selectPossibleMatches(WorkingMemory workingMemory, ReteTuple tuple) { boolean select = ((Boolean) declaration.getValue( tuple.get( this.column ).getObject() )).booleanValue(); select = (evaluator.getOperator()) == Evaluator.EQUAL ? select : !select; @@ -228,7 +230,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#isPossibleMatch(org.drools.util.MultiLinkedListNodeWrapper) */ - public boolean isPossibleMatch(MultiLinkedListNodeWrapper matches) { + public final boolean isPossibleMatch(MultiLinkedListNodeWrapper matches) { boolean ret = false; if ( this.selectedList != null ) { ret = matches.getLinkedList() == this.selectedList; @@ -246,7 +248,7 @@ * @param handle * @return */ - private MultiLinkedList getMatchingList(WorkingMemory workingMemory, + private final MultiLinkedList getMatchingList(WorkingMemory workingMemory, FactHandleImpl handle) { boolean select = ((Boolean) this.extractor.getValue( handle.getObject() )).booleanValue(); MultiLinkedList list = (select == true) ? this.trueList : this.falseList; @@ -259,14 +261,14 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#size() */ - public int size() { + public final int size() { return this.trueList.size() + this.falseList.size(); } /** * @inheritDoc */ - public Iterator iterator() { + public final Iterator iterator() { TreeSet set = new TreeSet( new Comparator() { public int compare(Object arg0, Object arg1) { Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultLeftMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultLeftMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -20,7 +20,6 @@ import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; -import org.drools.reteoo.FactHandleImpl; import org.drools.reteoo.ReteTuple; import org.drools.util.MultiLinkedList; import org.drools.util.MultiLinkedListNodeWrapper; @@ -49,7 +48,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#add(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { this.memory.add( tuple ); } @@ -57,7 +56,7 @@ /** * @inheritDoc */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { this.memory.remove( tuple ); } @@ -65,7 +64,7 @@ /** * @inheritDoc */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, ReteTuple tuple) { this.memory.add( tuple ); } @@ -73,7 +72,7 @@ /** * @inheritDoc */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, ReteTuple tuple) { this.memory.remove( tuple ); } @@ -81,7 +80,7 @@ /** * @inheritDoc */ - public Iterator iterator(WorkingMemory workingMemory, + public final Iterator iterator(WorkingMemory workingMemory, InternalFactHandle handle) { return this.memory.iterator(); } @@ -89,21 +88,21 @@ /** * @inheritDoc */ - public Iterator iterator() { + public final Iterator iterator() { return this.memory.iterator(); } /** * @inheritDoc */ - public boolean isEmpty() { + public final boolean isEmpty() { return this.memory.isEmpty(); } /** * @inheritDoc */ - public void selectPossibleMatches(WorkingMemory workingMemory, + public final void selectPossibleMatches(WorkingMemory workingMemory, InternalFactHandle handle) { // nothing to do. all tuples are possible matches } @@ -111,14 +110,14 @@ /** * @inheritDoc */ - public boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { + public final boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { return tuple.getLinkedList() == this.memory; } /** * @inheritDoc */ - public int size() { + public final int size() { return this.memory.size(); } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultRightMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultRightMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -48,7 +48,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#add(org.drools.WorkingMemory, org.drools.reteoo.ObjectMatches) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, ObjectMatches matches) { this.memory.add( matches ); } @@ -59,7 +59,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#remove(org.drools.WorkingMemory, org.drools.reteoo.ObjectMatches) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, ObjectMatches matches) { matches.getLinkedList().remove( matches ); } @@ -70,7 +70,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#add(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, MultiLinkedListNodeWrapper wrapper) { this.memory.add( wrapper ); } @@ -81,7 +81,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#remove(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper wrapper) { wrapper.getLinkedList().remove( wrapper ); } @@ -91,11 +91,9 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#iterator(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public Iterator iterator(final WorkingMemory workingMemory, + public final Iterator iterator(final WorkingMemory workingMemory, final ReteTuple tuple) { - this.selectPossibleMatches( workingMemory, - tuple ); - return this.iterator(); + return this.memory.iterator(); } /** @@ -103,7 +101,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#isEmpty() */ - public boolean isEmpty() { + public final boolean isEmpty() { return this.memory.isEmpty(); } @@ -113,7 +111,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#selectPossibleMatches(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public void selectPossibleMatches(WorkingMemory workingMemory, + public final void selectPossibleMatches(WorkingMemory workingMemory, ReteTuple tuple) { // nothing to do } @@ -124,7 +122,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#isPossibleMatch(org.drools.util.MultiLinkedListNodeWrapper) */ - public boolean isPossibleMatch(MultiLinkedListNodeWrapper matches) { + public final boolean isPossibleMatch(MultiLinkedListNodeWrapper matches) { return matches.getLinkedList() == this.memory; } @@ -134,7 +132,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#size() */ - public int size() { + public final int size() { return this.memory.size(); } @@ -143,7 +141,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#iterator() */ - public Iterator iterator() { + public final Iterator iterator() { return memory.iterator(); } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrLeftMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrLeftMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -26,7 +26,6 @@ import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; -import org.drools.reteoo.FactHandleImpl; import org.drools.reteoo.ReteTuple; import org.drools.rule.Declaration; import org.drools.spi.Evaluator; @@ -83,7 +82,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#add(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, ReteTuple tuple) { MultiLinkedList list = getTupleBucket( workingMemory, tuple ); @@ -101,7 +100,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#remove(org.drools.reteoo.ReteTuple) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, ReteTuple tuple) { if ( this.childMemory != null ) { this.childMemory.remove( workingMemory, @@ -120,7 +119,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#add(org.drools.reteoo.ReteTuple) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { MultiLinkedList list = this.getTupleBucket( workingMemory, (ReteTuple) tuple.getNode() ); @@ -141,7 +140,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#remove(org.drools.reteoo.ReteTuple) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { if ( this.childMemory != null ) { this.childMemory.remove( workingMemory, @@ -163,7 +162,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#isEmpty() */ - public boolean isEmpty() { + public final boolean isEmpty() { return memoryMap.isEmpty(); } @@ -172,26 +171,28 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#iterator(org.drools.WorkingMemory, org.drools.reteoo.FactHandleImpl) */ - public Iterator iterator(final WorkingMemory workingMemory, + public final Iterator iterator(final WorkingMemory workingMemory, final InternalFactHandle handle) { this.selectPossibleMatches( workingMemory, handle ); Iterator iterator = null; if ( this.selectedList != null ) { iterator = new Iterator() { - Iterator it = selectedList.iterator(); - MultiLinkedListNode current = null; - MultiLinkedListNode next = null; - - public boolean hasNext() { + MultiLinkedListNode current = null; + MultiLinkedListNode next = null; + MultiLinkedListNode candidate = (MultiLinkedListNode) selectedList.getFirst(); + + public final boolean hasNext() { boolean hasnext = false; if ( next == null ) { - while ( it.hasNext() ) { - next = (MultiLinkedListNode) it.next(); - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) next.getChild() )) ) { + while ( candidate != null ) { + if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { hasnext = true; + next = candidate; + candidate = (MultiLinkedListNode) candidate.getNext(); break; } + candidate = (MultiLinkedListNode) candidate.getNext(); } } else { hasnext = true; @@ -199,7 +200,7 @@ return hasnext; } - public Object next() { + public final Object next() { if ( this.next == null ) { this.hasNext(); } @@ -211,7 +212,7 @@ return this.current; } - public void remove() { + public final void remove() { if ( this.current != null ) { ObjectEqualConstrLeftMemory.this.remove( workingMemory, (ReteTuple) current ); @@ -230,7 +231,7 @@ /** * @inheritDoc */ - public Iterator iterator() { + public final Iterator iterator() { TreeSet set = new TreeSet( new Comparator() { public int compare(Object arg0, Object arg1) { @@ -253,7 +254,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#selectPossibleMatches(org.drools.WorkingMemory, org.drools.reteoo.FactHandleImpl) */ - public void selectPossibleMatches(WorkingMemory workingMemory, + public final void selectPossibleMatches(WorkingMemory workingMemory, InternalFactHandle handle) { Object select = this.extractor.getValue( handle.getObject() ); Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); @@ -265,7 +266,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#isPossibleMatch(org.drools.util.MultiLinkedListNodeWrapper) */ - public boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { + public final boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { return ((this.selectedList != null) && (tuple != null) && (tuple.getLinkedList() == this.selectedList)); } @@ -277,7 +278,7 @@ * @param tuple * @return */ - private MultiLinkedList getTupleBucket(WorkingMemory workingMemory, + private final MultiLinkedList getTupleBucket(WorkingMemory workingMemory, ReteTuple tuple) { Integer hash = getTupleHash( workingMemory, tuple ); @@ -297,14 +298,14 @@ * @param tuple * @return */ - private Integer getTupleHash(WorkingMemory workingMemory, + private final Integer getTupleHash(WorkingMemory workingMemory, ReteTuple tuple) { Object select = declaration.getValue( tuple.get( this.column ).getObject() ); Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); return hash; } - public int size() { + public final int size() { return this.size; } @@ -312,7 +313,7 @@ * Remove a clean memory entry * @param list */ - private void removeMemoryEntry(LinkedList list) { + private final void removeMemoryEntry(LinkedList list) { Object hash = ((KeyMultiLinkedList) list).getKey(); this.memoryMap.remove( hash ); } @@ -324,7 +325,7 @@ * * @return */ - public boolean isClean() { + public final boolean isClean() { boolean ret = true; for ( Iterator i = this.memoryMap.values().iterator(); i.hasNext(); ) { MultiLinkedList list = (MultiLinkedList) i.next(); @@ -336,7 +337,7 @@ return ret; } - private static class KeyMultiLinkedList extends MultiLinkedList { + private static final class KeyMultiLinkedList extends MultiLinkedList { private final Object key; public KeyMultiLinkedList(Object key) { Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrRightMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrRightMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -84,7 +84,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#add(org.drools.WorkingMemory, org.drools.reteoo.ObjectMatches) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, ObjectMatches matches) { MultiLinkedList list = this.getFactList( workingMemory, matches.getFactHandle() ); @@ -104,7 +104,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#remove(org.drools.WorkingMemory, org.drools.reteoo.ObjectMatches) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, ObjectMatches matches) { if ( this.childMemory != null ) { this.childMemory.remove( workingMemory, @@ -125,7 +125,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#add(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, MultiLinkedListNodeWrapper wrapper) { ObjectMatches matches = (ObjectMatches) wrapper.getNode(); MultiLinkedList list = this.getFactList( workingMemory, @@ -146,7 +146,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#remove(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper matches) { if ( this.childMemory != null ) { this.childMemory.remove( workingMemory, @@ -165,26 +165,28 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#iterator(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public Iterator iterator(final WorkingMemory workingMemory, + public final Iterator iterator(final WorkingMemory workingMemory, final ReteTuple tuple) { this.selectPossibleMatches( workingMemory, tuple ); Iterator iterator = null; if ( this.selectedList != null ) { iterator = new Iterator() { - Iterator it = selectedList.iterator(); - ObjectMatches current = null; - ObjectMatches next = null; + ObjectMatches current = null; + ObjectMatches next = null; + ObjectMatches candidate = (ObjectMatches) selectedList.getFirst(); - public boolean hasNext() { + public final boolean hasNext() { boolean hasnext = false; if ( next == null ) { - while ( it.hasNext() ) { - next = (ObjectMatches) it.next(); - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) next.getChild() )) ) { + while ( candidate != null ) { + if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { hasnext = true; + next = candidate; + candidate = (ObjectMatches) candidate.getNext(); break; } + candidate = (ObjectMatches) candidate.getNext(); } } else { hasnext = true; @@ -192,7 +194,7 @@ return hasnext; } - public Object next() { + public final Object next() { if ( this.next == null ) { this.hasNext(); } @@ -204,7 +206,7 @@ return this.current; } - public void remove() { + public final void remove() { throw new UnsupportedOperationException( "Iterator.remove() should not be used to remove right side objects from right memory." ); } }; @@ -219,7 +221,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#isEmpty() */ - public boolean isEmpty() { + public final boolean isEmpty() { return this.memoryMap.isEmpty(); } @@ -228,7 +230,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#selectPossibleMatches(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public void selectPossibleMatches(WorkingMemory workingMemory, + public final void selectPossibleMatches(WorkingMemory workingMemory, ReteTuple tuple) { Object select = declaration.getValue( tuple.get( this.column ).getObject() ); Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); @@ -240,7 +242,7 @@ } } - public boolean isPossibleMatch(MultiLinkedListNodeWrapper wrapper) { + public final boolean isPossibleMatch(MultiLinkedListNodeWrapper wrapper) { boolean ret = false; if ( this.selectedList != null ) { ret = wrapper.getLinkedList() == this.selectedList; @@ -258,7 +260,7 @@ * @param handle * @return */ - private MultiLinkedList getFactList(WorkingMemory workingMemory, + private final MultiLinkedList getFactList(WorkingMemory workingMemory, InternalFactHandle handle) { Object select = this.extractor.getValue( handle.getObject() ); Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); @@ -271,12 +273,12 @@ return list; } - private void removeMapEntry(KeyMultiLinkedList list) { + private final void removeMapEntry(KeyMultiLinkedList list) { Object hash = list.getKey(); this.memoryMap.remove( hash ); } - public int size() { + public final int size() { return this.memorySize; } @@ -287,7 +289,7 @@ * * @return */ - public boolean isClean() { + public final boolean isClean() { boolean ret = true; for ( Iterator i = this.memoryMap.values().iterator(); i.hasNext(); ) { MultiLinkedList list = (MultiLinkedList) i.next(); @@ -302,7 +304,7 @@ /** * @inheritDoc */ - public Iterator iterator() { + public final Iterator iterator() { TreeSet set = new TreeSet( new Comparator() { public int compare(Object arg0, Object arg1) { Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrLeftMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrLeftMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -23,7 +23,6 @@ import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; -import org.drools.reteoo.FactHandleImpl; import org.drools.reteoo.ReteTuple; import org.drools.rule.Declaration; import org.drools.spi.Evaluator; @@ -80,7 +79,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#add(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, ReteTuple tuple) { this.memoryMasterList.add( tuple ); @@ -103,7 +102,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#remove(org.drools.reteoo.ReteTuple) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, ReteTuple tuple) { if ( this.innerMemory != null ) { this.innerMemory.remove( workingMemory, @@ -122,7 +121,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#add(org.drools.reteoo.ReteTuple) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { this.memoryMasterList.add( tuple ); @@ -147,7 +146,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#remove(org.drools.reteoo.ReteTuple) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { if ( this.innerMemory != null ) { this.innerMemory.remove( workingMemory, @@ -168,7 +167,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#isEmpty() */ - public boolean isEmpty() { + public final boolean isEmpty() { return memoryMasterList.isEmpty(); } @@ -177,26 +176,28 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#iterator(org.drools.WorkingMemory, org.drools.reteoo.FactHandleImpl) */ - public Iterator iterator(final WorkingMemory workingMemory, + public final Iterator iterator(final WorkingMemory workingMemory, final InternalFactHandle handle) { this.selectPossibleMatches( workingMemory, handle ); Iterator iterator = new Iterator() { - Iterator it = memoryMasterList.iterator(); - MultiLinkedListNode current = null; - MultiLinkedListNode next = null; + MultiLinkedListNode current = null; + MultiLinkedListNode next = null; + MultiLinkedListNode candidate = (MultiLinkedListNode) memoryMasterList.getFirst(); - public boolean hasNext() { + public final boolean hasNext() { boolean hasnext = false; if ( next == null ) { - while ( it.hasNext() ) { - next = (MultiLinkedListNode) it.next(); - if ( next.getChild().getLinkedList() != noMatchList ) { - if ( (innerMemory == null) || (innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) next.getChild().getChild() )) ) { + while ( candidate != null ) { + if ( candidate.getChild().getLinkedList() != noMatchList ) { + if ( (innerMemory == null) || (innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild().getChild() )) ) { hasnext = true; + next = candidate; + candidate = (MultiLinkedListNode) candidate.getNext(); break; } } + candidate = (MultiLinkedListNode) candidate.getNext(); } } else { hasnext = true; @@ -204,7 +205,7 @@ return hasnext; } - public Object next() { + public final Object next() { if ( this.next == null ) { this.hasNext(); } @@ -216,7 +217,7 @@ return this.current; } - public void remove() { + public final void remove() { if ( this.current != null ) { // Iterator is always called on the outer most memory, // so elements shall always be ReteTuples @@ -233,7 +234,7 @@ /** * @inheritDoc */ - public Iterator iterator() { + public final Iterator iterator() { return this.memoryMasterList.iterator(); } @@ -242,7 +243,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#selectPossibleMatches(org.drools.WorkingMemory, org.drools.reteoo.FactHandleImpl) */ - public void selectPossibleMatches(WorkingMemory workingMemory, + public final void selectPossibleMatches(WorkingMemory workingMemory, InternalFactHandle handle) { Object select = this.extractor.getValue( handle.getObject() ); this.noMatchList = (MultiLinkedList) this.memoryMap.get( select ); @@ -253,7 +254,7 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#isPossibleMatch(org.drools.util.MultiLinkedListNodeWrapper) */ - public boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { + public final boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { boolean ret = false; if ( (tuple != null) && (tuple.getChild() != null) && (tuple.getChild().getLinkedList() != null) ) { ret = (tuple.getChild().getLinkedList() != this.noMatchList); @@ -272,7 +273,7 @@ * @param tuple * @return */ - private MultiLinkedList getTupleBucket(WorkingMemory workingMemory, + private final MultiLinkedList getTupleBucket(WorkingMemory workingMemory, ReteTuple tuple) { Object key = getTupleKey( workingMemory, tuple ); @@ -292,7 +293,7 @@ * @param tuple * @return */ - private Object getTupleKey(WorkingMemory workingMemory, + private final Object getTupleKey(WorkingMemory workingMemory, ReteTuple tuple) { Object select = declaration.getValue( tuple.get( this.column ).getObject() ); return select; @@ -304,14 +305,14 @@ * * @see org.drools.reteoo.beta.BetaLeftMemory#size() */ - public int size() { + public final int size() { return this.memoryMasterList.size(); } /** * @param list */ - private void removeMemoryEntry(LinkedList list) { + private final void removeMemoryEntry(LinkedList list) { this.memoryMap.remove( ((KeyMultiLinkedList) list).getKey() ); } @@ -322,7 +323,7 @@ * * @return */ - public boolean isClean() { + public final boolean isClean() { boolean ret = true; for ( Iterator i = this.memoryMap.values().iterator(); i.hasNext(); ) { MultiLinkedList list = (MultiLinkedList) i.next(); Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrRightMemory.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrRightMemory.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -23,7 +23,6 @@ import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; -import org.drools.reteoo.FactHandleImpl; import org.drools.reteoo.ObjectMatches; import org.drools.reteoo.ReteTuple; import org.drools.rule.Declaration; @@ -81,7 +80,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#add(org.drools.WorkingMemory, org.drools.reteoo.ObjectMatches) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, ObjectMatches matches) { // adding to master list this.memoryMasterList.add( matches ); @@ -109,7 +108,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#remove(org.drools.WorkingMemory, org.drools.reteoo.ObjectMatches) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, ObjectMatches matches) { if ( this.childMemory != null ) { // removing from inner indexes @@ -137,7 +136,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#add(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void add(WorkingMemory workingMemory, + public final void add(WorkingMemory workingMemory, MultiLinkedListNodeWrapper matches) { ObjectMatches om = (ObjectMatches) matches.getNode(); @@ -167,7 +166,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#remove(org.drools.WorkingMemory, org.drools.util.MultiLinkedListNodeWrapper) */ - public void remove(WorkingMemory workingMemory, + public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper matches) { if ( this.childMemory != null ) { // removing from inner indexes @@ -194,26 +193,29 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#iterator(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public Iterator iterator(final WorkingMemory workingMemory, + public final Iterator iterator(final WorkingMemory workingMemory, final ReteTuple tuple) { this.selectPossibleMatches( workingMemory, tuple ); Iterator iterator = new Iterator() { - Iterator it = memoryMasterList.iterator(); - ObjectMatches current = null; - ObjectMatches next = null; + //Iterator it = memoryMasterList.iterator(); + ObjectMatches current = null; + ObjectMatches next = null; + ObjectMatches candidate = (ObjectMatches) memoryMasterList.getFirst(); - public boolean hasNext() { + public final boolean hasNext() { boolean hasnext = false; if ( next == null ) { - while ( it.hasNext() ) { - next = (ObjectMatches) it.next(); - if ( next.getChild().getLinkedList() != noMatchList ) { - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) next.getChild().getChild() )) ) { + while ( candidate != null ) { + if ( candidate.getChild().getLinkedList() != noMatchList ) { + if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild().getChild() )) ) { hasnext = true; + next = candidate; + candidate = (ObjectMatches) candidate.getNext(); break; } } + candidate = (ObjectMatches) candidate.getNext(); } } else { hasnext = true; @@ -221,7 +223,7 @@ return hasnext; } - public Object next() { + public final Object next() { if ( this.next == null ) { this.hasNext(); } @@ -233,7 +235,7 @@ return this.current; } - public void remove() { + public final void remove() { throw new UnsupportedOperationException( "Iterator.remove() should not be used to remove right side objects from right memory." ); } @@ -246,7 +248,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#isEmpty() */ - public boolean isEmpty() { + public final boolean isEmpty() { return this.memoryMap.isEmpty(); } @@ -255,7 +257,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#selectPossibleMatches(org.drools.WorkingMemory, org.drools.reteoo.ReteTuple) */ - public void selectPossibleMatches(WorkingMemory workingMemory, + public final void selectPossibleMatches(WorkingMemory workingMemory, ReteTuple tuple) { Object select = declaration.getValue( tuple.get( this.column ).getObject() ); Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); @@ -272,7 +274,7 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#isPossibleMatch(org.drools.reteoo.FactHandleImpl) */ - public boolean isPossibleMatch(MultiLinkedListNodeWrapper matches) { + public final boolean isPossibleMatch(MultiLinkedListNodeWrapper matches) { boolean ret = false; if ( (matches != null) && (matches.getChild() != null) && (matches.getChild().getLinkedList() != null) ) { ret = (matches.getChild().getLinkedList() != noMatchList); @@ -292,7 +294,7 @@ * @param handle * @return */ - private MultiLinkedList getFactList(WorkingMemory workingMemory, + private final MultiLinkedList getFactList(WorkingMemory workingMemory, InternalFactHandle handle) { Object select = this.extractor.getValue( handle.getObject() ); Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); @@ -311,14 +313,14 @@ * * @see org.drools.reteoo.beta.BetaRightMemory#size() */ - public int size() { + public final int size() { return this.memoryMasterList.size(); } /** * @param matches */ - private void removeMemoryEntry(MultiLinkedList list) { + private final void removeMemoryEntry(MultiLinkedList list) { this.memoryMap.remove( ((KeyMultiLinkedList) list).getKey() ); } @@ -329,7 +331,7 @@ * * @return */ - public boolean isClean() { + public final boolean isClean() { boolean ret = true; for ( Iterator i = this.memoryMap.values().iterator(); i.hasNext(); ) { MultiLinkedList list = (MultiLinkedList) i.next(); @@ -341,7 +343,7 @@ return ret; } - public Iterator iterator() { + public final Iterator iterator() { return this.memoryMasterList.iterator(); } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -104,7 +104,7 @@ * @return * The first <code>LinkedListNode</code>. */ - public LinkedListNode getFirst() { + public final LinkedListNode getFirst() { return this.firstNode; } @@ -113,7 +113,7 @@ * @return * The last <code>LinkedListNode</code>. */ - public LinkedListNode getLast() { + public final LinkedListNode getLast() { return this.lastNode; } @@ -167,7 +167,7 @@ * @return * boolean value indicating the empty status of the list */ - public boolean isEmpty() { + public final boolean isEmpty() { return (this.firstNode == null); } @@ -183,7 +183,7 @@ * @return * return size of the list as an int */ - public int size() { + public final int size() { return this.size; } Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Chosen.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Chosen.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Chosen.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -21,7 +21,7 @@ import java.io.Serializable; -public class Chosen +public final class Chosen implements Serializable { @@ -39,19 +39,19 @@ this.hobby = hobby; } - public int getId() { + public final int getId() { return this.id; } - public String getGuestName() { + public final String getGuestName() { return this.guestName; } - public Hobby getHobby() { + public final Hobby getHobby() { return this.hobby; } - public String toString() { + public final String toString() { return "{Chosen id=" + this.id + ", name=" + this.guestName + ", hobbies=" + this.hobby + "}"; } } \ No newline at end of file Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Context.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Context.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Context.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -21,7 +21,7 @@ import java.io.Serializable; -public class Context +public final class Context implements Serializable { @@ -30,6 +30,14 @@ public static final int MAKE_PATH = 2; public static final int CHECK_DONE = 3; public static final int PRINT_RESULTS = 4; + + public static final String[] stateStrings = { + "START_UP", + "ASSIGN_SEATS", + "MAKE_PATH", + "CHECK_DONE", + "PRINT_RESULTS" + }; private int state; @@ -45,35 +53,23 @@ this.state = state; } - public void setState(int state) { + public final void setState(int state) { this.state = state; } - public boolean isState(int state) { + public final boolean isState(int state) { return this.state == state; } - public int getState() { + public final int getState() { return this.state; } - public String getStringValue() { - switch ( this.state ) { - case 0 : - return "START_UP"; - case 1 : - return "ASSIGN_SEATS"; - case 2 : - return "MAKE_PATH"; - case 3 : - return "CHECK_DONE"; - case 4 : - return "PRINT_RESULTS"; - } - return ""; + public final String getStringValue() { + return stateStrings[this.state]; } - public String toString() { + public final String toString() { return "[Context state=" + getStringValue() + "]"; } } \ No newline at end of file Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Count.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Count.java 2006-04-26 13:42:09 UTC (rev 3973) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Count.java 2006-04-26 14:56:28 UTC (rev 3974) @@ -17,7 +17,7 @@ -public class Count { +public final class Count { private int value; public Count(int value) { @@ -25,19 +25,19 @@ this.value = value; } - public int getValue() { + public final int getValue() { return this.value; } - public void setValue(int value) { + public final void setValue(int value) { this.value = value; ... [truncated message content] |