All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.yamcs.utils.ByteArrayWrapper Maven / Gradle / Ivy

There is a newer version: 5.10.9
Show newest version
package org.yamcs.utils;

import java.util.Arrays;

/**
 * Wrapper around byte array that allows usage as hashmap keys
 * @author nm
 *
 */
public class ByteArrayWrapper {
    private final byte[] data;

    public ByteArrayWrapper(byte[] buf) {
        this.data = buf;
    }
    
    public byte[] getData() {
        return data;
    }
    
    @Override
    public boolean equals(Object other) {
        if (!(other instanceof ByteArrayWrapper)) {
            return false;
        }
        return Arrays.equals(data, ((ByteArrayWrapper)other).data);
    }

    @Override
    public int hashCode() {
        return Arrays.hashCode(data);
    }
    
    @Override
    public String toString() {
        return StringConverter.arrayToHexString(data);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy