private String guessName(Pdu pdu){
  String villageName="anon";
  try {
    Message message=messageFactory.fromPdu(pdu);
switch (message.getType()) {
case OwnHomeData:
case VisitedHomeData:
case EnemyHomeData:
      Message user=message.getMessage("user");
    villageName=user.getString("userName");
  break;
case WarHomeData:
WarVillage warVillage=Json.valueOf(message.getString("homeVillage"),WarVillage.class);
villageName=warVillage.name;
break;
case HomeBattleReplayData:
Replay replay=Json.valueOf(message.getString("replay"),Replay.class);
villageName=replay.defender.name;
break;
}
}
 catch (RuntimeException|IOException e) {
log.warn("Couldn't extract name from pdu {}: {}",pdu.getId(),e.toString());
}
return sanitize(villageName);
}

private String guessName ( Pdu pdu ) { String villageName = "anon" ; try { Message message = messageFactory . fromPdu ( pdu ) ; switch ( message . getType ( ) ) { case OwnHomeData : case VisitedHomeData : case EnemyHomeData : Message user = message . getMessage ( "user" ) ; villageName = user . getString ( "userName" ) ; break ; case WarHomeData : WarVillage warVillage = Json . valueOf ( message . getString ( "homeVillage" ) , WarVillage . class ) ; villageName = warVillage . name ; break ; case HomeBattleReplayData : Replay replay = Json . valueOf ( message . getString ( "replay" ) , Replay . class ) ; villageName = replay . defender . name ; break ; } } catch ( RuntimeException | IOException e ) { log . warn ( "Couldn't extract name from pdu {}: {}" , pdu . getId ( ) , e . toString ( ) ) ; } return sanitize ( villageName ) ; }
try to extract the village name from a pdu .
