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 |
|
|
|
|
| 4.8% |
Uncovered Elements: 40 (42) |
Complexity: 13 |
Complexity Density: 0.62 |
|
8 |
|
public class FlakeSQLTypeDescriptor extends AbstractTypeDescriptor<Identifier> { |
9 |
|
|
10 |
|
public static final FlakeSQLTypeDescriptor INSTANCE = new FlakeSQLTypeDescriptor(); |
11 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
12 |
1 |
public FlakeSQLTypeDescriptor() {... |
13 |
1 |
super(Identifier.class); |
14 |
|
} |
15 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
16 |
0 |
@Override... |
17 |
|
public String toString(Identifier value) { |
18 |
0 |
return FlakeIdentifierTransformer.INSTANCE.transform(value); |
19 |
|
} |
20 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
21 |
0 |
@Override... |
22 |
|
public Identifier fromString(String string) { |
23 |
0 |
return FlakeIdentifierTransformer.INSTANCE.parse(string); |
24 |
|
} |
25 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.56 |
|
26 |
0 |
@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 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.56 |
|
46 |
0 |
@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 |
|
} |