public boolean equals()

in ch-commons-util/src/main/java/com/cloudhopper/commons/util/ByteBuffer.java [984:1011]


    public boolean equals(Object obj)  {
        if (this == obj) {
            return true;
        }
        if ((obj == null) || !(obj instanceof ByteBuffer)) {
            return false;
        }
        ByteBuffer toTest = (ByteBuffer)obj;

        // can't be equal if size()'s don't match
        if (toTest.size() != this.size())
            return false;

        // start comparison
        int length = this.size();
        for (int i = 0; i < length; i++) {
            try {
                if (this.get(i) != toTest.get(i)) {
                    return false;
                }
            } catch (Exception e) {
                logger.error("Impossible case should never happen", e);
                return false;
            }
        }
        
        return true;
    }