-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add experimental java records support
- Loading branch information
Showing
6 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/name/velikodniy/vitaliy/fixedlength/EmployeeRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package name.velikodniy.vitaliy.fixedlength; | ||
|
||
import name.velikodniy.vitaliy.fixedlength.annotation.FixedField; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
|
||
/** | ||
* this class emulates built java 14+'s record as follows | ||
* record EmployeeRecord( | ||
* @FixedField(offset = 1, length = 10, align = Align.LEFT) | ||
* String firstName, | ||
* @FixedField(offset = 11, length = 10, align = Align.LEFT) | ||
* String lastName, | ||
* @FixedField(offset = 21, length = 10, align = Align.LEFT) | ||
* String title, | ||
* @FixedField(offset = 31, length = 6, padding = '0') | ||
* BigDecimal salary, | ||
* @FixedField(offset = 37, length = 8, format = "MMddyyyy") | ||
* LocalDate hireDate | ||
* ){} | ||
*/ | ||
class EmployeeRecord{ | ||
@FixedField(offset = 1, length = 10, align = Align.LEFT) | ||
public String firstName; | ||
@FixedField(offset = 11, length = 10, align = Align.LEFT) | ||
public String lastName; | ||
@FixedField(offset = 21, length = 10, align = Align.LEFT) | ||
public String title; | ||
@FixedField(offset = 31, length = 6, padding = '0') | ||
public BigDecimal salary; | ||
@FixedField(offset = 37, length = 8, format = "MMddyyyy") | ||
public LocalDate hireDate; | ||
|
||
public EmployeeRecord(String firstName, String lastName, String title, BigDecimal salary, LocalDate hireDate) { | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
this.title = title; | ||
this.salary = salary; | ||
this.hireDate = hireDate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters