Max distance constraint on two consecutive activities of a route

I want to limit the distance between two consecutive activities of a route (except start and end) . I implemented a HardActivityConstraint but it’s not working as expected. It removes the routes that don’t violate this constraint.
Would you please help me?

@Override
    public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
        double maxDistanceOfConsecutiveActivities = #someValue;
        if (prevAct instanceof Start && nextAct instanceof End) {
            return ConstraintsStatus.FULFILLED;
        }
        if (prevAct instanceof Start && getDistance(newAct.getLocation(), nextAct.getLocation()) <= maxDistanceOfConsecutiveActivities) {
            return ConstraintsStatus.FULFILLED;
        } else if (nextAct instanceof End && getDistance(newAct.getLocation(), prevAct.getLocation()) <= maxDistanceOfConsecutiveActivities) {
            return ConstraintsStatus.FULFILLED;
        }
        if (getDistance(newAct.getLocation(), prevAct.getLocation()) > maxDistanceOfConsecutiveActivities
        || getDistance(newAct.getLocation(), nextAct.getLocation()) > maxDistanceOfConsecutiveActivities) {
            return ConstraintsStatus.NOT_FULFILLED;
        } else {
            return ConstraintsStatus.FULFILLED;
        }
    }