package testfactorymethod; import java.io.*; public class Funcionario implements Cloneable, Serializable { /** * Persistent Instance variables. This data is directly * mapped to the columns of database table. */ private Integer ID; private String datacontratacao; private int matricula; private String nome; /** * Constructors. DaoGen generates two constructors by default. * The first one takes no arguments and provides the most simple * way to create object instance. The another one takes one * argument, which is the primary key of the corresponding table. */ public Funcionario () { } public Funcionario (Integer IDIn) { this.ID = IDIn; } /** * Get- and Set-methods for persistent variables. The default * behaviour does not make any checks against malformed data, * so these might require some manual additions. */ public Integer getID() { return this.ID; } public void setID(Integer IDIn) { this.ID = IDIn; } public String getDatacontratacao() { return this.datacontratacao; } public void setDatacontratacao(String datacontratacaoIn) { this.datacontratacao = datacontratacaoIn; } public int getMatricula() { return this.matricula; } public void setMatricula(int matriculaIn) { this.matricula = matriculaIn; } public String getNome() { return this.nome; } public void setNome(String nomeIn) { this.nome = nomeIn; } /** * setAll allows to set all persistent variables in one method call. * This is useful, when all data is available and it is needed to * set the initial state of this object. Note that this method will * directly modify instance variales, without going trough the * individual set-methods. */ public void setAll(Integer IDIn, String datacontratacaoIn, int matriculaIn, String nomeIn) { this.ID = (Integer) IDIn; this.datacontratacao = datacontratacaoIn; this.matricula = matriculaIn; this.nome = nomeIn; } /** * hasEqualMapping-method will compare two Funcionario instances * and return true if they contain same values in all persistent instance * variables. If hasEqualMapping returns true, it does not mean the objects * are the same instance. However it does mean that in that moment, they * are mapped to the same row in database. */ public boolean hasEqualMapping(Funcionario valueObject) { if (this.ID == null) { if (valueObject.getID() != null) return(false); } else if (!this.ID.equals(valueObject.getID())) { return(false); } if (this.datacontratacao == null) { if (valueObject.getDatacontratacao() != null) return(false); } else if (!this.datacontratacao.equals(valueObject.getDatacontratacao())) { return(false); } if (valueObject.getMatricula() != this.matricula) { return(false); } if (this.nome == null) { if (valueObject.getNome() != null) return(false); } else if (!this.nome.equals(valueObject.getNome())) { return(false); } return true; } /** * toString will return String object representing the state of this * valueObject. This is useful during application development, and * possibly when application is writing object states in textlog. */ public String toString() { StringBuffer out = new StringBuffer(this.getDaogenVersion()); out.append("\nclass Funcionario, mapping to table funcionario\n"); out.append("Persistent attributes: \n"); out.append("ID = " + this.ID + "\n"); out.append("datacontratacao = " + this.datacontratacao + "\n"); out.append("matricula = " + this.matricula + "\n"); out.append("nome = " + this.nome + "\n"); return out.toString(); } /** * Clone will return identical deep copy of this valueObject. * Note, that this method is different than the clone() which * is defined in java.lang.Object. Here, the retuned cloned object * will also have all its attributes cloned. */ public Object clone() { Funcionario cloned = new Funcionario(); if (this.ID != null) cloned.setID(new Integer(this.ID.intValue())); if (this.datacontratacao != null) cloned.setDatacontratacao(new String(this.datacontratacao)); cloned.setMatricula(this.matricula); if (this.nome != null) cloned.setNome(new String(this.nome)); return cloned; } /** * getDaogenVersion will return information about * generator which created these sources. */ public String getDaogenVersion() { return "DaoGen version 2.4.1"; } }