Class | Line # | Actions | |||
---|---|---|---|---|---|
ClassConverter | 5 | 5 | 5 |
1 | package io.sunshower.persistence.core.converters; | |
2 | ||
3 | import javax.persistence.AttributeConverter; | |
4 | ||
5 | public class ClassConverter implements AttributeConverter<Class<?>, String> { | |
6 | 2 | ![]() |
7 | public String convertToDatabaseColumn(Class<?> attribute) { | |
8 | 2 | return attribute != null ? attribute.getName() : Void.class.getName(); |
9 | } | |
10 | ||
11 | 0 | ![]() |
12 | public Class<?> convertToEntityAttribute(String dbData) { | |
13 | 0 | if (dbData != null) { |
14 | 0 | try { |
15 | 0 | return Class.forName(dbData); |
16 | } catch (Exception ex) { | |
17 | ||
18 | } | |
19 | } | |
20 | 0 | return Void.class; |
21 | } | |
22 | } |