Skip to content

Commit 4e1f874

Browse files
committed
Apply spring-format plugin
1 parent 82cb521 commit 4e1f874

36 files changed

+1249
-1289
lines changed

pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<wro4j.version>1.8.0</wro4j.version>
2929

3030
<jacoco.version>0.8.5</jacoco.version>
31+
<spring-format.version>0.0.17</spring-format.version>
3132

3233
</properties>
3334

@@ -130,6 +131,20 @@
130131

131132
<build>
132133
<plugins>
134+
<plugin>
135+
<groupId>io.spring.javaformat</groupId>
136+
<artifactId>spring-javaformat-maven-plugin</artifactId>
137+
<version>${spring-format.version}</version>
138+
<!-- run ./mvnw spring-javaformat:apply to apply -->
139+
<executions>
140+
<execution>
141+
<phase>validate</phase>
142+
<goals>
143+
<goal>validate</goal>
144+
</goals>
145+
</execution>
146+
</executions>
147+
</plugin>
133148
<plugin>
134149
<groupId>org.springframework.boot</groupId>
135150
<artifactId>spring-boot-maven-plugin</artifactId>

src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
@SpringBootApplication(proxyBeanMethods = false)
2929
public class PetClinicApplication {
3030

31-
public static void main(String[] args) {
32-
SpringApplication.run(PetClinicApplication.class, args);
33-
}
31+
public static void main(String[] args) {
32+
SpringApplication.run(PetClinicApplication.class, args);
33+
}
3434

3535
}

src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@
3131
*/
3232
@MappedSuperclass
3333
public class BaseEntity implements Serializable {
34-
@Id
35-
@GeneratedValue(strategy = GenerationType.IDENTITY)
36-
private Integer id;
3734

38-
public Integer getId() {
39-
return id;
40-
}
35+
@Id
36+
@GeneratedValue(strategy = GenerationType.IDENTITY)
37+
private Integer id;
4138

42-
public void setId(Integer id) {
43-
this.id = id;
44-
}
39+
public Integer getId() {
40+
return id;
41+
}
4542

46-
public boolean isNew() {
47-
return this.id == null;
48-
}
43+
public void setId(Integer id) {
44+
this.id = id;
45+
}
46+
47+
public boolean isNew() {
48+
return this.id == null;
49+
}
4950

5051
}

src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,30 @@
1818
import javax.persistence.Column;
1919
import javax.persistence.MappedSuperclass;
2020

21-
2221
/**
23-
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as a base class for objects
24-
* needing these properties.
22+
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as
23+
* a base class for objects needing these properties.
2524
*
2625
* @author Ken Krebs
2726
* @author Juergen Hoeller
2827
*/
2928
@MappedSuperclass
3029
public class NamedEntity extends BaseEntity {
3130

32-
@Column(name = "name")
33-
private String name;
31+
@Column(name = "name")
32+
private String name;
3433

35-
public String getName() {
36-
return this.name;
37-
}
34+
public String getName() {
35+
return this.name;
36+
}
3837

39-
public void setName(String name) {
40-
this.name = name;
41-
}
38+
public void setName(String name) {
39+
this.name = name;
40+
}
4241

43-
@Override
44-
public String toString() {
45-
return this.getName();
46-
}
42+
@Override
43+
public String toString() {
44+
return this.getName();
45+
}
4746

4847
}

src/main/java/org/springframework/samples/petclinic/model/Person.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@
2727
@MappedSuperclass
2828
public class Person extends BaseEntity {
2929

30-
@Column(name = "first_name")
31-
@NotEmpty
32-
private String firstName;
30+
@Column(name = "first_name")
31+
@NotEmpty
32+
private String firstName;
3333

34-
@Column(name = "last_name")
35-
@NotEmpty
36-
private String lastName;
34+
@Column(name = "last_name")
35+
@NotEmpty
36+
private String lastName;
3737

38-
public String getFirstName() {
39-
return this.firstName;
40-
}
38+
public String getFirstName() {
39+
return this.firstName;
40+
}
4141

42-
public void setFirstName(String firstName) {
43-
this.firstName = firstName;
44-
}
42+
public void setFirstName(String firstName) {
43+
this.firstName = firstName;
44+
}
4545

46-
public String getLastName() {
47-
return this.lastName;
48-
}
46+
public String getLastName() {
47+
return this.lastName;
48+
}
4949

50-
public void setLastName(String lastName) {
51-
this.lastName = lastName;
52-
}
50+
public void setLastName(String lastName) {
51+
this.lastName = lastName;
52+
}
5353

5454
}

src/main/java/org/springframework/samples/petclinic/model/package-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@
1818
* The classes in this package represent utilities used by the domain.
1919
*/
2020
package org.springframework.samples.petclinic.model;
21-

src/main/java/org/springframework/samples/petclinic/owner/Owner.java

