All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.drools.core.reteoo.MethodCountingObjectTypeNode Maven / Gradle / Ivy

There is a newer version: 9.44.0.Final
Show newest version
package org.drools.core.reteoo;

import org.drools.core.reteoo.builder.BuildContext;
import org.drools.core.spi.ObjectType;

import java.util.HashMap;
import java.util.Map;

public class MethodCountingObjectTypeNode extends ObjectTypeNode {
    protected Map methodCount;

    public MethodCountingObjectTypeNode(final int id,
                          final EntryPointNode source,
                          final ObjectType objectType,
                          final BuildContext context) {
        super(id, source, objectType, context);
    }

    public boolean equals(final Object object) {
        incrementCount("equals");
        return super.equals(object);
    }

    public boolean thisNodeEquals(final Object object) {
        incrementCount("thisNodeEquals");
        return super.thisNodeEquals(object);
    }

    private void incrementCount(String key) {
        if ( this.methodCount== null ) {
            this.methodCount = new HashMap();
        }
        int count = methodCount.containsKey(key) ? methodCount.get(key) : 0;
        methodCount.put(key, count + 1);
    }

    public Map getMethodCountMap() {
        return this.methodCount;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy