public XmppAxolotlMessage fetchAxolotlMessageFromCache(Message message) {
   XmppAxolotlMessage axolotlMessage = messageCache.get(message.getUuid());
   if (axolotlMessage != null) {
     Log.d(
         Config.LOGTAG, AxolotlService.getLogprefix(account) + "Cache hit: " + message.getUuid());
     messageCache.remove(message.getUuid());
   } else {
     Log.d(
         Config.LOGTAG, AxolotlService.getLogprefix(account) + "Cache miss: " + message.getUuid());
   }
   return axolotlMessage;
 }
 public Message findSentMessageWithUuid(String id) {
   synchronized (this.messages) {
     for (Message message : this.messages) {
       if (id.equals(message.getUuid())) {
         return message;
       }
     }
   }
   return null;
 }
 public Message findUnsentMessageWithUuid(String uuid) {
   synchronized (this.messages) {
     for (final Message message : this.messages) {
       final int s = message.getStatus();
       if ((s == Message.STATUS_UNSEND || s == Message.STATUS_WAITING)
           && message.getUuid().equals(uuid)) {
         return message;
       }
     }
   }
   return null;
 }
 public Message findSentMessageWithUuidOrRemoteId(String id) {
   synchronized (this.messages) {
     for (Message message : this.messages) {
       if (id.equals(message.getUuid())
           || (message.getStatus() >= Message.STATUS_SEND
               && id.equals(message.getRemoteMsgId()))) {
         return message;
       }
     }
   }
   return null;
 }
 public Message findMessageWithFileAndUuid(final String uuid) {
   synchronized (this.messages) {
     for (final Message message : this.messages) {
       if ((message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE)
           && message.getEncryption() != Message.ENCRYPTION_PGP
           && message.getUuid().equals(uuid)) {
         return message;
       }
     }
   }
   return null;
 }
 private int getIndexOf(String uuid, List<Message> messages) {
   if (uuid == null) {
     return 0;
   }
   for (int i = 0; i < messages.size(); ++i) {
     if (uuid.equals(messages.get(i).getUuid())) {
       return i;
     } else {
       Message next = messages.get(i);
       while (next != null && next.wasMergedIntoPrevious()) {
         if (uuid.equals(next.getUuid())) {
           return i;
         }
         next = next.next();
       }
     }
   }
   return 0;
 }