<commit_before>package com.autofrog.xbee.api.protocol;

import com.autofrog.xbee.api.util.XbeeUtilities;

import java.util.Arrays;

/**
 * Created by chrisp on 028 3/28/2015.
 * <pre>
 * (C) Copyright 2015 <NAME> (<EMAIL>)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * </pre>
 */
public class XbeeDeviceId implements Comparable<XbeeDeviceId> {

    private byte[] deviceId;

    public XbeeDeviceId(byte[] deviceId) {
        this.deviceId = deviceId;
    }

    public byte[] getBytes() {
        return deviceId;
    }

    public String toString() {
        if (deviceId == null) {
            return "null";
        } else {
            return "0x" + XbeeUtilities.toHex(deviceId);
        }
    }

    @Override
    public boolean equals(Object compareTo) {
        if (this == compareTo)
            return true;

        if (!(compareTo instanceof XbeeDeviceId))
            return false;

        XbeeDeviceId that = (XbeeDeviceId) compareTo;
        return Arrays.equals(deviceId, that.deviceId);
    }

    @Override
    public int hashCode() {
        return deviceId != null ? Arrays.hashCode(deviceId) : 0;
    }


    public int compareTo(XbeeDeviceId that) {
        if (this.equals(that))
            return 0;

        if (that == null)
            return -1;

        if(deviceId.length != that.deviceId.length) {
            return deviceId.length - that.deviceId.length;
        }

        for(int i=0; i < deviceId.length; i++) {
            if(deviceId[i] != that.deviceId[i]) {
                return deviceId[i] = that.deviceId[i];
            }
        }

        return 0;
    }

    public boolean isUnknown() {
        return Arrays.equals(deviceId, XbeeApiConstants.UNKNOWN_DEVICE_ID);
    }

    public boolean isBroadcast() {
        return Arrays.equals(deviceId, XbeeApiConstants.BROADCAST_DEVICE_ID);
    }
}<commit_msg>Fixed long time bug in xbee library, then did a lot of testing and tweaking.  Got rid of some unnecessary sections in the UI and consolidated things a bit.<commit_after>package com.autofrog.xbee.api.protocol;

import com.autofrog.xbee.api.util.XbeeUtilities;

import java.util.Arrays;

/**
 * Created by chrisp on 028 3/28/2015.
 * <pre>
 * (C) Copyright 2015 <NAME> (<EMAIL>)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * </pre>
 */
public class XbeeDeviceId implements Comparable<XbeeDeviceId> {

    private final byte[] deviceIdBytes;

    public XbeeDeviceId(byte[] deviceId) {
        this.deviceIdBytes = deviceId;
    }

    public byte[] getBytes() {
        return deviceIdBytes;
    }

    public String toString() {
        if (deviceIdBytes == null) {
            return "null";
        } else {
            return "0x" + XbeeUtilities.toHex(deviceIdBytes);
        }
    }

    @Override
    public boolean equals(Object compareTo) {
        if (this == compareTo)
            return true;

        if (!(compareTo instanceof XbeeDeviceId))
            return false;

        XbeeDeviceId that = (XbeeDeviceId) compareTo;
        return Arrays.equals(deviceIdBytes, that.deviceIdBytes);
    }

    @Override
    public int hashCode() {
        return deviceIdBytes != null ? Arrays.hashCode(deviceIdBytes) : 0;
    }


    public int compareTo(XbeeDeviceId that) {
        if (this.equals(that))
            return 0;

        if (that == null)
            return -1;

        if(deviceIdBytes.length != that.deviceIdBytes.length) {
            return deviceIdBytes.length - that.deviceIdBytes.length;
        }

        for(int i = 0; i < deviceIdBytes.length; i++) {
            if(deviceIdBytes[i] != that.deviceIdBytes[i]) {
                return deviceIdBytes[i] - that.deviceIdBytes[i];
            }
        }

        return 0;
    }

    public boolean isUnknown() {
        return Arrays.equals(deviceIdBytes, XbeeApiConstants.UNKNOWN_DEVICE_ID);
    }

    public boolean isBroadcast() {
        return Arrays.equals(deviceIdBytes, XbeeApiConstants.BROADCAST_DEVICE_ID);
    }
}
{'fraction_non_alphanumeric': 0.09594320486815416, 'fraction_numerical': 0.00973630831643002, 'mean_word_length': 2.4823446327683616, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5759529', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1409, 'n_words': 422}