How to structure an object for the following data in firebase?

0

First of all I'm a little bit lazy about programming in Java .

I have the following situation:

FromthispointIneedtogetthe" restaurant name " (because from it I will access the other data).

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef =     database.getReference("restaurante");


myRef.addValueEventListener(new ValueEventListener() {
            Long counter= new Long(0);
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                for (DataSnapshot postSnapshot: snapshot.getChildren()) {

                //preciso desmembrar os dados em partes, por exemplo
                //descobrir o nome "XPTO" e alocar no "Restaurante.setNome
                //descobrir o UID e alocar no Restaurante.setUID;
                //sabendo isso eu faria algo do tipo
                //database.child("nomeDoRestaurante").child("UID").child("CARDAPIO");
                //e armazenaria esses dados no objeto do restaurante com CriarItemCardapio
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });

Class Restaurant :

package com.example.administrador.lanchesj;


import java.util.List;

public class Restaurante {
    public String Nome;
    public String TempoMedio;
    public String Valor;
    public ItensDoRestaurante item;
    public List<ItensDoRestaurante> Cardapio;
    private Long id;

    public Restaurante(){

    }

    public Restaurante(String nome, String tempoMedio, String valor){
        this.Nome=nome;
        this.TempoMedio=tempoMedio;
        this.Valor=valor;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void CriarItemCardapio(String nome, String valor){
        this.item.setNomeDoItem(nome);
        this.item.setValorDoItem(valor);
        this.Cardapio.add(item);
    }

}

The rest I know how to implement, my very problem is in dismembering these parts.

    
asked by anonymous 22.08.2018 / 01:34

0 answers