formatting work
This commit is contained in:
+21
-13
@@ -19,22 +19,27 @@ public class Campus {
|
||||
@Field
|
||||
@NotNull
|
||||
private Point location;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Point getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Point location) {
|
||||
this.location = location;
|
||||
}
|
||||
@@ -42,13 +47,13 @@ public class Campus {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
if(id != null) {
|
||||
if (id != null) {
|
||||
hash = hash * 31 + id.hashCode();
|
||||
}
|
||||
if(name != null) {
|
||||
if (name != null) {
|
||||
hash = hash * 31 + name.hashCode();
|
||||
}
|
||||
if(location != null) {
|
||||
if (location != null) {
|
||||
hash = hash * 31 + location.hashCode();
|
||||
}
|
||||
return hash;
|
||||
@@ -56,30 +61,33 @@ public class Campus {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if((obj == null) || (obj.getClass() != this.getClass())) return false;
|
||||
if(obj == this) return true;
|
||||
if ((obj == null) || (obj.getClass() != this.getClass()))
|
||||
return false;
|
||||
if (obj == this)
|
||||
return true;
|
||||
Campus other = (Campus) obj;
|
||||
return this.hashCode() == other.hashCode();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Campus() {}
|
||||
|
||||
private Campus() {
|
||||
}
|
||||
|
||||
public Campus(Builder b) {
|
||||
this.id = b.id;
|
||||
this.name = b.name;
|
||||
this.location = b.location;
|
||||
}
|
||||
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String name;
|
||||
private Point location;
|
||||
|
||||
|
||||
public static Builder newInstance() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
|
||||
public Campus build() {
|
||||
return new Campus(this);
|
||||
}
|
||||
@@ -93,7 +101,7 @@ public class Campus {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Builder location(Point location) {
|
||||
this.location = location;
|
||||
return this;
|
||||
|
||||
+18
-7
@@ -24,7 +24,7 @@ public class Person {
|
||||
private DateTime created;
|
||||
@Field
|
||||
private DateTime updated;
|
||||
|
||||
|
||||
public Person(String id, String firstName, String lastName) {
|
||||
this.id = id;
|
||||
this.firstName = firstName;
|
||||
@@ -34,44 +34,53 @@ public class Person {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public DateTime getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(DateTime created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public DateTime getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(DateTime updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
if(id != null) {
|
||||
if (id != null) {
|
||||
hash = hash * 31 + id.hashCode();
|
||||
}
|
||||
if(firstName != null) {
|
||||
if (firstName != null) {
|
||||
hash = hash * 31 + firstName.hashCode();
|
||||
}
|
||||
if(lastName != null) {
|
||||
if (lastName != null) {
|
||||
hash = hash * 31 + lastName.hashCode();
|
||||
}
|
||||
return hash;
|
||||
@@ -79,8 +88,10 @@ public class Person {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if((obj == null) || (obj.getClass() != this.getClass())) return false;
|
||||
if(obj == this) return true;
|
||||
if ((obj == null) || (obj.getClass() != this.getClass()))
|
||||
return false;
|
||||
if (obj == this)
|
||||
return true;
|
||||
Person other = (Person) obj;
|
||||
return this.hashCode() == other.hashCode();
|
||||
}
|
||||
|
||||
+26
-12
@@ -20,13 +20,13 @@ public class Student {
|
||||
private String id;
|
||||
@Field
|
||||
@NotNull
|
||||
@Size(min=1, max=20)
|
||||
@Pattern(regexp=NAME_REGEX)
|
||||
@Size(min = 1, max = 20)
|
||||
@Pattern(regexp = NAME_REGEX)
|
||||
private String firstName;
|
||||
@Field
|
||||
@NotNull
|
||||
@Size(min=1, max=20)
|
||||
@Pattern(regexp=NAME_REGEX)
|
||||
@Size(min = 1, max = 20)
|
||||
@Pattern(regexp = NAME_REGEX)
|
||||
private String lastName;
|
||||
@Field
|
||||
@Past
|
||||
@@ -38,8 +38,9 @@ public class Student {
|
||||
private DateTime updated;
|
||||
@Version
|
||||
private long version;
|
||||
|
||||
public Student() {}
|
||||
|
||||
public Student() {
|
||||
}
|
||||
|
||||
public Student(String id, String firstName, String lastName, DateTime dateOfBirth) {
|
||||
this.id = id;
|
||||
@@ -51,36 +52,47 @@ public class Student {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public DateTime getDateOfBirth() {
|
||||
return dateOfBirth;
|
||||
}
|
||||
|
||||
public void setDateOfBirth(DateTime dateOfBirth) {
|
||||
this.dateOfBirth = dateOfBirth;
|
||||
}
|
||||
|
||||
public DateTime getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(DateTime created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public DateTime getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(DateTime updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
@@ -88,16 +100,16 @@ public class Student {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
if(id != null) {
|
||||
if (id != null) {
|
||||
hash = hash * 31 + id.hashCode();
|
||||
}
|
||||
if(firstName != null) {
|
||||
if (firstName != null) {
|
||||
hash = hash * 31 + firstName.hashCode();
|
||||
}
|
||||
if(lastName != null) {
|
||||
if (lastName != null) {
|
||||
hash = hash * 31 + lastName.hashCode();
|
||||
}
|
||||
if(dateOfBirth != null) {
|
||||
if (dateOfBirth != null) {
|
||||
hash = hash * 31 + dateOfBirth.hashCode();
|
||||
}
|
||||
return hash;
|
||||
@@ -105,8 +117,10 @@ public class Student {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if((obj == null) || (obj.getClass() != this.getClass())) return false;
|
||||
if(obj == this) return true;
|
||||
if ((obj == null) || (obj.getClass() != this.getClass()))
|
||||
return false;
|
||||
if (obj == this)
|
||||
return true;
|
||||
Student other = (Student) obj;
|
||||
return this.hashCode() == other.hashCode();
|
||||
}
|
||||
|
||||
+1
-4
@@ -17,9 +17,6 @@ public class CustomStudentRepositoryImpl implements CustomStudentRepository {
|
||||
private CouchbaseTemplate template;
|
||||
|
||||
public List<Student> findByFirstNameStartsWith(String s) {
|
||||
return template.findByView(ViewQuery.from(DESIGN_DOC, "byFirstName")
|
||||
.startKey(s)
|
||||
.stale(Stale.FALSE),
|
||||
Student.class);
|
||||
return template.findByView(ViewQuery.from(DESIGN_DOC, "byFirstName").startKey(s).stale(Stale.FALSE), Student.class);
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -7,5 +7,6 @@ import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface PersonRepository extends CrudRepository<Person, String> {
|
||||
List<Person> findByFirstName(String firstName);
|
||||
|
||||
List<Person> findByLastName(String lastName);
|
||||
}
|
||||
|
||||
+1
@@ -7,5 +7,6 @@ import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface StudentRepository extends CrudRepository<Student, String>, CustomStudentRepository {
|
||||
List<Student> findByFirstName(String firstName);
|
||||
|
||||
List<Student> findByLastName(String lastName);
|
||||
}
|
||||
|
||||
+3
-2
@@ -14,8 +14,9 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@Qualifier("PersonRepositoryService")
|
||||
public class PersonRepositoryService implements PersonService {
|
||||
|
||||
|
||||
private PersonRepository repo;
|
||||
|
||||
@Autowired
|
||||
public void setPersonRepository(PersonRepository repo) {
|
||||
this.repo = repo;
|
||||
@@ -28,7 +29,7 @@ public class PersonRepositoryService implements PersonService {
|
||||
public List<Person> findAll() {
|
||||
List<Person> people = new ArrayList<Person>();
|
||||
Iterator<Person> it = repo.findAll().iterator();
|
||||
while(it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
people.add(it.next());
|
||||
}
|
||||
return people;
|
||||
|
||||
+4
-3
@@ -14,17 +14,18 @@ import com.couchbase.client.java.view.ViewQuery;
|
||||
@Service
|
||||
@Qualifier("PersonTemplateService")
|
||||
public class PersonTemplateService implements PersonService {
|
||||
|
||||
|
||||
private static final String DESIGN_DOC = "person";
|
||||
|
||||
private CouchbaseTemplate template;
|
||||
|
||||
@Autowired
|
||||
public void setCouchbaseTemplate(CouchbaseTemplate template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public Person findOne(String id) {
|
||||
return template.findById(id, Person.class);
|
||||
public Person findOne(String id) {
|
||||
return template.findById(id, Person.class);
|
||||
}
|
||||
|
||||
public List<Person> findAll() {
|
||||
|
||||
+3
-2
@@ -14,8 +14,9 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@Qualifier("StudentRepositoryService")
|
||||
public class StudentRepositoryService implements StudentService {
|
||||
|
||||
|
||||
private StudentRepository repo;
|
||||
|
||||
@Autowired
|
||||
public void setStudentRepository(StudentRepository repo) {
|
||||
this.repo = repo;
|
||||
@@ -28,7 +29,7 @@ public class StudentRepositoryService implements StudentService {
|
||||
public List<Student> findAll() {
|
||||
List<Student> people = new ArrayList<Student>();
|
||||
Iterator<Student> it = repo.findAll().iterator();
|
||||
while(it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
people.add(it.next());
|
||||
}
|
||||
return people;
|
||||
|
||||
+4
-3
@@ -14,17 +14,18 @@ import com.couchbase.client.java.view.ViewQuery;
|
||||
@Service
|
||||
@Qualifier("StudentTemplateService")
|
||||
public class StudentTemplateService implements StudentService {
|
||||
|
||||
|
||||
private static final String DESIGN_DOC = "student";
|
||||
|
||||
private CouchbaseTemplate template;
|
||||
|
||||
@Autowired
|
||||
public void setCouchbaseTemplate(CouchbaseTemplate template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public Student findOne(String id) {
|
||||
return template.findById(id, Student.class);
|
||||
public Student findOne(String id) {
|
||||
return template.findById(id, Student.class);
|
||||
}
|
||||
|
||||
public List<Student> findAll() {
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@ import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface CampusRepository extends CrudRepository<Campus, String> {
|
||||
|
||||
@View(designDocument="campus", viewName="byName")
|
||||
@View(designDocument = "campus", viewName = "byName")
|
||||
Set<Campus> findByName(String name);
|
||||
|
||||
@Dimensional(dimensions=2, designDocument="campus_spatial", spatialViewName="byLocation")
|
||||
@Dimensional(dimensions = 2, designDocument = "campus_spatial", spatialViewName = "byLocation")
|
||||
Set<Campus> findByLocationNear(Point point, Distance distance);
|
||||
}
|
||||
|
||||
+1
@@ -7,5 +7,6 @@ import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface PersonRepository extends CrudRepository<Person, String> {
|
||||
List<Person> findByFirstName(String firstName);
|
||||
|
||||
List<Person> findByLastName(String lastName);
|
||||
}
|
||||
|
||||
+1
@@ -7,5 +7,6 @@ import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface StudentRepository extends CrudRepository<Student, String> {
|
||||
List<Student> findByFirstName(String firstName);
|
||||
|
||||
List<Student> findByLastName(String lastName);
|
||||
}
|
||||
|
||||
+3
-3
@@ -7,14 +7,14 @@ import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Point;
|
||||
|
||||
public interface CampusService {
|
||||
|
||||
|
||||
Campus find(String id);
|
||||
|
||||
Set<Campus> findByName(String name);
|
||||
|
||||
Set<Campus> findByLocationNear(Point point, Distance distance);
|
||||
|
||||
|
||||
Set<Campus> findAll();
|
||||
|
||||
|
||||
void save(Campus campus);
|
||||
}
|
||||
|
||||
+5
-4
@@ -15,21 +15,22 @@ import org.springframework.stereotype.Service;
|
||||
public class CampusServiceImpl implements CampusService {
|
||||
|
||||
private CampusRepository repo;
|
||||
|
||||
@Autowired
|
||||
public void setCampusRepository(CampusRepository repo) {
|
||||
this.repo = repo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Campus find(String id) {
|
||||
return repo.findOne(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<Campus> findByName(String name) {
|
||||
return repo.findByName(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<Campus> findByLocationNear(Point point, Distance distance) {
|
||||
return repo.findByLocationNear(point, distance);
|
||||
@@ -39,7 +40,7 @@ public class CampusServiceImpl implements CampusService {
|
||||
public Set<Campus> findAll() {
|
||||
Set<Campus> campuses = new HashSet<>();
|
||||
Iterator<Campus> it = repo.findAll().iterator();
|
||||
while(it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
campuses.add(it.next());
|
||||
}
|
||||
return campuses;
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
public class PersonServiceImpl implements PersonService {
|
||||
|
||||
private PersonRepository repo;
|
||||
|
||||
@Autowired
|
||||
public void setPersonRepository(PersonRepository repo) {
|
||||
this.repo = repo;
|
||||
@@ -26,7 +27,7 @@ public class PersonServiceImpl implements PersonService {
|
||||
public List<Person> findAll() {
|
||||
List<Person> people = new ArrayList<Person>();
|
||||
Iterator<Person> it = repo.findAll().iterator();
|
||||
while(it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
people.add(it.next());
|
||||
}
|
||||
return people;
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
public class StudentServiceImpl implements StudentService {
|
||||
|
||||
private StudentRepository repo;
|
||||
|
||||
@Autowired
|
||||
public void setStudentRepository(StudentRepository repo) {
|
||||
this.repo = repo;
|
||||
@@ -26,7 +27,7 @@ public class StudentServiceImpl implements StudentService {
|
||||
public List<Student> findAll() {
|
||||
List<Student> people = new ArrayList<Student>();
|
||||
Iterator<Student> it = repo.findAll().iterator();
|
||||
while(it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
people.add(it.next());
|
||||
}
|
||||
return people;
|
||||
|
||||
Reference in New Issue
Block a user