本文整理汇总了Java中com.arangodb.velocypack.VPackBuilder类的典型用法代码示例。如果您正苦于以下问题:Java VPackBuilder类的具体用法?Java VPackBuilder怎么用?Java VPackBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VPackBuilder类属于com.arangodb.velocypack包,在下文中一共展示了VPackBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toBoolean
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toBoolean() throws IOException {
final VPackBuilder builder = new VPackBuilder();
{
builder.add(ValueType.OBJECT);
builder.add("a", false);
builder.add("b", true);
builder.add("c", Boolean.FALSE);
builder.add("d", Boolean.TRUE);
builder.close();
}
final VPackSlice vpack = builder.slice();
final TestEntityBoolean entity = mapper.readValue(vpack.getBuffer(), TestEntityBoolean.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.a, is(false));
assertThat(entity.b, is(true));
assertThat(entity.c, is(Boolean.FALSE));
assertThat(entity.d, is(Boolean.TRUE));
}
示例2: toStrings
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toStrings() throws IOException {
final VPackBuilder builder = new VPackBuilder();
{
builder.add(ValueType.OBJECT);
builder.add("s", "abc");
builder.add("c1", 'd');
builder.add("c2", 'd');
builder.close();
}
final VPackSlice vpack = builder.slice();
final TestEntityString entity = mapper.readValue(vpack.getBuffer(), TestEntityString.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.s, is("abc"));
assertThat(entity.c1, is(new Character('d')));
assertThat(entity.c1, is(new Character('d')));
}
示例3: toCollectionExtendedWithNulls
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toCollectionExtendedWithNulls() throws Exception {
final VPackBuilder builder = new VPackBuilder();
{
builder.add(ValueType.OBJECT);
{
builder.add("a1", ValueType.ARRAY);
builder.add("one");
builder.add(ValueType.NULL);
builder.add("two");
builder.close();
}
builder.close();
}
final VPackSlice vpack = builder.slice();
final TestEntityCollectionExtendedWithNulls entity = mapper.readValue(vpack.getBuffer(),
TestEntityCollectionExtendedWithNulls.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.getA1(), is(notNullValue()));
assertThat(entity.getA1().size(), is(3));
assertThat(entity.getA1(), contains("one", null, "two"));
}
示例4: toObjectInArray
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toObjectInArray() throws IOException {
final VPackBuilder builder = new VPackBuilder();
{
builder.add(ValueType.OBJECT);
builder.add("a1", ValueType.ARRAY);
{
builder.add(ValueType.OBJECT);
builder.add("s", "abc");
builder.close();
}
builder.close();
builder.close();
}
final VPackSlice vpack = builder.slice();
final TestEntityObjectInArray entity = mapper.readValue(vpack.getBuffer(), TestEntityObjectInArray.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.a1, is(notNullValue()));
assertThat(entity.a1.length, is(1));
final TestEntityString st = entity.a1[0];
assertThat(st, is(notNullValue()));
assertThat(st.s, is("abc"));
}
示例5: toInterface
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toInterface() throws IOException {
final VPackBuilder builder = new VPackBuilder();
{
builder.add(ValueType.OBJECT);
builder.add("d", ValueType.OBJECT);
builder.add("d", "test");
builder.close();
builder.close();
}
final VPackSlice slice = builder.slice();
final VPack vPack = new VPack.Builder()
.registerInstanceCreator(TestEntityD.class, new VPackInstanceCreator<TestEntityD>() {
@Override
public TestEntityD createInstance() {
return new TestEntityDImpl();
}
}).build();
final TestEntityC entity = vPack.deserialize(slice, TestEntityC.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.d, is(notNullValue()));
assertThat(entity.d.getD(), is("test"));
}
示例6: toObjectWithAttributeAdapter
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toObjectWithAttributeAdapter() throws IOException {
final VPackBuilder builder = new VPackBuilder();
{
builder.add(ValueType.OBJECT);
builder.add("_key", "a");
builder.add("_rev", "b");
builder.add("_id", "c");
builder.add("_from", "d");
builder.add("_to", "e");
builder.close();
}
final TestEntityBaseAttributes entity = mapper.readValue(builder.slice().getBuffer(),
TestEntityBaseAttributes.class);
assertThat(entity, is(notNullValue()));
assertThat(entity._key, is("a"));
assertThat(entity._rev, is("b"));
assertThat(entity._id, is("c"));
assertThat(entity._from, is("d"));
assertThat(entity._to, is("e"));
}
示例7: toMapWithAttributeAdapter
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toMapWithAttributeAdapter() throws IOException {
final VPackBuilder builder = new VPackBuilder();
{
builder.add(ValueType.OBJECT);
builder.add("m1", ValueType.OBJECT);
builder.add("_key", "a");
builder.add("_rev", "b");
builder.add("_id", "c");
builder.add("_from", "d");
builder.add("_to", "e");
builder.close();
builder.close();
}
final TestEntityMap entity = mapper.readValue(builder.slice().getBuffer(), TestEntityMap.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.m1, is(notNullValue()));
assertThat(entity.m1.size(), is(5));
}
示例8: directToCollection
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void directToCollection() throws IOException {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.ARRAY);
builder.add(ValueType.OBJECT);
builder.add("s", "abc");
builder.close();
builder.close();
final List<TestEntityString> list = mapper.readValue(builder.slice().getBuffer(),
new TypeReference<List<TestEntityString>>() {
});
assertThat(list, is(notNullValue()));
assertThat(list.size(), is(1));
final TestEntityString entry = list.get(0);
assertThat(entry.s, is("abc"));
}
示例9: directToStringMap
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void directToStringMap() throws IOException {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.OBJECT);
builder.add("a", ValueType.OBJECT);
builder.add("s", "abc");
builder.close();
builder.close();
final Map<String, TestEntityString> map = mapper.readValue(builder.slice().getBuffer(),
new TypeReference<Map<String, TestEntityString>>() {
});
assertThat(map, is(notNullValue()));
assertThat(map.size(), is(1));
final TestEntityString a = map.get("a");
assertThat(a, is(notNullValue()));
assertThat(a.s, is("abc"));
}
示例10: directToObjectMap
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void directToObjectMap() throws IOException {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.ARRAY);
builder.add(ValueType.OBJECT);
builder.add("key", ValueType.OBJECT);
builder.add("s", "abc");
builder.close();
builder.add("value", ValueType.OBJECT);
builder.add("s", "abc");
builder.close();
builder.close();
builder.close();
final Map<TestEntityString, TestEntityString> map = mapper.readValue(builder.slice().getBuffer(),
new TypeReference<Map<TestEntityString, TestEntityString>>() {
});
assertThat(map, is(notNullValue()));
assertThat(map.size(), is(1));
for (final Entry<TestEntityString, TestEntityString> entry : map.entrySet()) {
assertThat(entry.getKey().s, is("abc"));
assertThat(entry.getValue().s, is("abc"));
}
}
示例11: fieldNamingStrategyDeserialize
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void fieldNamingStrategyDeserialize() throws IOException {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.OBJECT);
builder.add("bla", "test");
builder.close();
final ObjectMapper mapper = new VPackMapper();
mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
private static final long serialVersionUID = 1L;
@Override
public String nameForSetterMethod(
final MapperConfig<?> config,
final AnnotatedMethod method,
final String defaultName) {
return "bla";
}
});
final TestEntityA entity = mapper.readValue(builder.slice().getBuffer(), TestEntityA.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.a, is("test"));
}
示例12: deserializeOptional
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserializeOptional() {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.OBJECT);
builder.add("s", "hello world");
builder.add("i", 69);
builder.add("o", ValueType.OBJECT).close();
builder.close();
final OptionalTestEntity entity = vp.deserialize(builder.slice(), OptionalTestEntity.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.s.isPresent(), is(true));
assertThat(entity.s.get(), is("hello world"));
assertThat(entity.i.isPresent(), is(true));
assertThat(entity.i.get(), is(69));
assertThat(entity.o.isPresent(), is(true));
}
示例13: deserializeOptionalNull
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserializeOptionalNull() {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.OBJECT);
builder.add("s", ValueType.NULL);
builder.add("i", ValueType.NULL);
builder.add("o", ValueType.NULL);
builder.add("e", ValueType.NULL);
builder.close();
final OptionalTestEntity entity = vp.deserialize(builder.slice(), OptionalTestEntity.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.s, is(notNullValue()));
assertThat(entity.s.isPresent(), is(false));
assertThat(entity.i, is(notNullValue()));
assertThat(entity.i.isPresent(), is(false));
assertThat(entity.o, is(notNullValue()));
assertThat(entity.o.isPresent(), is(false));
assertThat(entity.e, is(notNullValue()));
assertThat(entity.e.isPresent(), is(false));
}
示例14: deserializeOptionalPrimitive
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserializeOptionalPrimitive() {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.OBJECT);
builder.add("d", 69.5);
builder.add("i", 69);
builder.add("l", 69L);
builder.close();
final OptionalPrimitiveTestEntity entity = vp.deserialize(builder.slice(), OptionalPrimitiveTestEntity.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.d.isPresent(), is(true));
assertThat(entity.d.getAsDouble(), is(69.5));
assertThat(entity.i.isPresent(), is(true));
assertThat(entity.i.getAsInt(), is(69));
assertThat(entity.l.isPresent(), is(true));
assertThat(entity.l.getAsLong(), is(69L));
}
示例15: deserializeOptionalPrimitiveNull
import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserializeOptionalPrimitiveNull() {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.OBJECT);
builder.add("d", ValueType.NULL);
builder.add("i", ValueType.NULL);
builder.add("l", ValueType.NULL);
builder.close();
final OptionalPrimitiveTestEntity entity = vp.deserialize(builder.slice(), OptionalPrimitiveTestEntity.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.d, is(notNullValue()));
assertThat(entity.d.isPresent(), is(false));
assertThat(entity.i, is(notNullValue()));
assertThat(entity.i.isPresent(), is(false));
assertThat(entity.l, is(notNullValue()));
assertThat(entity.l.isPresent(), is(false));
}