Estou fazendo um foreach e nele preciso saber se o proximo elemento é igual ao elemento anterior, mas não estou conseguindo, alguem pode me ajudar por favor.
fico grato desde ja.
String jsonList = "";
if (hubMessage.payLoad().dado().contains("CNOVA")) {
List<CategoriaMarketPlace> documents = categoriaMarketPlaceRepository.buscarCategorias();
List <JSON> jsons = new ArrayList<JSON>();
for (CategoriaMarketPlace document : documents) {
if(document.marketPlace().equals("CNOVA")){
List<DadoCategoriaMarketPlace> dadosCategoria = document.dadosCategoria();
for(DadoCategoriaMarketPlace dadoCategoria : dadosCategoria){
DBObject dbObject = (DBObject) com.mongodb.util.JSON.parse(hubMessage.payLoad().dado());
String categoriaId = (String) dbObject.get("codigo");
String categoriaName = (String) dbObject.get("nome");
if (dadoCategoria.categoriaId().equals(categoriaId) && dadoCategoria.categoriaName().equals(categoriaName)) {
if(){
jsons.add(JSONEngine.getInstance().toJSON(dadoCategoria));
}
}
}
}
}
jsonList= JSONEngine.getInstance().toJsonArray(jsons);