| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bfdc171 commit 0094a87
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,24 @@ | |||
| 16 | 16 | <artifactId>log4j-core</artifactId> | |
| 17 | 17 | <version>${log4j2.version}</version> | |
| 18 | 18 | </dependency> | |
| 19 | + <dependency> | ||
| 20 | + <groupId>org.hamcrest</groupId> | ||
| 21 | + <artifactId>hamcrest-core</artifactId> | ||
| 22 | + <version>${org.hamcrest.version}</version> | ||
| 23 | + <scope>test</scope> | ||
| 24 | + </dependency> | ||
| 25 | + <dependency> | ||
| 26 | + <groupId>org.hamcrest</groupId> | ||
| 27 | + <artifactId>hamcrest-library</artifactId> | ||
| 28 | + <version>${org.hamcrest.version}</version> | ||
| 29 | + <scope>test</scope> | ||
| 30 | + </dependency> | ||
| 31 | + <dependency> | ||
| 32 | + <groupId>org.hamcrest</groupId> | ||
| 33 | + <artifactId>hamcrest-all</artifactId> | ||
| 34 | + <version>${org.hamcrest.version}</version> | ||
| 35 | + <scope>test</scope> | ||
| 36 | + </dependency> | ||
| 19 | 37 | </dependencies> | |
| 20 | 38 | ||
| 21 | 39 | <build> | |
@@ -32,5 +50,6 @@ | |||
| 32 | 50 | </build> | |
| 33 | 51 | <properties> | |
| 34 | 52 | <log4j2.version>2.8.2</log4j2.version> | |
| 53 | + <org.hamcrest.version>1.3</org.hamcrest.version> | ||
| 35 | 54 | </properties> | |
| 36 | 55 | </project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,46 @@ | |||
| 1 | + package com.stackify.stream; | ||
| 2 | + | ||
| 3 | + public class Employee { | ||
| 4 | + private Integer id; | ||
| 5 | + private String name; | ||
| 6 | + private Double salary; | ||
| 7 | + | ||
| 8 | + public Employee(Integer id, String name, Double salary) { | ||
| 9 | + this.id = id; | ||
| 10 | + this.name = name; | ||
| 11 | + this.salary = salary; | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + public Integer getId() { | ||
| 15 | + return id; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + public void setId(Integer id) { | ||
| 19 | + this.id = id; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public String getName() { | ||
| 23 | + return name; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public void setName(String name) { | ||
| 27 | + this.name = name; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public Double getSalary() { | ||
| 31 | + return salary; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public void setSalary(Double salary) { | ||
| 35 | + this.salary = salary; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void salaryIncrement(Double percentage) { | ||
| 39 | + Double newSalary = salary + percentage * salary / 100; | ||
| 40 | + setSalary(newSalary); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String toString() { | ||
| 44 | + return "Id: " + id + " Name:" + name + " Price:" + salary; | ||
| 45 | + } | ||
| 46 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + package com.stackify.stream; | ||
| 2 | + | ||
| 3 | + import java.util.List; | ||
| 4 | + | ||
| 5 | + public class EmployeeRepository { | ||
| 6 | + private List<Employee> empList; | ||
| 7 | + | ||
| 8 | + public EmployeeRepository(List<Employee> empList) { | ||
| 9 | + this.empList = empList; | ||
| 10 | + | ||
| 11 | + } | ||
| 12 | + public Employee findById(Integer id) { | ||
| 13 | + for (Employee emp : empList) { | ||
| 14 | + if (emp.getId() == id) { | ||
| 15 | + return emp; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + return null; | ||
| 20 | + } | ||
| 21 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments