#96 Reformat code with EditorConfig

This commit is contained in:
Antoine Rey 2015-10-16 09:33:06 +02:00
parent 1aef94d6a8
commit 09ed33a5fc
56 changed files with 831 additions and 832 deletions

9
.editorconfig Normal file
View file

@ -0,0 +1,9 @@
# top-most EditorConfig file
root = true
[*.{java,xml}]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>spring-petclinic</artifactId>

View file

@ -32,15 +32,14 @@ public class BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Integer id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public boolean isNew() {
return (this.id == null);
}

View file

@ -32,15 +32,14 @@ public class NamedEntity extends BaseEntity {
@Column(name = "name")
private String name;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
@Override
public String toString() {
return this.getName();

View file

@ -85,10 +85,6 @@ public class Owner extends Person {
this.telephone = telephone;
}
protected void setPetsInternal(Set<Pet> pets) {
this.pets = pets;
}
protected Set<Pet> getPetsInternal() {
if (this.pets == null) {
this.pets = new HashSet<>();
@ -96,6 +92,10 @@ public class Owner extends Person {
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));

View file

@ -63,33 +63,28 @@ public class Pet extends NamedEntity {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER)
private Set<Visit> visits;
public void setBirthDate(DateTime birthDate) {
this.birthDate = birthDate;
}
public DateTime getBirthDate() {
return this.birthDate;
}
public void setType(PetType type) {
this.type = type;
public void setBirthDate(DateTime birthDate) {
this.birthDate = birthDate;
}
public PetType getType() {
return this.type;
}
protected void setOwner(Owner owner) {
this.owner = owner;
public void setType(PetType type) {
this.type = type;
}
public Owner getOwner() {
return this.owner;
}
protected void setVisitsInternal(Set<Visit> visits) {
this.visits = visits;
protected void setOwner(Owner owner) {
this.owner = owner;
}
protected Set<Visit> getVisitsInternal() {
@ -99,6 +94,10 @@ public class Pet extends NamedEntity {
return this.visits;
}
protected void setVisitsInternal(Set<Visit> visits) {
this.visits = visits;
}
public List<Visit> getVisits() {
List<Visit> sortedVisits = new ArrayList<>(getVisitsInternal());
PropertyComparator.sort(sortedVisits, new MutableSortDefinition("date", false, false));

View file

@ -49,11 +49,6 @@ public class Vet extends Person {
inverseJoinColumns = @JoinColumn(name = "specialty_id"))
private Set<Specialty> specialties;
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
this.specialties = specialties;
}
protected Set<Specialty> getSpecialtiesInternal() {
if (this.specialties == null) {
this.specialties = new HashSet<>();
@ -61,6 +56,10 @@ public class Vet extends Person {
return this.specialties;
}
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
this.specialties = specialties;
}
@XmlElement
public List<Specialty> getSpecialties() {
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());

View file

@ -1,8 +1,5 @@
/**
*
* The classes in this package represent PetClinic's business layer.
*
*/
package org.springframework.samples.petclinic.model;

View file

@ -62,8 +62,7 @@ public interface OwnerRepository {
*
* @param id the id to search for
* @return the <code>Owner</code> if found
* @throws org.springframework.dao.DataRetrievalFailureException
* if not found
* @throws org.springframework.dao.DataRetrievalFailureException if not found
*/
Owner findById(int id) throws DataAccessException;

View file

@ -45,8 +45,7 @@ public interface PetRepository {
*
* @param id the id to search for
* @return the <code>Pet</code> if found
* @throws org.springframework.dao.DataRetrievalFailureException
* if not found
* @throws org.springframework.dao.DataRetrievalFailureException if not found
*/
Pet findById(int id) throws DataAccessException;

View file

@ -29,21 +29,20 @@ class JdbcPet extends Pet {
private int ownerId;
public void setTypeId(int typeId) {
this.typeId = typeId;
}
public int getTypeId() {
return this.typeId;
}
public void setOwnerId(int ownerId) {
this.ownerId = ownerId;
public void setTypeId(int typeId) {
this.typeId = typeId;
}
public int getOwnerId() {
return this.ownerId;
}
public void setOwnerId(int ownerId) {
this.ownerId = ownerId;
}
}

View file

@ -1,9 +1,6 @@
/**
*
* The classes in this package represent the JDBC implementation
* of PetClinic's persistence layer.
*
*/
package org.springframework.samples.petclinic.repository.jdbc;

View file

@ -72,8 +72,7 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository {
public void save(Owner owner) {
if (owner.getId() == null) {
this.em.persist(owner);
}
else {
} else {
this.em.merge(owner);
}

View file

@ -55,8 +55,7 @@ public class JpaPetRepositoryImpl implements PetRepository {
public void save(Pet pet) {
if (pet.getId() == null) {
this.em.persist(pet);
}
else {
} else {
this.em.merge(pet);
}
}

View file

@ -47,8 +47,7 @@ public class JpaVisitRepositoryImpl implements VisitRepository {
public void save(Visit visit) {
if (visit.getId() == null) {
this.em.persist(visit);
}
else {
} else {
this.em.merge(visit);
}
}

View file

@ -1,9 +1,6 @@
/**
*
* The classes in this package represent the JPA implementation
* of PetClinic's persistence layer.
*
*/
package org.springframework.samples.petclinic.repository.jpa;

View file

@ -26,7 +26,7 @@ import org.springframework.util.StopWatch;
/**
* Simple aspect that monitors call count and call invocation time. It uses JMX annotations and therefore can be
* monitored using any JMX console such as the jConsole
*
* <p/>
* This is only useful if you use JPA or JDBC. Spring-data-jpa doesn't have any correctly annotated classes to join on
*
* @author Rob Harrop
@ -44,17 +44,16 @@ public class CallMonitoringAspect {
private long accumulatedCallTime = 0;
@ManagedAttribute
public boolean isEnabled() {
return enabled;
}
@ManagedAttribute
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@ManagedAttribute
public boolean isEnabled() {
return enabled;
}
@ManagedOperation
public void reset() {
this.callCount = 0;

View file

@ -39,8 +39,7 @@ public abstract class EntityUtils {
* @param entityClass the entity class to look up
* @param entityId the entity id to look up
* @return the found entity
* @throws ObjectRetrievalFailureException
* if the entity was not found
* @throws ObjectRetrievalFailureException if the entity was not found
*/
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
throws ObjectRetrievalFailureException {

View file

@ -96,13 +96,11 @@ public class OwnerController {
// no owners found
result.rejectValue("lastName", "notFound", "not found");
return "owners/findOwners";
}
else if (results.size() == 1) {
} else if (results.size() == 1) {
// 1 owner found
owner = results.iterator().next();
return "redirect:/owners/" + owner.getId();
}
else {
} else {
// multiple owners found
model.put("selections", results);
return "owners/ownersList";

View file

@ -52,7 +52,9 @@ public class VetController {
}
@RequestMapping("/vets.json")
public @ResponseBody Vets showResourcesVetList() {
public
@ResponseBody
Vets showResourcesVetList() {
// Here we are returning an object of type 'Vets' rather than a collection of Vet objects
// so it is simpler for JSon/Object mapping
Vets vets = new Vets();

View file

@ -60,6 +60,7 @@ public class VisitController {
* - Make sure we always have fresh data
* - Since we do not use the session scope, make sure that Pet object always has an id
* (Even though id is not part of the form fields)
*
* @param petId
* @return Pet
*/

View file

@ -1,8 +1,5 @@
/**
*
* The classes in this package represent PetClinic's web presentation layer.
*
*/
package org.springframework.samples.petclinic.web;

View file

@ -21,18 +21,32 @@
<tbody>
<tr>
<td>
<img class="speakerPic" alt="Sergiu Bodiu" src="http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/4/000/16a/2ba/0ba653e.jpg" />
<img class="speakerPic" alt="Sergiu Bodiu"
src="http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/4/000/16a/2ba/0ba653e.jpg"/>
<h2>Sergiu Bodiu </h2>
<h3> Java Consultant at Bank of America </h3>
<font size="5">S</font>easoned consultant experienced in large-scale e-commerce projects, passionate about providing innovative technology solutions to solve complex business problems, have extensive knowledge and experience delivering enterprise wide applications. He is skilled in software design, data modeling, stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, test and maintain software product components with strong focus on design elegance and software reuse.
<font size="5">S</font>easoned consultant experienced in large-scale e-commerce projects, passionate about
providing innovative technology solutions to solve complex business problems, have extensive knowledge and
experience delivering enterprise wide applications. He is skilled in software design, data modeling,
stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement,
test and maintain software product components with strong focus on design elegance and software reuse.
</td>
</tr>
<tr>
<td>
<img alt="Sergiu Bodiu" src="http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/4/000/16a/2ba/0ba653e.jpg" width="84" height="84" align="right" hspace="10"/>
<img alt="Sergiu Bodiu" src="http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/4/000/16a/2ba/0ba653e.jpg"
width="84" height="84" align="right" hspace="10"/>
<h2>Sergiu Bodiu </h2>
<h3> Java Consultant at Bank of America </h3>
<font size="5">S</font>easoned consultant experienced in large-scale e-commerce projects, passionate about providing innovative technology solutions to solve complex business problems, have extensive knowledge and experience delivering enterprise wide applications. He is skilled in software design, data modeling, stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, test and maintain software product components with strong focus on design elegance and software reuse.
<font size="5">S</font>easoned consultant experienced in large-scale e-commerce projects, passionate about
providing innovative technology solutions to solve complex business problems, have extensive knowledge and
experience delivering enterprise wide applications. He is skilled in software design, data modeling,
stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement,
test and maintain software product components with strong focus on design elegance and software reuse.
</td>
</tr>
</tbody>

View file

@ -2,9 +2,9 @@
<!--
Repository and Service layers
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd

View file

@ -2,11 +2,11 @@
<!--
Application context definition for PetClinic Datasource.
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context

View file

@ -2,11 +2,11 @@
<!--
- DispatcherServlet application context for PetClinic's web tier.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans

View file

@ -2,8 +2,8 @@
<!--
- DispatcherServlet application context for PetClinic's web tier.
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:mvc="http://www.springframework.org/schema/mvc"
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

View file

@ -2,11 +2,11 @@
<!--
Application context definition for PetClinic on JPA.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/beans

View file

@ -16,7 +16,8 @@
<h2>Veterinarians</h2>
<datatables:table id="vets" data="${vets.vetList}" row="vet" theme="bootstrap2" cssClass="table table-striped" pageable="false" info="false">
<datatables:table id="vets" data="${vets.vetList}" row="vet" theme="bootstrap2" cssClass="table table-striped"
pageable="false" info="false">
<datatables:column title="Name">
<c:out value="${vet.firstName} ${vet.lastName}"></c:out>
</datatables:column>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0" metadata-complete="true">

View file

@ -13,11 +13,9 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
/**
*
* @author Michael Isvy
* Simple test to make sure that Bean Validation is working
* (useful when upgrading to a new version of Hibernate Validator/ Bean Validation)
*
*/
public class ValidatorTests {

View file

@ -22,10 +22,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* <p> Integration test using the jdbc profile.
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
*
* @author Thomas Risberg
* @author Michael Isvy
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
*/
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
@RunWith(SpringJUnit4ClassRunner.class)

View file

@ -1,4 +1,3 @@
package org.springframework.samples.petclinic.service;
import org.junit.runner.RunWith;
@ -8,11 +7,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* <p> Integration test using the jpa profile.
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
*
* @author Rod Johnson
* @author Sam Brannen
* @author Michael Isvy
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
*/
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})

View file

@ -1,4 +1,3 @@
package org.springframework.samples.petclinic.service;
import org.junit.runner.RunWith;
@ -8,8 +7,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* <p> Integration test using the 'Spring Data' profile.
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
*
* @author Michael Isvy
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
*/
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})