Skip to content

Commit

Permalink
Apply spring-format plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Jan 3, 2020
1 parent 82cb521 commit 4e1f874
Show file tree
Hide file tree
Showing 36 changed files with 1,249 additions and 1,289 deletions.
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<wro4j.version>1.8.0</wro4j.version>

<jacoco.version>0.8.5</jacoco.version>
<spring-format.version>0.0.17</spring-format.version>

</properties>

Expand Down Expand Up @@ -130,6 +131,20 @@

<build>
<plugins>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring-format.version}</version>
<!-- run ./mvnw spring-javaformat:apply to apply -->
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
@SpringBootApplication(proxyBeanMethods = false)
public class PetClinicApplication {

public static void main(String[] args) {
SpringApplication.run(PetClinicApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(PetClinicApplication.class, args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@
*/
@MappedSuperclass
public class BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

public Integer getId() {
return id;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}

public boolean isNew() {
return this.id == null;
}
public void setId(Integer id) {
this.id = id;
}

public boolean isNew() {
return this.id == null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,30 @@
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;


/**
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as a base class for objects
* needing these properties.
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as
* a base class for objects needing these properties.
*
* @author Ken Krebs
* @author Juergen Hoeller
*/
@MappedSuperclass
public class NamedEntity extends BaseEntity {

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

public String getName() {
return this.name;
}
public String getName() {
return this.name;
}

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

@Override
public String toString() {
return this.getName();
}
@Override
public String toString() {
return this.getName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@
@MappedSuperclass
public class Person extends BaseEntity {

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

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

public String getFirstName() {
return this.firstName;
}
public String getFirstName() {
return this.firstName;
}

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

public String getLastName() {
return this.lastName;
}
public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
* The classes in this package represent utilities used by the domain.
*/
package org.springframework.samples.petclinic.model;

206 changes: 102 additions & 104 deletions src/main/java/org/springframework/samples/petclinic/owner/Owner.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,108 +45,106 @@
@Entity
@Table(name = "owners")
public class Owner extends Person {
@Column(name = "address")
@NotEmpty
private String address;

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

@Column(name = "telephone")
@NotEmpty
@Digits(fraction = 0, integer = 10)
private String telephone;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
private Set<Pet> pets;

public String getAddress() {
return this.address;
}

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

public String getCity() {
return this.city;
}

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

public String getTelephone() {
return this.telephone;
}

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

protected Set<Pet> getPetsInternal() {
if (this.pets == null) {
this.pets = new HashSet<>();
}
return this.pets;
}

protected void setPetsInternal(Set<Pet> pets) {
this.pets = pets;
}

public List<Pet> getPets() {
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
PropertyComparator.sort(sortedPets,
new MutableSortDefinition("name", true, true));
return Collections.unmodifiableList(sortedPets);
}

public void addPet(Pet pet) {
if (pet.isNew()) {
getPetsInternal().add(pet);
}
pet.setOwner(this);
}

/**
* Return the Pet with the given name, or null if none found for this Owner.
*
* @param name to test
* @return true if pet name is already in use
*/
public Pet getPet(String name) {
return getPet(name, false);
}

/**
* Return the Pet with the given name, or null if none found for this Owner.
*
* @param name to test
* @return true if pet name is already in use
*/
public Pet getPet(String name, boolean ignoreNew) {
name = name.toLowerCase();
for (Pet pet : getPetsInternal()) {
if (!ignoreNew || !pet.isNew()) {
String compName = pet.getName();
compName = compName.toLowerCase();
if (compName.equals(name)) {
return pet;
}
}
}
return null;
}

@Override
public String toString() {
return new ToStringCreator(this)

.append("id", this.getId()).append("new", this.isNew())
.append("lastName", this.getLastName())
.append("firstName", this.getFirstName()).append("address", this.address)
.append("city", this.city).append("telephone", this.telephone).toString();
}

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

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

@Column(name = "telephone")
@NotEmpty
@Digits(fraction = 0, integer = 10)
private String telephone;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
private Set<Pet> pets;

public String getAddress() {
return this.address;
}

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

public String getCity() {
return this.city;
}

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

public String getTelephone() {
return this.telephone;
}

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

protected Set<Pet> getPetsInternal() {
if (this.pets == null) {
this.pets = new HashSet<>();
}
return this.pets;
}

protected void setPetsInternal(Set<Pet> pets) {
this.pets = pets;
}

public List<Pet> getPets() {
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
return Collections.unmodifiableList(sortedPets);
}

public void addPet(Pet pet) {
if (pet.isNew()) {
getPetsInternal().add(pet);
}
pet.setOwner(this);
}

/**
* Return the Pet with the given name, or null if none found for this Owner.
* @param name to test
* @return true if pet name is already in use
*/
public Pet getPet(String name) {
return getPet(name, false);
}

/**
* Return the Pet with the given name, or null if none found for this Owner.
* @param name to test
* @return true if pet name is already in use
*/
public Pet getPet(String name, boolean ignoreNew) {
name = name.toLowerCase();
for (Pet pet : getPetsInternal()) {
if (!ignoreNew || !pet.isNew()) {
String compName = pet.getName();
compName = compName.toLowerCase();
if (compName.equals(name)) {
return pet;
}
}
}
return null;
}

@Override
public String toString() {
return new ToStringCreator(this)

.append("id", this.getId()).append("new", this.isNew()).append("lastName", this.getLastName())
.append("firstName", this.getFirstName()).append("address", this.address).append("city", this.city)
.append("telephone", this.telephone).toString();
}

}
Loading

0 comments on commit 4e1f874

Please sign in to comment.