Search in sources :

Example 1 with ShouldntHappenException

use of org.killbill.billing.util.customfield.ShouldntHappenException in project killbill by killbill.

the class ProxyBlockingStateDao method insertTiedBlockingStatesInTheRightOrder.

private static BlockingState insertTiedBlockingStatesInTheRightOrder(final Collection<BlockingState> result, final BlockingState current, final BlockingState next, final boolean prevBlocked, final boolean currentBlocked, final boolean nextBlocked) {
    final BlockingState prev;
    if (prevBlocked && currentBlocked && nextBlocked) {
        // Tricky use case, bail
        return null;
    } else if (prevBlocked && currentBlocked && !nextBlocked) {
        result.add(next);
        result.add(current);
        prev = current;
    } else if (prevBlocked && !currentBlocked && nextBlocked) {
        result.add(current);
        result.add(next);
        prev = next;
    } else if (prevBlocked && !currentBlocked && !nextBlocked) {
        // Tricky use case, bail
        return null;
    } else if (!prevBlocked && currentBlocked && nextBlocked) {
        // Tricky use case, bail
        return null;
    } else if (!prevBlocked && currentBlocked && !nextBlocked) {
        result.add(current);
        result.add(next);
        prev = next;
    } else if (!prevBlocked && !currentBlocked && nextBlocked) {
        result.add(next);
        result.add(current);
        prev = current;
    } else if (!prevBlocked && !currentBlocked && !nextBlocked) {
        // Tricky use case, bail
        return null;
    } else {
        throw new ShouldntHappenException("Marker exception for code clarity");
    }
    return prev;
}
Also used : BlockingState(org.killbill.billing.entitlement.api.BlockingState) ShouldntHappenException(org.killbill.billing.util.customfield.ShouldntHappenException)

Aggregations

BlockingState (org.killbill.billing.entitlement.api.BlockingState)1 ShouldntHappenException (org.killbill.billing.util.customfield.ShouldntHappenException)1