public boolean isFriend ( Jid provisioningServer , BareJid friendInQuestion ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { LruCache < BareJid , Void > cache = negativeFriendshipRequestCache . lookup ( provisioningServer ) ; if ( cache != null && cache . containsKey ( friendInQuestion ) ) { // We hit a cached negative isFriend response for this provisioning server. return false ; } IoTIsFriend iotIsFriend = new IoTIsFriend ( friendInQuestion ) ; iotIsFriend . setTo ( provisioningServer ) ; IoTIsFriendResponse response = connection ( ) . createStanzaCollectorAndSend ( iotIsFriend ) . nextResultOrThrow ( ) ; assert ( response . getJid ( ) . equals ( friendInQuestion ) ) ; boolean isFriend = response . getIsFriendResult ( ) ; if ( ! isFriend ) { // Cache the negative is friend response. if ( cache == null ) { cache = new LruCache <> ( 1024 ) ; negativeFriendshipRequestCache . put ( provisioningServer , cache ) ; } cache . put ( friendInQuestion , null ) ; } return isFriend ; }
As the given provisioning server is the given JID is a friend .