Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.persist.hibernate.types

File FlakeSQLTypeDescriptor.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart1.png
48% of files have more coverage

Code metrics

16
21
5
1
64
52
13
0.62
4.2
5
2.6

Classes

Class Line # Actions
FlakeSQLTypeDescriptor 8 21 13
0.047619054.8%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.persist.hibernate.types;
2   
3    import io.sunshower.common.Identifier;
4    import io.sunshower.common.Identifiers;
5    import org.hibernate.type.descriptor.WrapperOptions;
6    import org.hibernate.type.descriptor.java.AbstractTypeDescriptor;
7   
 
8    public class FlakeSQLTypeDescriptor extends AbstractTypeDescriptor<Identifier> {
9   
10    public static final FlakeSQLTypeDescriptor INSTANCE = new FlakeSQLTypeDescriptor();
11   
 
12  1 toggle public FlakeSQLTypeDescriptor() {
13  1 super(Identifier.class);
14    }
15   
 
16  0 toggle @Override
17    public String toString(Identifier value) {
18  0 return FlakeIdentifierTransformer.INSTANCE.transform(value);
19    }
20   
 
21  0 toggle @Override
22    public Identifier fromString(String string) {
23  0 return FlakeIdentifierTransformer.INSTANCE.parse(string);
24    }
25   
 
26  0 toggle @Override
27    @SuppressWarnings("unchecked")
28    public <X> X unwrap(Identifier value, Class<X> type, WrapperOptions options) {
29   
30  0 if (value == null) {
31  0 return null;
32    }
33   
34  0 if (Identifier.class.isAssignableFrom(type)) {
35  0 return (X) value;
36    }
37  0 if (String.class.isAssignableFrom(type)) {
38  0 return (X) FlakeIdentifierTransformer.INSTANCE.transform(value);
39    }
40  0 if (byte[].class.isAssignableFrom(type)) {
41  0 return (X) Identifiers.getBytes(value);
42    }
43  0 throw unknownUnwrap(type);
44    }
45   
 
46  0 toggle @Override
47    public <X> Identifier wrap(X value, WrapperOptions options) {
48  0 if (value == null) {
49  0 return null;
50    }
51   
52  0 if (Identifier.class.isInstance(value)) {
53  0 return (Identifier) value;
54    }
55   
56  0 if (String.class.isInstance(value)) {
57  0 return Identifier.valueOf((String) value);
58    }
59  0 if (byte[].class.isInstance(value)) {
60  0 return Identifier.valueOf((byte[]) value);
61    }
62  0 throw unknownUnwrap(value.getClass());
63    }
64    }