Last active
August 29, 2015 14:13
-
-
Save heat/410f03484287265c6ac8 to your computer and use it in GitHub Desktop.
Exemplo de um objeto simples para retorno de uma consulta generica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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