Example usage for com.google.gson.reflect TypeToken TypeToken

List of usage examples for com.google.gson.reflect TypeToken TypeToken

Introduction

In this page you can find the example usage for com.google.gson.reflect TypeToken TypeToken.

Prototype

@SuppressWarnings("unchecked")
protected TypeToken() 

Source Link

Document

Constructs a new type literal.

Usage

From source file:br.edu.ifrn.pdscfyp.Model.Profissional.java

public static Profissional getProfissionalByLogin(String login) {
    Client c = Client.create();//from  w  w w  .j a  v  a 2 s.c o  m
    WebResource wr = c.resource("https://apifyp.herokuapp.com/GetProfissionalByLogin?login=" + login);
    String json = wr.get(String.class);

    Gson gson = new Gson();
    return gson.fromJson(json, new TypeToken<Profissional>() {
    }.getType());
}

From source file:br.edu.ifrn.pdscfyp.Model.Profissional.java

public static Set<Profissional> getProfissionais() {
    Client c = Client.create();//  ww  w . ja  va  2 s .  c  o  m
    WebResource wr = c.resource("https://apifyp.herokuapp.com/ListProfissionais");
    String json = wr.get(String.class);

    Gson gson = new Gson();
    return gson.fromJson(json, new TypeToken<Set<Profissional>>() {
    }.getType());
}

From source file:br.edu.ifrn.pdscfyp.Model.Profissional.java

public static Set<Profissional> getProfissionaisByProfissao(String profissao) {
    Client c = Client.create();/* w  w w  .ja va  2s .  c om*/
    WebResource wr = c
            .resource("https://apifyp.herokuapp.com/ListProfissionaisByProfissao?profissao=" + profissao);
    String json = wr.get(String.class);

    Gson gson = new Gson();
    return gson.fromJson(json, new TypeToken<Set<Profissional>>() {
    }.getType());
}

From source file:br.edu.ifrn.pdscfyp.Model.Profissional.java

public static Profissional getProfissionalById(String idProfisisonal) {
    Client c = Client.create();//from   www  .  ja  v a2  s .  c om
    WebResource wr = c
            .resource("https://apifyp.herokuapp.com/GetFuncionarioById?idProfissional=" + idProfisisonal);
    String json = wr.get(String.class);

    Gson gson = new Gson();
    return gson.fromJson(json, new TypeToken<Profissional>() {
    }.getType());
}

From source file:br.edu.ifrn.pdscfyp.Model.Usuario.java

public static Usuario getProfissionalByLogin(String login) {
    Client c = Client.create();/* w  w w .  j  ava 2 s  . c  om*/
    WebResource wr = c.resource("https://apifyp.herokuapp.com/GetProfissionalByLogin?login=" + login);
    String json = wr.get(String.class);

    Gson gson = new Gson();
    return gson.fromJson(json, new TypeToken<Usuario>() {
    }.getType());
}

From source file:br.edu.ifrn.pdscfyp.Model.Usuario.java

public static Set<Usuario> getProfissionais() {
    Client c = Client.create();/*from w ww. j  av a  2s  .c o  m*/
    WebResource wr = c.resource("https://apifyp.herokuapp.com/ListProfissionais");
    String json = wr.get(String.class);

    Gson gson = new Gson();
    return gson.fromJson(json, new TypeToken<Set<Usuario>>() {
    }.getType());
}

From source file:br.edu.ifrn.pdscfyp.Model.Usuario.java

public static Usuario login(String login, String senha) {

    Client c = Client.create();/*from   w w w .  j  av a 2s. c  o  m*/

    WebResource wr = c.resource("https://apifyp.herokuapp.com/Login?login=" + login + "&senha=" + senha);
    String json = wr.get(String.class);

    Gson gson = new Gson();

    return gson.fromJson(json, new TypeToken<Usuario>() {
    }.getType());
}

From source file:br.edu.ifsc.pacmanwho.dao.ConversorJSON.java

public static List<Jogador> jsonToJava() throws FileNotFoundException, IOException {
    List<Jogador> resultado;
    BufferedReader br = new BufferedReader(new FileReader("json.json"));
    resultado = gson.fromJson(br, new TypeToken<List<Jogador>>() {
    }.getType());/*from   w  w w  .  j a  v a  2 s.c o m*/
    return resultado;
}

From source file:br.itecbrazil.serviceftpcliente.model.ArquivoDao.java

private ArrayList<Arquivo> getEnvio() throws FileNotFoundException {
    File arquivoDeEnvio = new File(EnumDiretorio.Configuracao.getDiretorio().concat(File.separator)
            .concat(EnumArquivos.Envio.getNomeDoArquivo()));
    FileReader fr = new FileReader(arquivoDeEnvio);
    Gson gson = new Gson();
    Type listType = new TypeToken<List<Arquivo>>() {
    }.getType();/* ww w . j  a  v  a 2s.c o  m*/
    ArrayList<Arquivo> arquivosEnviados = gson.fromJson(fr, listType);
    return arquivosEnviados;
}

From source file:br.itecbrazil.serviceftpcliente.model.ArquivoDao.java

private ArrayList<Arquivo> getRetorno() throws FileNotFoundException {
    File arquivoDeRetorno = new File(EnumDiretorio.Configuracao.getDiretorio().concat(File.separator)
            .concat(EnumArquivos.Retorno.getNomeDoArquivo()));
    FileReader fr = new FileReader(arquivoDeRetorno);
    Gson gson = new Gson();
    Type listType = new TypeToken<List<Arquivo>>() {
    }.getType();//from   w ww . ja  v  a2s  .  c o  m
    ArrayList<Arquivo> arquivosEnviados = gson.fromJson(fr, listType);
    return arquivosEnviados;
}