001package org.hl7.fhir.r5.utils.sql; 002 003import java.math.BigDecimal; 004import java.util.Date; 005 006import org.hl7.fhir.r5.model.Base; 007 008 009/** 010 * String value is always provided, and a more specific value may also be provided 011 */ 012 013public class Value { 014 015 private String valueString; 016 private Boolean valueBoolean; 017 private Date valueDate; 018 private Integer valueInt; 019 private BigDecimal valueDecimal; 020 private byte[] valueBinary; 021 private Base valueComplex; 022 023 private Value() { 024 super(); 025 } 026 027 public static Value makeString(String s) { 028 Value v = new Value(); 029 v.valueString = s; 030 return v; 031 } 032 033 public static Value makeBoolean(String s, Boolean b) { 034 Value v = new Value(); 035 v.valueString = s; 036 v.valueBoolean = b; 037 return v; 038 } 039 040 public static Value makeDate(String s, Date d) { 041 Value v = new Value(); 042 v.valueString = s; 043 v.valueDate = d; 044 return v; 045 } 046 047 public static Value makeInteger(String s, Integer i) { 048 Value v = new Value(); 049 v.valueString = s; 050 v.valueInt = i; 051 return v; 052 } 053 054 055 public static Value makeDecimal(String s, BigDecimal bigDecimal) { 056 Value v = new Value(); 057 v.valueString = s; 058 v.valueDecimal = bigDecimal; 059 return v; 060 } 061 062 public static Value makeBinary(String s, byte[] b) { 063 Value v = new Value(); 064 v.valueString = s; 065 v.valueBinary = b; 066 return v; 067 } 068 069 public static Value makeComplex(Base b) { 070 Value v = new Value(); 071 v.valueComplex = b; 072 return v; 073 } 074 public String getValueString() { 075 return valueString; 076 } 077 078 public Date getValueDate() { 079 return valueDate; 080 } 081 082 public Integer getValueInt() { 083 return valueInt; 084 } 085 086 public BigDecimal getValueDecimal() { 087 return valueDecimal; 088 } 089 090 public byte[] getValueBinary() { 091 return valueBinary; 092 } 093 094 public Boolean getValueBoolean() { 095 return valueBoolean; 096 } 097 098 public Base getValueComplex() { 099 return valueComplex; 100 } 101 102 public boolean hasValueString() { 103 return valueString != null; 104 } 105 106 public boolean hasValueDate() { 107 return valueDate != null; 108 } 109 110 public boolean hasValueInt() { 111 return valueInt != null; 112 } 113 114 public boolean hasValueDecimal() { 115 return valueDecimal != null; 116 } 117 118 public boolean hasValueBinary() { 119 return valueBinary != null; 120 } 121 122 public boolean hasValueBoolean() { 123 return valueBoolean != null; 124 } 125 126 public boolean hasValueComplex() { 127 return valueComplex != null; 128 } 129}