Skip to content

Instantly share code, notes, and snippets.

@heat
Last active August 29, 2015 14:13
Show Gist options
  • Save heat/410f03484287265c6ac8 to your computer and use it in GitHub Desktop.
Save heat/410f03484287265c6ac8 to your computer and use it in GitHub Desktop.
Exemplo de um objeto simples para retorno de uma consulta generica
public class Entity implements Objectfy {
private String nome;
private String sobrenome;
private Integer idade;
private List<Integer> contatos;
@Override
public String getObjectName(){
return this.nome + " " + this.sobrenome;
}
@Override
public String getType() {
return "Entity";
}
@Override
public Set getObjectFields() {
return new Arrays.asList(this.nome, this.idade, this.contatos.get(0));
}
@Override
public Object getObject() {
return this;
}
}
}
import java.io.Serializable;
import java.util.Set;
public interface Objectfy extends Serializable {
/**
* Retorna um nome amigavel do objeto
* @return
*/
public String getObjectName();
/**
* Retorna o tipo do objeto, normalmente o nome da classe <br>
* @return
*/
public String getType();
/**
* Em alguns tipos de consultas o resultado deve ser possível exibilos
* de forma tabular com diversos campos.
* @return
*/
public Set getObjectFields();
/**
* Retorna a propria representação do objeto.
* @return
*/
public Object getObject();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment