Skip to content

Commit

Permalink
Added Project Lombok to project, closes springframeworkguru#51
Browse files Browse the repository at this point in the history
  • Loading branch information
springframeworkguru committed Aug 7, 2018
1 parent 036baac commit f6a7c34
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 132 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package guru.springframework.sfgpetclinic.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
Expand All @@ -9,18 +14,15 @@
/**
* Created by jt on 7/18/18.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
public class BaseEntity implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
package guru.springframework.sfgpetclinic.model;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
* Created by jt on 7/13/18.
*/
@Setter
@Getter
@NoArgsConstructor
@Entity
@Table(name = "owners")
public class Owner extends Person {

@Builder
public Owner(Long id, String firstName, String lastName, String address, String city,
String telephone, Set<Pet> pets) {
super(id, firstName, lastName);
this.address = address;
this.city = city;
this.telephone = telephone;
this.pets = pets;
}

@Column(name = "address")
private String address;

Expand All @@ -23,35 +41,4 @@ public class Owner extends Person {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
private Set<Pet> pets = new HashSet<>();

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public String getTelephone() {
return telephone;
}

public void setTelephone(String telephone) {
this.telephone = telephone;
}

public Set<Pet> getPets() {
return pets;
}

public void setPets(Set<Pet> pets) {
this.pets = pets;
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
package guru.springframework.sfgpetclinic.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

/**
* Created by jt on 7/13/18.
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@MappedSuperclass
public class Person extends BaseEntity {

public Person(Long id, String firstName, String lastName) {
super(id);
this.firstName = firstName;
this.lastName = lastName;
}

@Column(name = "first_name")
private String firstName;

@Column(name = "last_name")
private String lastName;

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package guru.springframework.sfgpetclinic.model;

import lombok.*;

import javax.persistence.*;
import java.time.LocalDate;
import java.util.HashSet;
Expand All @@ -8,6 +10,11 @@
/**
* Created by jt on 7/13/18.
*/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "pets")
public class Pet extends BaseEntity{
Expand All @@ -29,43 +36,4 @@ public class Pet extends BaseEntity{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet")
private Set<Visit> vists = new HashSet<>();

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public PetType getPetType() {
return petType;
}

public void setPetType(PetType petType) {
this.petType = petType;
}

public Owner getOwner() {
return owner;
}

public void setOwner(Owner owner) {
this.owner = owner;
}

public LocalDate getBirthDate() {
return birthDate;
}

public void setBirthDate(LocalDate birthDate) {
this.birthDate = birthDate;
}

public Set<Visit> getVists() {
return vists;
}

public void setVists(Set<Visit> vists) {
this.vists = vists;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package guru.springframework.sfgpetclinic.model;

import lombok.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
* Created by jt on 7/13/18.
*/

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "types")
public class PetType extends BaseEntity {

@Column(name = "name")
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package guru.springframework.sfgpetclinic.model;

import lombok.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
* Created by jt on 7/29/18.
*/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "specialties")
public class Speciality extends BaseEntity {

@Column(name = "description")
private String description;

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package guru.springframework.sfgpetclinic.model;

import lombok.*;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
* Created by jt on 7/13/18.
*/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "vets")
public class Vet extends Person {
Expand All @@ -16,11 +23,4 @@ public class Vet extends Person {
inverseJoinColumns = @JoinColumn(name = "speciality_id"))
private Set<Speciality> specialities = new HashSet<>();

public Set<Speciality> getSpecialities() {
return specialities;
}

public void setSpecialities(Set<Speciality> specialities) {
this.specialities = specialities;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package guru.springframework.sfgpetclinic.model;

import lombok.*;

import javax.persistence.*;
import java.time.LocalDate;

/**
* Created by jt on 7/29/18.
*/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "visits")
public class Visit extends BaseEntity {
Expand All @@ -24,23 +31,4 @@ public LocalDate getDate() {
return date;
}

public void setDate(LocalDate date) {
this.date = date;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public Pet getPet() {
return pet;
}

public void setPet(Pet pet) {
this.pet = pet;
}
}
6 changes: 6 additions & 0 deletions pet-clinic-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!--<dependency>-->
<!--<groupId>org.projectlombok</groupId>-->
<!--<artifactId>lombok</artifactId>-->
<!--<optional>true</optional>-->
<!--</dependency>-->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand Down

0 comments on commit f6a7c34

Please sign in to comment.