Skip to content

Commit

Permalink
Add Employee entity and repository classes
Browse files Browse the repository at this point in the history
  • Loading branch information
pavankjadda committed Jul 25, 2020
1 parent df3a0e8 commit 7227825
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/pj/liquibasedemo/domain/Employee.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ public class Employee
@Column(name = "employment_type")
@Convert(converter = EmploymentTypeConverter.class)
private EmploymentType employmentType;

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,16 @@
@Converter(autoApply = true)
public class EmploymentTypeConverter implements AttributeConverter<EmploymentType, String>
{

@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);
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/com/pj/liquibasedemo/EnumTest.java
Original file line number Diff line number Diff line change
@@ -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"));
}
}

0 comments on commit 7227825

Please sign in to comment.