// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java
// public interface Situation {
// 
//     public long getUID();
//     public SituationEvent getActivation();
//     public SituationEvent getDeactivation();
//     public void setDeactivation(SituationEvent deactivation);
//     public boolean isActive();
//     public List<? extends Participation> getParticipations();
//     public SituationType getType();
// }


import br.ufes.inf.lprm.situation.model.Situation;
import org.drools.core.base.ValueType;
import org.drools.core.base.evaluators.MetByEvaluatorDefinition;
import org.drools.core.common.EventFactHandle;
import org.drools.core.common.InternalFactHandle;
import org.drools.core.common.InternalWorkingMemory;
import org.drools.core.rule.VariableRestriction.LeftEndRightStartContextEntry;
import org.drools.core.rule.VariableRestriction.VariableContextEntry;
import org.drools.core.spi.FieldValue;
import org.drools.core.spi.InternalReadAccessor;
import java.lang.reflect.Field;
        try {
            Field finalRange   = this.getClass().getSuperclass().getDeclaredField("finalRange");
            finalRange.setAccessible(true);
            this.finalRange = finalRange.getLong(this);
        } catch (Exception e) {
            throw new RuntimeException( e.getMessage() );
        }
    }

    @Override
    public boolean evaluate(InternalWorkingMemory workingMemory,
                            final InternalReadAccessor extractor,
                            final InternalFactHandle object1,
                            final FieldValue object2) {
        throw new RuntimeException( "The 'metby' operator can only be used to compare one event or situation event to another, and never to compare to literal constraints." );
    }

    @Override
    public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
                                       final VariableContextEntry context,
                                       final InternalFactHandle left) {
        if ( context.rightNull ||
                context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) {
            return false;
        }

        long leftEndTS, rightStartTS;

        rightStartTS = ((LeftEndRightStartContextEntry)context).timestamp;

// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java
// public interface Situation {
// 
//     public long getUID();
//     public SituationEvent getActivation();
//     public SituationEvent getDeactivation();
//     public void setDeactivation(SituationEvent deactivation);
//     public boolean isActive();
//     public List<? extends Participation> getParticipations();
//     public SituationType getType();
// }


// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/MetByEvaluator.java
import br.ufes.inf.lprm.situation.model.Situation;
import org.drools.core.base.ValueType;
import org.drools.core.base.evaluators.MetByEvaluatorDefinition;
import org.drools.core.common.EventFactHandle;
import org.drools.core.common.InternalFactHandle;
import org.drools.core.common.InternalWorkingMemory;
import org.drools.core.rule.VariableRestriction.LeftEndRightStartContextEntry;
import org.drools.core.rule.VariableRestriction.VariableContextEntry;
import org.drools.core.spi.FieldValue;
import org.drools.core.spi.InternalReadAccessor;
import java.lang.reflect.Field;

        try {
            Field finalRange   = this.getClass().getSuperclass().getDeclaredField("finalRange");
            finalRange.setAccessible(true);
            this.finalRange = finalRange.getLong(this);
        } catch (Exception e) {
            throw new RuntimeException( e.getMessage() );
        }
    }

    @Override
    public boolean evaluate(InternalWorkingMemory workingMemory,
                            final InternalReadAccessor extractor,
                            final InternalFactHandle object1,
                            final FieldValue object2) {
        throw new RuntimeException( "The 'metby' operator can only be used to compare one event or situation event to another, and never to compare to literal constraints." );
    }

    @Override
    public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
                                       final VariableContextEntry context,
                                       final InternalFactHandle left) {
        if ( context.rightNull ||
                context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) {
            return false;
        }

        long leftEndTS, rightStartTS;

        rightStartTS = ((LeftEndRightStartContextEntry)context).timestamp;

        if (left.getObject() instanceof Situation) {