• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codenotary / immudb4j / #127

pending completion
#127

push

github-actions

web-flow
Merge pull request #55 from Lonko/fix/timestamp_conversion

1 of 1 new or added line in 1 file covered. (100.0%)

1447 of 1758 relevant lines covered (82.31%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.19
/src/main/java/io/codenotary/immudb4j/sql/SQLValue.java
1

2
/*
3
Copyright 2022 CodeNotary, Inc. All rights reserved.
4

5
Licensed under the Apache License, Version 2.0 (the "License");
6
you may not use this file except in compliance with the License.
7
You may obtain a copy of the License at
8

9
        http://www.apache.org/licenses/LICENSE-2.0
10

11
Unless required by applicable law or agreed to in writing, software
12
distributed under the License is distributed on an "AS IS" BASIS,
13
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
See the License for the specific language governing permissions and
15
limitations under the License.
16
*/
17
package io.codenotary.immudb4j.sql;
18

19
import java.util.Date;
20
import java.util.concurrent.TimeUnit;
21

22
import io.codenotary.immudb.ImmudbProto;
23
import io.codenotary.immudb4j.Utils;
24

25
public class SQLValue {
26
    
27
    private ImmudbProto.SQLValue value;
28

29
    public SQLValue(Boolean value) {
1✔
30
        final ImmudbProto.SQLValue.Builder builder = ImmudbProto.SQLValue.newBuilder();
1✔
31

32
        if (value == null) {
1✔
33
            builder.setNull(null);
×
34
        } else {
35
            builder.setB(value);
1✔
36
        }
37

38
        this.value = builder.build();   
1✔
39
    }
1✔
40

41
    public SQLValue(Integer value) {
1✔
42
        final ImmudbProto.SQLValue.Builder builder = ImmudbProto.SQLValue.newBuilder();
1✔
43

44
        if (value == null) {
1✔
45
            builder.setNull(null);
×
46
        } else {
47
            builder.setN(value);
1✔
48
        }
49

50
        this.value = builder.build();   
1✔
51
    }
1✔
52

53
    public SQLValue(Long value) {
×
54
        final ImmudbProto.SQLValue.Builder builder = ImmudbProto.SQLValue.newBuilder();
×
55

56
        if (value == null) {
×
57
            builder.setNull(null);
×
58
        } else {
59
            builder.setN(value);
×
60
        }
61

62
        this.value = builder.build();   
×
63
    }
×
64

65
    public SQLValue(String value) {
1✔
66
        final ImmudbProto.SQLValue.Builder builder = ImmudbProto.SQLValue.newBuilder();
1✔
67

68
        if (value == null) {
1✔
69
            builder.setNull(null);
×
70
        } else {
71
            builder.setS(value);
1✔
72
        }
73

74
        this.value = builder.build();   
1✔
75
    }
1✔
76

77
    public SQLValue(Date value) {
×
78
        final ImmudbProto.SQLValue.Builder builder = ImmudbProto.SQLValue.newBuilder();
×
79

80
        if (value == null) {
×
81
            builder.setNull(null);
×
82
        } else {
83
            builder.setTs(TimeUnit.MILLISECONDS.toMicros(value.getTime()));
×
84
        }
85

86
        this.value = builder.build();   
×
87
    }
×
88

89
    public SQLValue(byte[] value) {
×
90
        final ImmudbProto.SQLValue.Builder builder = ImmudbProto.SQLValue.newBuilder();
×
91

92
        if (value == null) {
×
93
            builder.setNull(null);
×
94
        } else {
95
            builder.setBs(Utils.toByteString(value));
×
96
        }
97

98
        this.value = builder.build();   
×
99
    }
×
100

101
    public ImmudbProto.SQLValue asProtoSQLValue() {
102
        return value;
1✔
103
    }
104

105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc