Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 17.82 KB | None | 0 0
  1. package de.swe1.kundenverwaltung.domain;
  2. import static javax.xml.bind.annotation.XmlAccessType.FIELD;
  3. import static javax.persistence.CascadeType.PERSIST;
  4. import static javax.persistence.CascadeType.REMOVE;
  5. import java.io.Serializable;
  6. import java.net.URI;
  7.  
  8. import javax.persistence.Entity;
  9. import javax.persistence.Table;
  10. import javax.persistence.NamedQueries;
  11. import javax.persistence.NamedQuery;
  12. import javax.persistence.Id;
  13. import javax.persistence.GeneratedValue;
  14. import javax.persistence.GenerationType;
  15. import javax.persistence.Column;
  16. import javax.persistence.ManyToOne;
  17. import javax.persistence.OneToMany;
  18. import javax.persistence.Transient;
  19. import javax.persistence.Embedded;
  20. import javax.persistence.FetchType;
  21. import javax.persistence.Version;
  22. import javax.validation.Valid;
  23. import javax.validation.constraints.Min;
  24. import javax.validation.constraints.NotNull;
  25. import javax.validation.constraints.Pattern;
  26. import javax.validation.constraints.Size;
  27. import javax.xml.bind.annotation.XmlAccessorType;
  28. import javax.xml.bind.annotation.XmlAttribute;
  29. import javax.xml.bind.annotation.XmlElement;
  30. import javax.xml.bind.annotation.XmlElementWrapper;
  31. import javax.xml.bind.annotation.XmlRootElement;
  32. import javax.xml.bind.annotation.XmlTransient;
  33.  
  34. import org.hibernate.validator.constraints.Email;
  35.  
  36. import de.swe1.anschriftverwaltung.domain.Anschrift;
  37. import de.swe1.bestellverwaltung.domain.Bestellung;
  38. import de.swe1.util.IdGroup;
  39.  
  40. import java.util.ArrayList;
  41. import java.util.List;
  42.  
  43.  
  44.  
  45. /**
  46.  * JPA Klasse Anschrift fuer Datenbank.
  47.  */
  48. @Entity
  49. @Table(name = "kunde")
  50.  
  51. @NamedQueries({
  52.     @NamedQuery(name  = Kunde.FIND_KUNDE,
  53.             query = "SELECT k"
  54.                     + " FROM   Kunde k LEFT JOIN FETCH k.bestellungen"),
  55.    
  56.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_NACHNAME,
  57.                 query = "FROM Kunde k"     
  58.                      + " WHERE k.name=:" + Kunde.PARAM_KUNDE_NACHNAME),
  59.    
  60.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_ID,
  61.                 query = "FROM Kunde k"     
  62.                     + " WHERE k.idKunde=:" + Kunde.PARAM_KUNDE_IDKUNDE
  63.                         ),
  64.                        
  65.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_VORNAMEANDNACHNAME,
  66.                 query = "FROM Kunde k"     
  67.                     + " WHERE k.vorname=:" + Kunde.PARAM_KUNDE_VORNAME + " AND " + "k.name=:" + Kunde.PARAM_KUNDE_NACHNAME),
  68.                      
  69.     @NamedQuery(name = "Kunde.Count",
  70.                 query = "Select Count(idKunde)as Anzahl From Kunde"),
  71.    
  72.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_NACHNAMEFETCHBESTELLUNG,
  73.                 query = "SELECT DISTINCT k"
  74.                      + " FROM   Kunde k LEFT JOIN FETCH k.bestellungen"
  75.                      + " WHERE  k.name= :" + Kunde.PARAM_KUNDE_NACHNAME),
  76.                      
  77.     @NamedQuery(name  = Kunde.FIND_KUNDEN_FETCH_BESTELLUNGEN,
  78.                 query = "SELECT  DISTINCT k"
  79.                 + " FROM Kunde k LEFT JOIN FETCH k.bestellungen"),
  80.                    
  81.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_IDKUNDEFETCHBESTELLUNG,
  82.               query = "SELECT DISTINCT k"
  83.                    + " FROM   Kunde k LEFT JOIN FETCH k.bestellungen"
  84.                    + " WHERE  k.idKunde = :" + Kunde.PARAM_KUNDE_IDKUNDE),
  85.                    
  86.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_PLZ,
  87.                 query = "Select  k"
  88.                      + " From Kunde k"
  89.                      + " Left Join Fetch k.anschrift"
  90.                      + " Where k.anschrift.plz=:" + Kunde.PARAM_KUNDE_PLZ),
  91.                    
  92.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_RABATT,
  93.                 query = "Select  k"
  94.                     + " From Kunde k"
  95.                     + " Where k.kundenrabatt>=:" + Kunde.PARAM_KUNDE_RABATT),
  96.                    
  97.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_KEINEBESTELLUNG,
  98.                 query = "Select k"
  99.                      + " From Kunde k"
  100.                      + " Where k NOT IN (Select kk From Kunde kk,Bestellung b "
  101.                                      + " Where kk.idKunde=b.kunde)"),
  102.                            
  103.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_LOGINNAME,
  104.                 query = "Select k"
  105.                      + " From Kunde k"
  106.                      + " Where k.loginname=:" + Kunde.PARAM_KUNDE_LOGINNAME),
  107.    
  108.     @NamedQuery(name = Kunde.FIND_KUNDE_BY_EMAIL,
  109.                 query = "Select k "
  110.                         + "From Kunde k "
  111.                         + "Where k.email=:" + Kunde.PARAM_KUNDE_EMAIL),
  112.                        
  113.     @NamedQuery(name  = Kunde.FIND_NACHNAMEN_BY_PREFIX,
  114.                 query = "SELECT   DISTINCT k.name"
  115.                         + " FROM  Kunde k "
  116.                         + " WHERE UPPER(k.name) LIKE UPPER(:"
  117.                         + Kunde.PARAM_KUNDE_NACHNAME_PREFIX + ")"),
  118.  
  119.     @NamedQuery(name  = Kunde.FIND_KUNDEN_BY_ID_PREFIX,
  120.                 query = "SELECT   k"
  121.                         + " FROM  Kunde as k"
  122.                         + " WHERE CONCAT('', k.id) LIKE :" + Kunde.PARAM_KUNDE_ID_PREFIX
  123.                         + " ORDER BY k.id"),
  124.                        
  125.     @NamedQuery(name  = Kunde.FIND_ALL_NACHNAMEN,
  126.                 query = "SELECT      DISTINCT k.name"
  127.                        + " FROM     Kunde k"
  128.                        + " ORDER BY k.name")
  129. })
  130.  
  131. @XmlRootElement
  132. @XmlAccessorType(FIELD)
  133. public class Kunde implements Serializable {
  134.    
  135.     /** The Constant serialVersionUID. */
  136.     private static final long serialVersionUID = 1L;
  137.    
  138.     /** Konstante fuer die Beanvalidation. */
  139.     private static final String NAME_PATTERN = "[A-Z\u00C4\u00D6\u00DC][a-z\u00E4\u00F6\u00FC\u00DF]+";
  140.    
  141.     /** The Constant NACHNAME_PATTERN. */
  142.     public static final String NACHNAME_PATTERN = NAME_PATTERN + "(-" + NAME_PATTERN + ")?";
  143.    
  144.     /** The Constant GESCHLECHT_PATTERN. */
  145.     public static final String GESCHLECHT_PATTERN = "(w|m)?";
  146.    
  147.     /** The Constant NACHNAME_LENGTH_MIN. */
  148.     public static final int NACHNAME_LENGTH_MIN = 2;
  149.    
  150.     /** The Constant NACHNAME_LENGTH_MAX. */
  151.     public static final int NACHNAME_LENGTH_MAX = 32;
  152.    
  153.     /** The Constant VORNAME_LENGTH_MAX. */
  154.     public static final int VORNAME_LENGTH_MAX = 32;
  155.    
  156.     /** The Constant EMAIL_LENGTH_MAX. */
  157.     public static final int EMAIL_LENGTH_MAX = 128;
  158.    
  159.     /** The Constant PASSWORD_LENGTH_MAX. */
  160.     public static final int PASSWORD_LENGTH_MAX = 25;
  161.    
  162.     /** The Constant MIN_ID. */
  163.     public static final int MIN_ID = 0;
  164.    
  165.     /** The Constant LOGINNAME_LENGTH_MAX. */
  166.     public static final int LOGINNAME_LENGTH_MAX = 30;
  167.    
  168.     /** The Constant LOGINNAME_LENGTH_MIN. */
  169.     public static final int LOGINNAME_LENGTH_MIN = 2;
  170.    
  171.     /** The Constant PASSWORD_LENGTH_MIN. */
  172.     public static final int PASSWORD_LENGTH_MIN = 5;
  173.    
  174.     /** String-Konstanten fuer die @Named-Queries. */
  175.     public static final String PREFIX = "Kunde.";
  176.    
  177.     /** The Constant FIND_KUNDE. */
  178.     public static final String FIND_KUNDE = PREFIX + "findKunden";
  179.    
  180.     /** The Constant FIND_KUNDE_BY_NACHNAME. */
  181.     public static final String FIND_KUNDE_BY_NACHNAME = FIND_KUNDE  + ".byNachname";
  182.    
  183.     /** The Constant FIND_KUNDE_BY_ID. */
  184.     public static final String FIND_KUNDE_BY_ID = FIND_KUNDE  + ".byId";
  185.    
  186.     /** The Constant FIND_KUNDE_BY_VORNAMEANDNACHNAME. */
  187.     public static final String FIND_KUNDE_BY_VORNAMEANDNACHNAME = FIND_KUNDE  + ".byVornameUndVorname";
  188.    
  189.     /** The Constant FIND_KUNDE_BY_NACHNAMEFETCHBESTELLUNG. */
  190.     public static final String FIND_KUNDE_BY_NACHNAMEFETCHBESTELLUNG = FIND_KUNDE  + ".byNachnameFetchBestellung";
  191.    
  192.     /** The Constant FIND_KUNDE_BY_IDKUNDEFETCHBESTELLUNG. */
  193.     public static final String FIND_KUNDE_BY_IDKUNDEFETCHBESTELLUNG = FIND_KUNDE  + ".byIdFetchBestellung";
  194.    
  195.     /** The Constant FIND_KUNDEN_FETCH_BESTELLUNGEN. */
  196.     public static final String FIND_KUNDEN_FETCH_BESTELLUNGEN = FIND_KUNDE + ".fetchBestellungen";
  197.    
  198.     /** The Constant FIND_KUNDE_BY_PLZ. */
  199.     public static final String FIND_KUNDE_BY_PLZ = FIND_KUNDE  + ".byPlz";
  200.    
  201.     /** The Constant FIND_KUNDE_BY_RABATT. */
  202.     public static final String FIND_KUNDE_BY_RABATT = FIND_KUNDE  + ".byRabatt";
  203.    
  204.     /** The Constant FIND_KUNDE_BY_KEINEBESTELLUNG. */
  205.     public static final String FIND_KUNDE_BY_KEINEBESTELLUNG = FIND_KUNDE  + ".byKeineBestellung";
  206.    
  207.     /** The Constant FIND_KUNDE_BY_LOGINNAMEANDPASSWORD. */
  208.     public static final String FIND_KUNDE_BY_LOGINNAME = FIND_KUNDE  + ".byLoginnname";
  209.    
  210.     /** The Constant FIND_KUNDE_BY_EMAIL. */
  211.     public static final String FIND_KUNDE_BY_EMAIL = FIND_KUNDE + ".byEmail";
  212.    
  213.     public static final String FIND_NACHNAMEN_BY_PREFIX = PREFIX + "findNachnamenByPrefix";
  214.    
  215.     public static final String FIND_KUNDEN_BY_ID_PREFIX = PREFIX + "findKundenByIdPrefix";
  216.    
  217.     public static final String FIND_ALL_NACHNAMEN = PREFIX + "findAllNachnamen";
  218.    
  219.     /** Parameter fuer die @Named-Queries. */
  220.     public static final String PARAM_KUNDE_IDKUNDE = "kundeId";
  221.    
  222.     /** The Constant PARAM_KUNDE_NACHNAME. */
  223.     public static final String PARAM_KUNDE_NACHNAME = "kundeNachname";
  224.    
  225.     /** The Constant PARAM_KUNDE_VORNAME. */
  226.     public static final String PARAM_KUNDE_VORNAME = "kundeVorname";
  227.    
  228.     /** The Constant PARAM_KUNDE_PLZ. */
  229.     public static final String PARAM_KUNDE_PLZ = "kundePlz";
  230.    
  231.     /** The Constant PARAM_KUNDE_RABATT. */
  232.     public static final String PARAM_KUNDE_RABATT = "kundeRabatt";
  233.    
  234.     /** The Constant PARAM_KUNDE_LOGINNAME. */
  235.     public static final String PARAM_KUNDE_LOGINNAME = "kundeLoginname";
  236.    
  237.     /** The Constant PARAM_KUNDE_PASSWORD. */
  238.     public static final String PARAM_KUNDE_PASSWORD = "kundePassword";
  239.    
  240.     /** The Constant PARAM_KUNDE_EMAIL. */
  241.     public static final String PARAM_KUNDE_EMAIL = "kundeEmail";
  242.    
  243.     public static final String PARAM_KUNDE_ID_PREFIX = "idPrefix";
  244.    
  245.     public static final String PARAM_KUNDE_NACHNAME_PREFIX = "nachnamePrefix";
  246.    
  247.     private static final int ERSTE_VERSION = 0;
  248.  
  249.    
  250.     /** The id kunde. */
  251.     @Id
  252.     @GeneratedValue(strategy = GenerationType.AUTO)
  253.     @Column(name = "id_kunde")
  254.     @Min(value = MIN_ID, message = "{kundenverwaltung.kunde.id.min}", groups = IdGroup.class)
  255.     @XmlAttribute(name = "id", required = true)
  256.     private int idKunde;
  257.  
  258.     /** The email. */
  259.     @Column(length = EMAIL_LENGTH_MAX, nullable = false, unique = true)
  260.     @NotNull(message = "{kundenverwaltung.kunde.email.notNull}")
  261.     @Email(message = "{kundenverwaltung.kunde.email.pattern}")
  262.     private String email;
  263.  
  264.     /** The firmenname. */
  265.     private String firmenname;
  266.    
  267.     /** The geschlecht. */
  268.     @Pattern(regexp = GESCHLECHT_PATTERN, message = "(kundenverwaltung.kunde.geschlecht.Pattern")
  269.     private String geschlecht;
  270.  
  271.     /** The kundenrabatt. */
  272.     @Column(nullable = false)
  273.     private float kundenrabatt;
  274.    
  275.     /** The loginname. */
  276.     @Column(length = LOGINNAME_LENGTH_MAX)
  277.     @NotNull(message = "{kundenverwaltung.kunde.loginname.notNull}")
  278.     @Size(min = LOGINNAME_LENGTH_MIN, max = LOGINNAME_LENGTH_MAX, message = "{kundenverwaltung.kunde.loginname.legth")
  279.     private String loginname;
  280.    
  281.     /** The name. */
  282.     @Column(length = NACHNAME_LENGTH_MAX)
  283.     @NotNull(message = "{kundenverwaltung.kunde.nachname.notNull}")
  284.     @Size(min = NACHNAME_LENGTH_MIN, max = NACHNAME_LENGTH_MAX, message = "{kundenverwaltung.kunde.nachname.length}")
  285.     @Pattern(regexp = NACHNAME_PATTERN, message = "{kundenverwaltung.kunde.nachname.pattern}")
  286.     @XmlElement(required = true)
  287.     private String name;
  288.  
  289.     /** The password. */
  290.     @Column(length = PASSWORD_LENGTH_MAX)
  291.     @Size(min = PASSWORD_LENGTH_MIN, message = "(kundenverwaltung.kunde.password.length)")
  292.     private String password;
  293.  
  294.     /** The telefonnummer. */
  295.     private String telefonnummer;
  296.    
  297.     /** The vorname. */
  298.     @Column(length = VORNAME_LENGTH_MAX)
  299.     @Size(max = VORNAME_LENGTH_MAX, message = "{kundenverwaltung.kunde.vorname.length}")
  300.     private String vorname;
  301.  
  302.     //bi-directional many-to-one association to Bestellung
  303.     /** The bestellungen. */
  304.     @OneToMany(mappedBy = "kunde")
  305.     @XmlTransient
  306.     private List<Bestellung> bestellungen;
  307.    
  308.     /** The bestellungen uris. */
  309.     @Transient
  310.     @XmlElementWrapper(name = "bestellungen")
  311.     @XmlElement(name = "bestellung")
  312.     private List<URI> bestellungenUris;
  313.  
  314.     //bi-directional many-to-one association to Anschrift
  315.     /** The anschrift. */
  316.     @ManyToOne(fetch = FetchType.EAGER, cascade = { PERSIST, REMOVE })
  317.     @Embedded
  318.     @Valid
  319.     @NotNull(message = "{kundenverwaltung.kunde.adresse.notNull}")
  320.     private Anschrift anschrift = new Anschrift();
  321.    
  322.     @Version
  323.     @XmlTransient
  324.     private int version = ERSTE_VERSION;
  325.    
  326.  
  327.     /**
  328.      * Instantiates a new kunde.
  329.      */
  330.     public Kunde() {
  331.     }
  332.  
  333.     /**
  334.      * Gets the id kunde.
  335.      *
  336.      * @return the id kunde
  337.      */
  338.     public int getIdKunde() {
  339.         return this.idKunde;
  340.     }
  341.  
  342.     /**
  343.      * Sets the id kunde.
  344.      *
  345.      * @param idKunde the new id kunde
  346.      */
  347.     public void setIdKunde(int idKunde) {
  348.         this.idKunde = idKunde;
  349.     }
  350.  
  351.     /**
  352.      * Gets the email.
  353.      *
  354.      * @return the email
  355.      */
  356.     public String getEmail() {
  357.         return this.email;
  358.     }
  359.  
  360.     /**
  361.      * Sets the email.
  362.      *
  363.      * @param email the new email
  364.      */
  365.     public void setEmail(String email) {
  366.         this.email = email;
  367.     }
  368.  
  369.     /**
  370.      * Gets the firmenname.
  371.      *
  372.      * @return the firmenname
  373.      */
  374.     public String getFirmenname() {
  375.         return this.firmenname;
  376.     }
  377.  
  378.     /**
  379.      * Sets the firmenname.
  380.      *
  381.      * @param firmenname the new firmenname
  382.      */
  383.     public void setFirmenname(String firmenname) {
  384.         this.firmenname = firmenname;
  385.     }
  386.  
  387.     /**
  388.      * Gets the geschlecht.
  389.      *
  390.      * @return the geschlecht
  391.      */
  392.     public String getGeschlecht() {
  393.         return this.geschlecht;
  394.     }
  395.  
  396.     /**
  397.      * Sets the geschlecht.
  398.      *
  399.      * @param geschlecht the new geschlecht
  400.      */
  401.     public void setGeschlecht(String geschlecht) {
  402.         this.geschlecht = geschlecht;
  403.     }
  404.  
  405.     /**
  406.      * Gets the kundenrabatt.
  407.      *
  408.      * @return the kundenrabatt
  409.      */
  410.     public float getKundenrabatt() {
  411.         return this.kundenrabatt;
  412.     }
  413.  
  414.     /**
  415.      * Sets the kundenrabatt.
  416.      *
  417.      * @param kundenrabatt the new kundenrabatt
  418.      */
  419.     public void setKundenrabatt(float kundenrabatt) {
  420.         this.kundenrabatt = kundenrabatt;
  421.     }
  422.  
  423.     /**
  424.      * Gets the loginname.
  425.      *
  426.      * @return the loginname
  427.      */
  428.     public String getLoginname() {
  429.         return this.loginname;
  430.     }
  431.  
  432.     /**
  433.      * Sets the loginname.
  434.      *
  435.      * @param loginname the new loginname
  436.      */
  437.     public void setLoginname(String loginname) {
  438.         this.loginname = loginname;
  439.     }
  440.  
  441.     /**
  442.      * Gets the name.
  443.      *
  444.      * @return the name
  445.      */
  446.     public String getName() {
  447.         return this.name;
  448.     }
  449.  
  450.     /**
  451.      * Sets the name.
  452.      *
  453.      * @param name the new name
  454.      */
  455.     public void setName(String name) {
  456.         this.name = name;
  457.     }
  458.  
  459.     /**
  460.      * Gets the password.
  461.      *
  462.      * @return the password
  463.      */
  464.     public String getPassword() {
  465.         return this.password;
  466.     }
  467.  
  468.     /**
  469.      * Sets the password.
  470.      *
  471.      * @param password the new password
  472.      */
  473.     public void setPassword(String password) {
  474.         this.password = password;
  475.     }
  476.  
  477.     /**
  478.      * Gets the telefonnummer.
  479.      *
  480.      * @return the telefonnummer
  481.      */
  482.     public String getTelefonnummer() {
  483.         return this.telefonnummer;
  484.     }
  485.  
  486.     /**
  487.      * Sets the telefonnummer.
  488.      *
  489.      * @param telefonnummer the new telefonnummer
  490.      */
  491.     public void setTelefonnummer(String telefonnummer) {
  492.         this.telefonnummer = telefonnummer;
  493.     }
  494.  
  495.     /**
  496.      * Gets the vorname.
  497.      *
  498.      * @return the vorname
  499.      */
  500.     public String getVorname() {
  501.         return this.vorname;
  502.     }
  503.  
  504.     /**
  505.      * Sets the vorname.
  506.      *
  507.      * @param vorname the new vorname
  508.      */
  509.     public void setVorname(String vorname) {
  510.         this.vorname = vorname;
  511.     }
  512.  
  513.     /**
  514.      * Gets the bestellungen.
  515.      *
  516.      * @return the bestellungen
  517.      */
  518.     public List<Bestellung> getBestellungen() {
  519.         return this.bestellungen;
  520.     }
  521.  
  522.     /**
  523.      * Sets the bestellungen.
  524.      *
  525.      * @param bestellungs the new bestellungen
  526.      */
  527.     public void setBestellungen(List<Bestellung> bestellungs) {
  528.         this.bestellungen = bestellungs;
  529.     }
  530.    
  531.     /**
  532.      * Adds the bestellung.
  533.      *
  534.      * @param bestellung the bestellung
  535.      */
  536.     public void addBestellung(Bestellung bestellung) {
  537.         if (bestellungen == null) {
  538.             bestellungen = new ArrayList<Bestellung>();
  539.         }
  540.         bestellungen.add(bestellung);
  541.     }
  542.    
  543.     /**
  544.      * Gets the anschrift.
  545.      *
  546.      * @return the anschrift
  547.      */
  548.     public Anschrift getAnschrift() {
  549.         return this.anschrift;
  550.     }
  551.  
  552.     /**
  553.      * Sets the anschrift.
  554.      *
  555.      * @param anschrift the new anschrift
  556.      */
  557.     public void setAnschrift(Anschrift anschrift) {
  558.         this.anschrift = anschrift;
  559.     }
  560.  
  561.     /**
  562.      * Sets the bestellungen uris.
  563.      *
  564.      * @param bestellungenUris the new bestellungen uris
  565.      */
  566.     public void setBestellungenUris(List<URI> bestellungenUris) {
  567.         this.bestellungenUris = bestellungenUris;
  568.     }
  569.  
  570.     /**
  571.      * Gets the bestellungen uris.
  572.      *
  573.      * @return the bestellungen uris
  574.      */
  575.     public List<URI> getBestellungenUris() {
  576.         return bestellungenUris;
  577.     }
  578.  
  579.     public void setVersion(int version) {
  580.         this.version = version;
  581.     }
  582.  
  583.     public int getVersion() {
  584.         return version;
  585.     }
  586.  
  587.     /**
  588.      * Sets the values.
  589.      *
  590.      * @param k the new values
  591.      */
  592.     public void setValues(Kunde k) {
  593.         name = k.name;
  594.         vorname = k.vorname;
  595.         geschlecht = k.geschlecht;
  596.         kundenrabatt = k.kundenrabatt;
  597.         telefonnummer = k.telefonnummer;
  598.         firmenname = k.firmenname;
  599.         loginname = k.loginname;
  600.         email = k.email;
  601.         password = k.password;
  602.         version = k.version;
  603.        
  604.     }
  605.  
  606.     /* (non-Javadoc)
  607.      * @see java.lang.Object#hashCode()
  608.      */
  609.     @Override
  610.     public int hashCode() {
  611.         final int prime = 31;
  612.         int result = 1;
  613.         result = prime * result + ((email == null) ? 0 : email.hashCode());
  614.         result = prime * result + ((name == null) ? 0 : name.hashCode());
  615.         result = prime * result + ((vorname == null) ? 0 : vorname.hashCode());
  616.         return result;
  617.     }
  618.  
  619.     /* (non-Javadoc)
  620.      * @see java.lang.Object#equals(java.lang.Object)
  621.      */
  622.     @Override
  623.     public boolean equals(Object obj) {
  624.         if (this == obj) {
  625.             return true;
  626.         }
  627.         if (obj == null) {
  628.             return false;
  629.         }
  630.         if (getClass() != obj.getClass()) {
  631.             return false;
  632.         }
  633.         Kunde other = (Kunde) obj;
  634.         if (email == null) {
  635.             if (other.email != null) {
  636.                 return false;
  637.             }
  638.         }
  639.         else if (!email.equals(other.email)) {
  640.             return false;
  641.         }
  642.         if (name == null) {
  643.             if (other.name != null) {
  644.                 return false;
  645.             }
  646.         }
  647.         else if (!name.equals(other.name)) {
  648.             return false;
  649.         }
  650.         if (vorname == null) {
  651.             if (other.vorname != null) {
  652.                 return false;
  653.             }
  654.         }
  655.         else if (!vorname.equals(other.vorname)) {
  656.             return false;
  657.         }
  658.         return true;
  659.     }
  660.  
  661.     /* (non-Javadoc)
  662.      * @see java.lang.Object#toString()
  663.      */
  664.     @Override
  665.     public String toString() {
  666.         return "Kunde [idKunde=" + idKunde + ", email=" + email
  667.                 + ", firmenname=" + firmenname + ", geschlecht=" + geschlecht
  668.                 + ", kundenrabatt=" + kundenrabatt + ", loginname=" + loginname
  669.                 + ", name=" + name + ", password=" + password
  670.                 + ", telefonnummer=" + telefonnummer + ", vorname=" + vorname
  671.                 + ", bestellungen=" + bestellungen + ", anschrift=" + anschrift
  672.                 + "]";
  673.     }
  674.    
  675. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement