1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.healthmarketscience.jackcess.impl.expr;
18
19 import java.math.BigDecimal;
20 import java.time.LocalDateTime;
21
22 import com.healthmarketscience.jackcess.expr.LocaleContext;
23 import com.healthmarketscience.jackcess.expr.Value;
24
25
26
27
28
29 public abstract class BaseDelayedValue implements Value
30 {
31 private Value _val;
32
33 protected BaseDelayedValue() {
34 }
35
36 private Value getDelegate() {
37 if(_val == null) {
38 _val = eval();
39 }
40 return _val;
41 }
42
43 @Override
44 public boolean isNull() {
45 return(getType() == Type.NULL);
46 }
47
48 @Override
49 public Value.Type getType() {
50 return getDelegate().getType();
51 }
52
53 @Override
54 public Object get() {
55 return getDelegate().get();
56 }
57
58 @Override
59 public boolean getAsBoolean(LocaleContext ctx) {
60 return getDelegate().getAsBoolean(ctx);
61 }
62
63 @Override
64 public String getAsString(LocaleContext ctx) {
65 return getDelegate().getAsString(ctx);
66 }
67
68 @Override
69 public LocalDateTime getAsLocalDateTime(LocaleContext ctx) {
70 return getDelegate().getAsLocalDateTime(ctx);
71 }
72
73 @Override
74 public Value getAsDateTimeValue(LocaleContext ctx) {
75 return getDelegate().getAsDateTimeValue(ctx);
76 }
77
78 @Override
79 public Integer getAsLongInt(LocaleContext ctx) {
80 return getDelegate().getAsLongInt(ctx);
81 }
82
83 @Override
84 public Double getAsDouble(LocaleContext ctx) {
85 return getDelegate().getAsDouble(ctx);
86 }
87
88 @Override
89 public BigDecimal getAsBigDecimal(LocaleContext ctx) {
90 return getDelegate().getAsBigDecimal(ctx);
91 }
92
93 protected abstract Value eval();
94 }