Skip to content

Commit 012a46f

Browse files
committed
adding blank node factory to ValueFactory
1 parent e4e8135 commit 012a46f

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/main/java/fr/inria/corese/core/next/impl/temp/CoreseAdaptedValueFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414
import java.time.temporal.TemporalAccessor;
1515
import java.time.temporal.TemporalAmount;
1616
import java.util.Date;
17+
import java.util.concurrent.ThreadLocalRandom;
18+
import java.util.concurrent.atomic.AtomicLong;
1719

1820
public class CoreseAdaptedValueFactory implements ValueFactory {
1921

2022
private static Logger logger = LoggerFactory.getLogger(CoreseAdaptedValueFactory.class);
2123

24+
private final AtomicLong nodeID = new AtomicLong(ThreadLocalRandom.current().nextLong());
25+
2226
public CoreseAdaptedValueFactory() {
2327
}
2428

@@ -34,12 +38,12 @@ public IRI createIRI(String namespace, String localName) {
3438

3539
@Override
3640
public BNode createBNode() {
37-
return null;
41+
return new CoreseBNode(Long.toHexString(Math.abs(nodeID.getAndIncrement())));
3842
}
3943

4044
@Override
4145
public BNode createBNode(String nodeID) {
42-
return null;
46+
return new CoreseBNode(nodeID);
4347
}
4448

4549
@Override

src/test/java/fr/inria/corese/core/next/api/model/ValueFactoryTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fr.inria.corese.core.next.api.model;
22

3+
import fr.inria.corese.core.next.api.BNode;
34
import fr.inria.corese.core.next.api.Literal;
45
import fr.inria.corese.core.next.api.ValueFactory;
56
import fr.inria.corese.core.next.impl.exception.IncorrectFormatException;
@@ -40,6 +41,14 @@ public void testCreateIRI() {
4041

4142
@Test
4243
public void testCreateBNode() {
44+
String nodeId = "corese123";
45+
BNode nodesCorese123 = this.valueFactory.createBNode(nodeId);
46+
BNode nodesCoreseRandom = this.valueFactory.createBNode();
47+
48+
assertNotNull(nodesCorese123);
49+
assertNotNull(nodesCoreseRandom);
50+
assertNotNull(nodesCoreseRandom.getID());
51+
assertEquals(nodesCorese123.getID(), "corese123");
4352
}
4453

4554
@Test

0 commit comments

Comments
 (0)