@Override
    public int getCachedSize() throws CannotCalculateSizeException {
        int size = jid.toBareJID().length();
        size += CacheSizes.sizeOfString(nickname);
        size += CacheSizes.sizeOfCollection(groups);
        size += CacheSizes.sizeOfCollection(invisibleSharedGroups);
        size += CacheSizes.sizeOfCollection(sharedGroups);
        size += CacheSizes.sizeOfInt(); // subStatus
        size += CacheSizes.sizeOfInt(); // askStatus
        size += CacheSizes.sizeOfInt(); // recvStatus
        size += CacheSizes.sizeOfLong(); // id
        if (subscribeStanza != null) {
            size += CacheSizes.sizeOfString(subscribeStanza.toXML());
        }
        return size;
    }
<p>Update the cached item as a copy of the given item.</p>
<p>A convenience for getting the item and setting each attribute.</p>

@param item The item who's settings will be copied into the cached copy
@throws org.jivesoftware.openfire.SharedGroupException if trying to remove shared group.
xmppserver/src/main/java/org/jivesoftware/openfire/roster/RosterItem.java