if (maximumDuration != null && (temp.isLongerThan(maximumDuration))) {
if (!(timePoints[0].getPointAttributes().contains(AttributeType.JUSTIFICATION) && timePoints[1] .getPointAttributes().contains(AttributeType.JUSTIFICATION)) && (maximumDuration != null && (temp.isLongerThan(maximumDuration)))) {
    public Duration calculateWorkPeriodDuration(TimePoint firstTimePoint, TimePoint lastTimePoint,            TimePoint minimumClockTimePoint, TimePoint maximumClockTimePoint, Duration maximumDuration) {        Duration totalDuration = Duration.ZERO;        Duration temp = null;        for (AttributeType attributeType : DomainConstants.WORKED_ATTRIBUTES.getAttributes()) {            TimePoint[] timePoints = findIntervalByAttribute(attributeType);            if (timePoints != null) {                if ((firstTimePoint != null && (timePoints[1].isBefore(firstTimePoint) || firstTimePoint                        .isAtSameTime(timePoints[1])))                        || (lastTimePoint != null && (lastTimePoint.isBefore(timePoints[0]) || lastTimePoint                                .isAtSameTime(timePoints[0])))) {                    temp = getDurationBetweenPoints(timePoints[0], timePoints[1], minimumClockTimePoint,                            maximumClockTimePoint);                    if (maximumDuration != null && (temp.isLongerThan(maximumDuration))) {                        totalDuration = totalDuration.plus(maximumDuration);                    } else {                        totalDuration = totalDuration.plus(temp);                    }                }            } else {                break;            }        }        return totalDuration;    }