Skip to content

Commit db66530

Browse files
committed
Code formatting.
1 parent 0ce14be commit db66530

File tree

26 files changed

+623
-792
lines changed

26 files changed

+623
-792
lines changed

spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/auditing/AuditableUser.java

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,34 @@
55
import org.springframework.data.domain.Auditable;
66
import org.springframework.data.jpa.domain.AbstractAuditable;
77

8-
98
/**
10-
* User domain class that uses auditing functionality of Spring Data that can either
11-
* be aquired implementing {@link Auditable} or extend
12-
* {@link AbstractAuditable}.
9+
* User domain class that uses auditing functionality of Spring Data that can either be aquired implementing
10+
* {@link Auditable} or extend {@link AbstractAuditable}.
1311
*
1412
* @author Oliver Gierke
1513
*/
1614
@Entity
1715
public class AuditableUser extends AbstractAuditable<AuditableUser, Long> {
1816

19-
private static final long serialVersionUID = 1L;
20-
21-
private String username;
22-
23-
24-
/**
25-
* Set's the user's name.
26-
*
27-
* @param username the username to set
28-
*/
29-
public void setUsername(String username) {
30-
31-
this.username = username;
32-
}
33-
34-
35-
/**
36-
* Returns the user's name.
37-
*
38-
* @return the username
39-
*/
40-
public String getUsername() {
41-
42-
return username;
43-
}
17+
private static final long serialVersionUID = 1L;
18+
19+
private String username;
20+
21+
/**
22+
* Set's the user's name.
23+
*
24+
* @param username the username to set
25+
*/
26+
public void setUsername(String username) {
27+
this.username = username;
28+
}
29+
30+
/**
31+
* Returns the user's name.
32+
*
33+
* @return the username
34+
*/
35+
public String getUsername() {
36+
return username;
37+
}
4438
}

spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/auditing/AuditorAwareImpl.java

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,29 @@
22

33
import org.springframework.data.domain.AuditorAware;
44

5-
65
/**
7-
* Dummy implementation of {@link AuditorAware}. It will return the configured
8-
* {@link AuditableUser} as auditor on every call to
9-
* {@link #getCurrentAuditor()}. Normally you would access the applications
10-
* security subsystem to return the current user.
6+
* Dummy implementation of {@link AuditorAware}. It will return the configured {@link AuditableUser} as auditor on every
7+
* call to {@link #getCurrentAuditor()}. Normally you would access the applications security subsystem to return the
8+
* current user.
119
*
1210
* @author Oliver Gierke
1311
*/
1412
public class AuditorAwareImpl implements AuditorAware<AuditableUser> {
1513

16-
private AuditableUser auditor;
17-
18-
19-
/**
20-
* @param auditor the auditor to set
21-
*/
22-
public void setAuditor(AuditableUser auditor) {
23-
24-
this.auditor = auditor;
25-
}
26-
27-
28-
/*
29-
* (non-Javadoc)
30-
*
31-
* @see org.springframework.data.domain.AuditorAware#getCurrentAuditor()
32-
*/
33-
public AuditableUser getCurrentAuditor() {
34-
35-
return auditor;
36-
}
37-
14+
private AuditableUser auditor;
15+
16+
/**
17+
* @param auditor the auditor to set
18+
*/
19+
public void setAuditor(AuditableUser auditor) {
20+
this.auditor = auditor;
21+
}
22+
23+
/*
24+
* (non-Javadoc)
25+
* @see org.springframework.data.domain.AuditorAware#getCurrentAuditor()
26+
*/
27+
public AuditableUser getCurrentAuditor() {
28+
return auditor;
29+
}
3830
}

spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/domain/User.java

Lines changed: 63 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import org.springframework.data.jpa.domain.AbstractPersistable;
88

