本文整理汇总了Java中com.fasterxml.jackson.databind.node.BooleanNode类的典型用法代码示例。如果您正苦于以下问题:Java BooleanNode类的具体用法?Java BooleanNode怎么用?Java BooleanNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BooleanNode类属于com.fasterxml.jackson.databind.node包,在下文中一共展示了BooleanNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: arrayWithUniqueItemsProducesSet
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Test
public void arrayWithUniqueItemsProducesSet() {
JCodeModel codeModel = new JCodeModel();
JPackage jpackage = codeModel._package(getClass().getPackage().getName());
ObjectMapper mapper = new ObjectMapper();
ObjectNode itemsNode = mapper.createObjectNode();
itemsNode.put("type", "integer");
ObjectNode propertyNode = mapper.createObjectNode();
propertyNode.set("uniqueItems", BooleanNode.TRUE);
propertyNode.set("items", itemsNode);
JClass propertyType = rule.apply("fooBars", propertyNode, jpackage, mock(Schema.class));
assertThat(propertyType, notNullValue());
assertThat(propertyType.erasure(), is(codeModel.ref(Set.class)));
assertThat(propertyType.getTypeParameters().get(0).fullName(), is(Integer.class.getName()));
}
示例2: arrayWithNonUniqueItemsProducesList
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Test
public void arrayWithNonUniqueItemsProducesList() {
JCodeModel codeModel = new JCodeModel();
JPackage jpackage = codeModel._package(getClass().getPackage().getName());
ObjectMapper mapper = new ObjectMapper();
ObjectNode itemsNode = mapper.createObjectNode();
itemsNode.put("type", "number");
ObjectNode propertyNode = mapper.createObjectNode();
propertyNode.set("uniqueItems", BooleanNode.FALSE);
propertyNode.set("items", itemsNode);
Schema schema = mock(Schema.class);
when(schema.getId()).thenReturn(URI.create("http://example/nonUniqueArray"));
when(config.isUseDoubleNumbers()).thenReturn(true);
JClass propertyType = rule.apply("fooBars", propertyNode, jpackage, schema);
assertThat(propertyType, notNullValue());
assertThat(propertyType.erasure(), is(codeModel.ref(List.class)));
assertThat(propertyType.getTypeParameters().get(0).fullName(), is(Double.class.getName()));
}
示例3: arrayOfPrimitivesProducesCollectionOfWrapperTypes
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Test
public void arrayOfPrimitivesProducesCollectionOfWrapperTypes() {
JCodeModel codeModel = new JCodeModel();
JPackage jpackage = codeModel._package(getClass().getPackage().getName());
ObjectMapper mapper = new ObjectMapper();
ObjectNode itemsNode = mapper.createObjectNode();
itemsNode.put("type", "number");
ObjectNode propertyNode = mapper.createObjectNode();
propertyNode.set("uniqueItems", BooleanNode.FALSE);
propertyNode.set("items", itemsNode);
Schema schema = mock(Schema.class);
when(schema.getId()).thenReturn(URI.create("http://example/nonUniqueArray"));
when(config.isUsePrimitives()).thenReturn(true);
when(config.isUseDoubleNumbers()).thenReturn(true);
JClass propertyType = rule.apply("fooBars", propertyNode, jpackage, schema);
assertThat(propertyType, notNullValue());
assertThat(propertyType.erasure(), is(codeModel.ref(List.class)));
assertThat(propertyType.getTypeParameters().get(0).fullName(), is(Double.class.getName()));
}
示例4: arrayDefaultsToNonUnique
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Test
public void arrayDefaultsToNonUnique() {
JCodeModel codeModel = new JCodeModel();
JPackage jpackage = codeModel._package(getClass().getPackage().getName());
ObjectMapper mapper = new ObjectMapper();
ObjectNode itemsNode = mapper.createObjectNode();
itemsNode.put("type", "boolean");
ObjectNode propertyNode = mapper.createObjectNode();
propertyNode.set("uniqueItems", BooleanNode.FALSE);
propertyNode.set("items", itemsNode);
Schema schema = mock(Schema.class);
when(schema.getId()).thenReturn(URI.create("http://example/defaultArray"));
JClass propertyType = rule.apply("fooBars", propertyNode, jpackage, schema);
assertThat(propertyType.erasure(), is(codeModel.ref(List.class)));
}
示例5: get
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
public static JsonNode get( final PrimitiveObject obj ) throws IOException{
switch( obj.getPrimitiveType() ){
case BOOLEAN:
return BooleanNode.valueOf( obj.getBoolean() );
case BYTE:
return IntNode.valueOf( obj.getInt() );
case SHORT:
return IntNode.valueOf( obj.getInt() );
case INTEGER:
return IntNode.valueOf( obj.getInt() );
case LONG:
return new LongNode( obj.getLong() );
case FLOAT:
return new DoubleNode( obj.getDouble() );
case DOUBLE:
return new DoubleNode( obj.getDouble() );
case STRING:
return new TextNode( obj.getString() );
case BYTES:
return new BinaryNode( obj.getBytes() );
default:
return new TextNode( null );
}
}
示例6: activate
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Activate
public void activate() {
Serializer serializer = Serializer.using(KryoNamespaces.API,
ObjectNode.class, ArrayNode.class,
JsonNodeFactory.class, LinkedHashMap.class,
TextNode.class, BooleanNode.class,
LongNode.class, DoubleNode.class, ShortNode.class,
IntNode.class, NullNode.class);
prefsConsistentMap = storageService.<String, ObjectNode>consistentMapBuilder()
.withName(ONOS_USER_PREFERENCES)
.withSerializer(serializer)
.withRelaxedReadConsistency()
.build();
prefsConsistentMap.addListener(prefsListener);
prefs = prefsConsistentMap.asJavaMap();
register(core);
log.info("Started");
}
示例7: activate
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Activate
public void activate() {
KryoNamespace.Builder kryoBuilder = new KryoNamespace.Builder()
.register(KryoNamespaces.API)
.register(ConfigKey.class, ObjectNode.class, ArrayNode.class,
JsonNodeFactory.class, LinkedHashMap.class,
TextNode.class, BooleanNode.class,
LongNode.class, DoubleNode.class, ShortNode.class, IntNode.class,
NullNode.class);
configs = storageService.<ConfigKey, JsonNode>consistentMapBuilder()
.withSerializer(Serializer.using(kryoBuilder.build()))
.withName("onos-network-configs")
.withRelaxedReadConsistency()
.build();
configs.addListener(listener);
log.info("Started");
}
示例8: JQueryLoadedTestCase
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
public JQueryLoadedTestCase(String pageURL, List<String> blockPatterns, Object params) {
super(pageURL, blockPatterns);
// handle parameters
if (BooleanNode.class.isAssignableFrom(params.getClass())) {
_test = ((BooleanNode) params).asBoolean();
if (_test) {
_note = "";
} else {
_note = "not ";
}
} else {
_test = true;
_note = "";
}
setName(Tools.JQUERY + " " + _note + "loaded" + " - " + pageURL);
}
示例9: DTMLoadedTestCase
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
public DTMLoadedTestCase(String pageURL, List<String> blockPatterns, Object params) {
super(pageURL, blockPatterns);
// handle parameters
if (BooleanNode.class.isAssignableFrom(params.getClass())) {
_test = ((BooleanNode) params).asBoolean();
if (_test) {
_note = "";
} else {
_note = "not ";
}
} else {
_test = true;
_note = "";
}
setName(Tools.DTM + " " + _note + "loaded" + " - " + pageURL);
}
示例10: testJsonCompare
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Test
public void testJsonCompare() {
assertEquals(JsonUtils.compare(json(1), json(1)), 0);
assertEquals(JsonUtils.compare(json(1), json(2)), -1);
assertEquals(JsonUtils.compare(json(2), json(1)), 1);
assertEquals(JsonUtils.compare(json(1.0), json(1.0)), 0);
assertEquals(JsonUtils.compare(json(1.0), json(2.0)), -1);
assertEquals(JsonUtils.compare(json(2.0), json(1.0)), 1);
assertEquals(JsonUtils.compare(json("a"), json("a")), 0);
assertEquals(JsonUtils.compare(json("a"), json("b")), -1);
assertEquals(JsonUtils.compare(json("b"), json("a")), 1);
assertEquals(JsonUtils.compare(BooleanNode.TRUE, BooleanNode.TRUE), 0);
assertEquals(JsonUtils.compare(BooleanNode.FALSE, BooleanNode.FALSE), 0);
assertEquals(JsonUtils.compare(BooleanNode.TRUE, json("true")), 0);
assertEquals(JsonUtils.compare(BooleanNode.FALSE, json("false")), 0);
assertEquals(JsonUtils.compare(BooleanNode.TRUE, BooleanNode.FALSE), 1);
assertEquals(JsonUtils.compare(BooleanNode.FALSE, BooleanNode.TRUE), -1);
}
示例11: deserializePrimitiveTest
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Test public void deserializePrimitiveTest() {
assertEquals(Boolean.TRUE,
Deserializer.fromJson(TypeNode.fromString("bool"), BooleanNode.TRUE));
assertEquals(Boolean.FALSE,
Deserializer.fromJson(TypeNode.fromString("bool"), BooleanNode.FALSE));
assertEquals('a',
Deserializer.fromJson(TypeNode.fromString("char"), TextNode.valueOf("a")));
assertEquals(Integer.valueOf(123),
Deserializer.fromJson(TypeNode.fromString("int"), IntNode.valueOf(123)));
assertEquals(Long.valueOf(123),
Deserializer.fromJson(TypeNode.fromString("long"), IntNode.valueOf(123)));
assertEquals(Double.valueOf(123.0),
Deserializer.fromJson(TypeNode.fromString("double"), DoubleNode.valueOf(123.0)));
assertEquals("algohub",
Deserializer.fromJson(TypeNode.fromString("string"), TextNode.valueOf("algohub")));
}
示例12: primitiveToJsonTest
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Test public void primitiveToJsonTest() {
assertEquals(BooleanNode.TRUE, Serializer.toJson(true, TypeNode.fromString("bool")));
assertEquals(BooleanNode.FALSE, Serializer.toJson(false, TypeNode.fromString("bool")));
assertEquals(TextNode.valueOf("a"),
Serializer.toJson('a', TypeNode.fromString("char")));
assertEquals(IntNode.valueOf(123), Serializer.toJson(123, TypeNode.fromString("int")));
assertEquals(LongNode.valueOf(123), Serializer.toJson(123L, TypeNode.fromString("long")));
assertEquals(DoubleNode.valueOf(123.0),
Serializer.toJson(123.0, TypeNode.fromString("double")));
assertEquals(TextNode.valueOf("123"),
Serializer.toJson("123", TypeNode.fromString("string")));
}
示例13: toValueNode
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
@Deprecated
public static ValueNode toValueNode(Object value) {
if (value == null)
return NullNode.instance;
if (value instanceof ValueNode)
return (ValueNode) value;
if (value instanceof Boolean)
return BooleanNode.valueOf((boolean) value);
else if (value instanceof Integer)
return IntNode.valueOf((int) value);
else if (value instanceof Long)
return LongNode.valueOf((long) value);
else if (value instanceof Double)
return DoubleNode.valueOf((double) value);
else if (value instanceof Float)
return FloatNode.valueOf((float) value);
return TextNode.valueOf(value.toString());
}
示例14: toValueNode
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
public static ValueNode toValueNode(Object value) {
if (value == null)
return NullNode.instance;
if (value instanceof ValueNode)
return (ValueNode) value;
if (value instanceof Boolean)
return BooleanNode.valueOf((boolean) value);
else if (value instanceof Integer)
return IntNode.valueOf((int) value);
else if (value instanceof Long)
return LongNode.valueOf((long) value);
else if (value instanceof Double)
return DoubleNode.valueOf((double) value);
else if (value instanceof Float)
return FloatNode.valueOf((float) value);
return TextNode.valueOf(value.toString());
}
示例15: getAvroSchema
import com.fasterxml.jackson.databind.node.BooleanNode; //导入依赖的package包/类
/**
* Get an Avro schema using {@link AvroUtils#wrapAsNullable(Schema)} by node type.
*
* @param node Json node.
* @return an Avro schema using {@link AvroUtils#wrapAsNullable(Schema)} by node type.
*/
public Schema getAvroSchema(JsonNode node) {
if (node instanceof TextNode) {
return AvroUtils.wrapAsNullable(AvroUtils._string());
} else if (node instanceof IntNode) {
return AvroUtils.wrapAsNullable(AvroUtils._int());
} else if (node instanceof LongNode) {
return AvroUtils.wrapAsNullable(AvroUtils._long());
} else if (node instanceof DoubleNode) {
return AvroUtils.wrapAsNullable(AvroUtils._double());
} else if (node instanceof BooleanNode) {
return AvroUtils.wrapAsNullable(AvroUtils._boolean());
} else if (node instanceof NullNode) {
return AvroUtils.wrapAsNullable(AvroUtils._string());
} else {
return Schema.createRecord(getSubRecordRandomName(), null, null, false, getFields(node));
}
}