code: package org.optsol.project_scheduling.mrcpsp.ooe.constraints;
  
  import com.google.ortools.linearsolver.MPConstraint;
  import com.google.ortools.linearsolver.MPSolver;
  import com.google.ortools.linearsolver.MPVariable;
  import java.util.Collection;
  import java.util.stream.Collectors;
  import org.optsol.jdecor.core.AbstractConstraintManager;
  import org.optsol.jdecor.core.AbstractVariableManager;
  import org.optsol.jdecor.ortools.AbstractOrtoolsConstraintManager;
  import org.optsol.project_scheduling.mrcpsp.constants.shared.events.IConstants_E;
  import org.optsol.project_scheduling.mrcpsp.ooe.variables.DecisionVars_Ooe;
  
  public class OOE_c_EventOrder<CONST extends IConstants_E>
      extends AbstractOrtoolsConstraintManager<CONST> {
  
    public OOE_c_EventOrder() {
      super("e");
    }
  
    @Override
    protected Collection<ConstraintKey> createKeys(CONST constants) {
      return
          constants.get_E().stream()
              .filter(e -> e != constants.get_card_A())
              .map(ConstraintKey::new)
              .collect(Collectors.toSet());
    }
  
    @Override
    protected void configureConstraint(
        MPConstraint constraint,
        CONST constants,
        AbstractVariableManager<MPSolver, MPVariable> variables,
        AbstractConstraintManager<MPSolver, CONST, MPVariable, MPConstraint>.ConstraintKey constraintKey)
        throws Exception {
  
      int e = constraintKey.get("e");
  
      constraint.setLb(0.);
      constraint.setCoefficient(variables.getVar(DecisionVars_Ooe.s, e + 1), 1.);
      constraint.setCoefficient(variables.getVar(DecisionVars_Ooe.s, e), -1.);
    }
  }
  