Skip to content

Commit 7d411af

Browse files
gumrealgumreal
gumreal
authored and
gumreal
committed
facet
1 parent 878293b commit 7d411af

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ apply plugin: 'signing'
4141

4242
group = 'io.dgraph'
4343
archivesBaseName = 'dgraph4j'
44-
version = '21.03.2.p11.20220221a'
44+
version = '21.03.2.p12.20220221b'
4545
sourceCompatibility = 1.8
4646
targetCompatibility = 1.8
4747

src/main/java/io/dgraph/wrapper/model/NQuadHelper.java

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,51 @@ public static DgraphProto.NQuad newNQuadEdgeWithFacets(
8383
* @param value
8484
* @return
8585
*/
86-
public static DgraphProto.Facet newFacet(String key, Object value) {
87-
DgraphProto.Facet.ValType valType = DgraphProto.Facet.ValType.STRING;
88-
if (null != valType) {
89-
if (value instanceof Integer) {
90-
valType = DgraphProto.Facet.ValType.INT;
91-
} else if (value instanceof Float) {
92-
valType = DgraphProto.Facet.ValType.FLOAT;
93-
} else if (value instanceof Boolean) {
94-
valType = DgraphProto.Facet.ValType.BOOL;
95-
}
96-
}
86+
public static DgraphProto.Facet newFacet(String key, Integer value) {
9787
return DgraphProto.Facet.newBuilder()
9888
.setKey(key)
99-
.setValType(valType)
100-
.setValue(ByteString.copyFromUtf8((null == value) ? "" : value.toString()))
89+
.setValType(DgraphProto.Facet.ValType.INT)
90+
.setValue(ByteString.copyFromUtf8((null == value) ? "0" : value.toString()))
10191
.build();
10292
}
93+
94+
/**
95+
* @param key
96+
* @param value
97+
* @return
98+
*/
99+
public static DgraphProto.Facet newFacet(String key, Float value) {
100+
return DgraphProto.Facet.newBuilder()
101+
.setKey(key)
102+
.setValType(DgraphProto.Facet.ValType.FLOAT)
103+
.setValue(ByteString.copyFromUtf8((null == value) ? "0.0" : value.toString()))
104+
.build();
105+
106+
}
107+
/**
108+
* @param key
109+
* @param value
110+
* @return
111+
*/
112+
public static DgraphProto.Facet newFacet(String key, String value) {
113+
return DgraphProto.Facet.newBuilder()
114+
.setKey(key)
115+
.setValType(DgraphProto.Facet.ValType.STRING)
116+
.setValue(ByteString.copyFromUtf8((null == value) ? "" : value.toString()))
117+
.build();
118+
119+
}
120+
/**
121+
* @param key
122+
* @param value
123+
* @return
124+
*/
125+
public static DgraphProto.Facet newFacet(String key, Boolean value) {
126+
return DgraphProto.Facet.newBuilder()
127+
.setKey(key)
128+
.setValType(DgraphProto.Facet.ValType.BOOL)
129+
.setValue(ByteString.copyFromUtf8((null == value) ? "FALSE" : value.toString()))
130+
.build();
131+
132+
}
103133
}

0 commit comments

Comments
 (0)