void handlePartitionChange(PartitionRegistration prev, PartitionRegistration next) {
        boolean wasPresent = false;
        boolean wasOffline = false;
        boolean wasWithoutPreferredLeader = false;
        if (prev != null) {
            wasPresent = true;
            wasOffline = !prev.hasLeader();
            wasWithoutPreferredLeader = !prev.hasPreferredLeader();
        }
        boolean isPresent = false;
        boolean isOffline = false;
        boolean isWithoutPreferredLeader = false;
        if (next != null) {
            isPresent = true;
            isOffline = !next.hasLeader();
            isWithoutPreferredLeader = !next.hasPreferredLeader();
        }
        globalPartitionsChange += delta(wasPresent, isPresent);
        offlinePartitionsChange += delta(wasOffline, isOffline);
        partitionsWithoutPreferredLeaderChange += delta(wasWithoutPreferredLeader, isWithoutPreferredLeader);
    }
Calculates the change between two boolean values, expressed as an integer.
metadata/src/main/java/org/apache/kafka/controller/metrics/ControllerMetricsChanges.java