9-
109
/**
1110
* Sample user class.
1211
*
@@ -16,82 +15,67 @@
1615
@NamedQuery(name = "User.findByTheUsersName", query = "from User u where u.username = ?")
1716
public class User extends AbstractPersistable<Long> {
1817

19-
private static final long serialVersionUID = -2952735933715107252L;
20-
21-
@Column(unique = true)
22-
private String username;
23-
24-
private String firstname;
25-
private String lastname;
26-
27-
28-
public User() {
29-
30-
this(null);
31-
}
32-
33-
34-
/**
35-
* Creates a new user instance.
36-
*/
37-
public User(Long id) {
38-
39-
this.setId(id);
40-
}
41-
42-
43-
/**
44-
* Returns the username.
45-
*
46-
* @return
47-
*/
48-
public String getUsername() {
49-
50-
return username;
51-
}
52-
53-
54-
/**
55-
* @param username the username to set
56-
*/
57-
public void setUsername(String username) {
58-
59-
this.username = username;
60-
}
61-
62-
63-
/**
64-
* @return the firstname
65-
*/
66-
public String getFirstname() {
67-
68-
return firstname;
69-
}
70-
71-
72-
/**
73-
* @param firstname the firstname to set
74-
*/
75-
public void setFirstname(String firstname) {
76-
77-
this.firstname = firstname;
78-
}
79-
80-
81-
/**
82-
* @return the lastname
83-
*/
84-
public String getLastname() {
85-
86-
return lastname;
87-
}
88-
89-
90-
/**
91-
* @param lastname the lastname to set
92-
*/
93-
public void setLastname(String lastname) {
94-
95-
this.lastname = lastname;
96-
}
18+
private static final long serialVersionUID = -2952735933715107252L;
19+
20+
@Column(unique = true)
21+
private String username;
22+
23+
private String firstname;
24+
private String lastname;
25+
26+
public User() {
27+
this(null);
28+
}
29+
30+
/**
31+
* Creates a new user instance.
32+
*/
33+
public User(Long id) {
34+
this.setId(id);
35+
}
36+
37+
/**
38+
* Returns the username.
39+
*
40+
* @return
41+
*/
42+
public String getUsername() {
43+
44+
return username;
45+
}
46+
47+
/**
48+
* @param username the username to set
49+
*/
50+
public void setUsername(String username) {
51+
this.username = username;
52+
}
53+
54+
/**
55+
* @return the firstname
56+
*/
57+
public String getFirstname() {
58+
return firstname;
59+
}
60+
61+
/**
62+
* @param firstname the firstname to set
63+
*/
64+
public void setFirstname(String firstname) {
65+
this.firstname = firstname;
66+
}
67+
68+
/**
69+
* @return the lastname
70+
*/
71+
public String getLastname() {
72+
return lastname;
73+
}
74+
75+
/**
76+
* @param lastname the lastname to set
77+
*/
78+
public void setLastname(String lastname) {
79+
this.lastname = lastname;
80+
}
9781
}

spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/UserRepository.java

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,39 @@
77
import org.springframework.data.jpa.repository.Query;
88
import org.springframework.data.repository.CrudRepository;
99

10-
1110
/**
12-
* Repository interface for {@link User} instances. Provides basic CRUD operations due
13-
* to the extension of {@link JpaRepository}. Includes custom implemented
14-
* functionality by extending {@link UserRepositoryCustom}.
11+
* Repository interface for {@link User} instances. Provides basic CRUD operations due to the extension of
12+
* {@link JpaRepository}. Includes custom implemented functionality by extending {@link UserRepositoryCustom}.
1513
*
1614
* @author Oliver Gierke
1715
*/
1816
public interface UserRepository extends CrudRepository<User, Long>, UserRepositoryCustom {
1917

20-
/**
21-
* Find the user with the given username. This method will be translated
22-
* into a query using the {@link javax.persistence.NamedQuery} annotation at
23-
* the {@link User} class.
24-
*
25-
* @param lastname
26-
* @return
27-
*/
28-
User findByTheUsersName(String username);
29-
30-
31-
/**
32-
* Find all users with the given lastname. This method will be translated
33-
* into a query by constructing it directly from the method name as there is
34-
* no other query declared.
35-
*
36-
* @param lastname
37-
* @return
38-
*/
39-
List<User> findByLastname(String lastname);
40-
41-
42-
/**
43-
* Returns all users with the given firstname. This method will be
44-
* translated into a query using the one declared in the {@link Query}
45-
* annotation declared one.
46-
*
47-
* @param firstname
48-
* @return
49-
*/
50-
@Query("select u from User u where u.firstname = ?")
51-
List<User> findByFirstname(String firstname);
18+
/**
19+
* Find the user with the given username. This method will be translated into a query using the
20+
* {@link javax.persistence.NamedQuery} annotation at the {@link User} class.
21+
*
22+
* @param lastname
23+
* @return
24+
*/
25+
User findByTheUsersName(String username);
26+
27+
/**
28+
* Find all users with the given lastname. This method will be translated into a query by constructing it directly
29+
* from the method name as there is no other query declared.
30+
*
31+
* @param lastname
32+
* @return
33+
*/
34+
List<User> findByLastname(String lastname);
35+
36+
/**
37+
* Returns all users with the given firstname. This method will be translated into a query using the one declared in
38+
* the {@link Query} annotation declared one.
39+
*
40+
* @param firstname
41+
* @return
42+
*/
43+
@Query("select u from User u where u.firstname = ?")
44+
List<User> findByFirstname(String firstname);
5245
}

spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/UserRepositoryCustom.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44

55
import org.springframework.data.jpa.example.domain.User;
66

7-
87
/**
98
* Interface for repository functionality that ought to be implemented manually.
109
*
1110
* @author Oliver Gierke
1211
*/
1312
interface UserRepositoryCustom {
1413

15-
/**
16-
* Custom repository operation.
17-
*
18-
* @return
19-
*/
20-
List<User> myCustomBatchOperation();
14+
/**
15+
* Custom repository operation.
16+
*
17+
* @return
18+
*/
19+
List<User> myCustomBatchOperation();
2120
}

0 commit comments

Comments
 (0)