Lines changed: 102 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -45,108 +45,106 @@
4545
@Entity
4646
@Table(name = "owners")
4747
public class Owner extends Person {
48-
@Column(name = "address")
49-
@NotEmpty
50-
private String address;
51-
52-
@Column(name = "city")
53-
@NotEmpty
54-
private String city;
55-
56-
@Column(name = "telephone")
57-
@NotEmpty
58-
@Digits(fraction = 0, integer = 10)
59-
private String telephone;
60-
61-
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
62-
private Set<Pet> pets;
63-
64-
public String getAddress() {
65-
return this.address;
66-
}
67-
68-
public void setAddress(String address) {
69-
this.address = address;
70-
}
71-
72-
public String getCity() {
73-
return this.city;
74-
}
75-
76-
public void setCity(String city) {
77-
this.city = city;
78-
}
79-
80-
public String getTelephone() {
81-
return this.telephone;
82-
}
83-
84-
public void setTelephone(String telephone) {
85-
this.telephone = telephone;
86-
}
87-
88-
protected Set<Pet> getPetsInternal() {
89-
if (this.pets == null) {
90-
this.pets = new HashSet<>();
91-
}
92-
return this.pets;
93-
}
94-
95-
protected void setPetsInternal(Set<Pet> pets) {
96-
this.pets = pets;
97-
}
98-
99-
public List<Pet> getPets() {
100-
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
101-
PropertyComparator.sort(sortedPets,
102-
new MutableSortDefinition("name", true, true));
103-
return Collections.unmodifiableList(sortedPets);
104-
}
105-
106-
public void addPet(Pet pet) {
107-
if (pet.isNew()) {
108-
getPetsInternal().add(pet);
109-
}
110-
pet.setOwner(this);
111-
}
112-
113-
/**
114-
* Return the Pet with the given name, or null if none found for this Owner.
115-
*
116-
* @param name to test
117-
* @return true if pet name is already in use
118-
*/
119-
public Pet getPet(String name) {
120-
return getPet(name, false);
121-
}
122-
123-
/**
124-
* Return the Pet with the given name, or null if none found for this Owner.
125-
*
126-
* @param name to test
127-
* @return true if pet name is already in use
128-
*/
129-
public Pet getPet(String name, boolean ignoreNew) {
130-
name = name.toLowerCase();
131-
for (Pet pet : getPetsInternal()) {
132-
if (!ignoreNew || !pet.isNew()) {
133-
String compName = pet.getName();
134-
compName = compName.toLowerCase();
135-
if (compName.equals(name)) {
136-
return pet;
137-
}
138-
}
139-
}
140-
return null;
141-
}
142-
143-
@Override
144-
public String toString() {
145-
return new ToStringCreator(this)
146-
147-
.append("id", this.getId()).append("new", this.isNew())
148-
.append("lastName", this.getLastName())
149-
.append("firstName", this.getFirstName()).append("address", this.address)
150-
.append("city", this.city).append("telephone", this.telephone).toString();
151-
}
48+
49+
@Column(name = "address")
50+
@NotEmpty
51+
private String address;
52+
53+
@Column(name = "city")
54+
@NotEmpty
55+
private String city;
56+
57+
@Column(name = "telephone")
58+
@NotEmpty
59+
@Digits(fraction = 0, integer = 10)
60+
private String telephone;
61+
62+
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
63+
private Set<Pet> pets;
64+
65+
public String getAddress() {
66+
return this.address;
67+
}
68+
69+
public void setAddress(String address) {
70+
this.address = address;
71+
}
72+
73+
public String getCity() {
74+
return this.city;
75+
}
76+
77+
public void setCity(String city) {
78+
this.city = city;
79+
}
80+
81+
public String getTelephone() {
82+
return this.telephone;
83+
}
84+
85+
public void setTelephone(String telephone) {
86+
this.telephone = telephone;
87+
}
88+
89+
protected Set<Pet> getPetsInternal() {
90+
if (this.pets == null) {
91+
this.pets = new HashSet<>();
92+
}
93+
return this.pets;
94+
}
95+
96+
protected void setPetsInternal(Set<Pet> pets) {
97+
this.pets = pets;
98+
}
99+
100+
public List<Pet> getPets() {
101+
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
102+
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
103+
return Collections.unmodifiableList(sortedPets);
104+
}
105+
106+
public void addPet(Pet pet) {
107+
if (pet.isNew()) {
108+
getPetsInternal().add(pet);
109+
}
110+
pet.setOwner(this);
111+
}
112+
113+
/**
114+
* Return the Pet with the given name, or null if none found for this Owner.
115+
* @param name to test
116+
* @return true if pet name is already in use
117+
*/
118+
public Pet getPet(String name) {
119+
return getPet(name, false);
120+
}
121+
122+
/**
123+
* Return the Pet with the given name, or null if none found for this Owner.
124+
* @param name to test
125+
* @return true if pet name is already in use
126+
*/
127+
public Pet getPet(String name, boolean ignoreNew) {
128+
name = name.toLowerCase();
129+
for (Pet pet : getPetsInternal()) {
130+
if (!ignoreNew || !pet.isNew()) {
131+
String compName = pet.getName();
132+
compName = compName.toLowerCase();
133+
if (compName.equals(name)) {
134+
return pet;
135+
}
136+
}
137+
}
138+
return null;
139+
}
140+
141+
@Override
142+
public String toString() {
143+
return new ToStringCreator(this)
144+
145+
.append("id", this.getId()).append("new", this.isNew()).append("lastName", this.getLastName())
146+
.append("firstName", this.getFirstName()).append("address", this.address).append("city", this.city)
147+
.append("telephone", this.telephone).toString();
148+
}
149+
152150
}

0 commit comments

Comments
 (0)