Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.persistence.core.converters

File ClassConverter.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart4.png
43% of files have more coverage

Code metrics

4
5
2
1
22
18
5
1
2.5
2
2.5

Classes

Class Line # Actions
ClassConverter 5 5 5
0.3636363736.4%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    package io.sunshower.persistence.core.converters;
2   
3    import javax.persistence.AttributeConverter;
4   
 
5    public class ClassConverter implements AttributeConverter<Class<?>, String> {
 
6  2 toggle @Override
7    public String convertToDatabaseColumn(Class<?> attribute) {
8  2 return attribute != null ? attribute.getName() : Void.class.getName();
9    }
10   
 
11  0 toggle @Override
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    }