From 72278254691196df77b8598659360f61fb64e52f Mon Sep 17 00:00:00 2001 From: Pavan Jadda Date: Sat, 25 Jul 2020 00:01:02 -0400 Subject: [PATCH] Add Employee entity and repository classes --- .../java/com/pj/liquibasedemo/domain/Employee.java | 1 + .../domain/EmploymentTypeConverter.java | 13 ++----------- src/test/java/com/pj/liquibasedemo/EnumTest.java | 11 +++++++++++ 3 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 src/test/java/com/pj/liquibasedemo/EnumTest.java diff --git a/src/main/java/com/pj/liquibasedemo/domain/Employee.java b/src/main/java/com/pj/liquibasedemo/domain/Employee.java index f7c9494..efa128f 100755 --- a/src/main/java/com/pj/liquibasedemo/domain/Employee.java +++ b/src/main/java/com/pj/liquibasedemo/domain/Employee.java @@ -36,4 +36,5 @@ public class Employee @Column(name = "employment_type") @Convert(converter = EmploymentTypeConverter.class) private EmploymentType employmentType; + } diff --git a/src/main/java/com/pj/liquibasedemo/domain/EmploymentTypeConverter.java b/src/main/java/com/pj/liquibasedemo/domain/EmploymentTypeConverter.java index c342110..a74373f 100644 --- a/src/main/java/com/pj/liquibasedemo/domain/EmploymentTypeConverter.java +++ b/src/main/java/com/pj/liquibasedemo/domain/EmploymentTypeConverter.java @@ -7,25 +7,16 @@ @Converter(autoApply = true) public class EmploymentTypeConverter implements AttributeConverter { - @Override public String convertToDatabaseColumn(EmploymentType employmentType) { - if (employmentType == null) - { - return null; - } - return employmentType.getLabel(); + return employmentType == null ? null : employmentType.getLabel(); } @Override public EmploymentType convertToEntityAttribute(String label) { - if (label == null) - { - return null; - } - return Stream.of(EmploymentType.values()) + return label == null ? null : Stream.of(EmploymentType.values()) .filter(c -> c.getLabel().equals(label)) .findFirst() .orElseThrow(IllegalArgumentException::new); diff --git a/src/test/java/com/pj/liquibasedemo/EnumTest.java b/src/test/java/com/pj/liquibasedemo/EnumTest.java new file mode 100644 index 0000000..b2429b4 --- /dev/null +++ b/src/test/java/com/pj/liquibasedemo/EnumTest.java @@ -0,0 +1,11 @@ +package com.pj.liquibasedemo; + +import com.pj.liquibasedemo.domain.EmploymentType; + +public class EnumTest +{ + public static void main(String[] args) + { + System.out.println(EmploymentType.CONTRACTOR.toString().equals("CONTRACTOR")); + } +}