本文整理汇总了Java中org.codehaus.jackson.node.BooleanNode类的典型用法代码示例。如果您正苦于以下问题:Java BooleanNode类的具体用法?Java BooleanNode怎么用?Java BooleanNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BooleanNode类属于org.codehaus.jackson.node包,在下文中一共展示了BooleanNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deSchema
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
public static SchemaComponent deSchema(String name, JsonNode n)
{
if (n.isObject())
return deSchema(name, (ObjectNode)n);
if (n.isArray())
return deSchema(name, (ArrayNode)n);
if (n.isBoolean())
return deSchema(name, (BooleanNode)n);
if(n.isInt())
return deSchema(name, (IntNode)n);
if (n.isFloatingPointNumber())
return deSchema(name, (DoubleNode)n);
if (n.isNull())
return deSchema(name, (NullNode)n);
return null;
}
示例2: getValue
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
private Object getValue(String propName, JsonNode node)
{
JsonNode jsonNode = node.get(propName);
if (jsonNode != null)
{
if (jsonNode instanceof BooleanNode)
{
BooleanNode boolNode = (BooleanNode) jsonNode;
return boolNode.getBooleanValue() ? true : false;
} else
{
return jsonNode.getBigIntegerValue().doubleValue();
}
}
return null;
}
示例3: convertToJsonNode
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
private JsonNode convertToJsonNode(AvroDefaultConfig defaultConfig) {
switch (defaultConfig.avroType) {
case BOOLEAN:
return Boolean.parseBoolean(defaultConfig.defaultValue) ? BooleanNode.TRUE : BooleanNode.FALSE;
case INTEGER:
return new IntNode(Integer.parseInt(defaultConfig.defaultValue));
case LONG:
return new LongNode(Long.parseLong(defaultConfig.defaultValue));
case FLOAT:
// FloatNode is fairly recent and our Jackson version does not have it yet
return new DoubleNode(Float.parseFloat(defaultConfig.defaultValue));
case DOUBLE:
return new DoubleNode(Double.parseDouble(defaultConfig.defaultValue));
case STRING:
return new TextNode(defaultConfig.defaultValue);
default:
throw new IllegalArgumentException("Unknown type: " + defaultConfig.avroType);
}
}
示例4: testBufferedMessages
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
@Test
public void testBufferedMessages() throws PacketSerializationException {
BufferedMessageWithSender message1 = new BufferedMessageWithSender(
new BufferedMessage(23, BooleanNode.valueOf(true)),
getPlayer("Player #1")
);
BufferedMessageWithSender message2 = new BufferedMessageWithSender(
new BufferedMessage(42, BooleanNode.valueOf(true)),
getPlayer("Player #2")
);
Packet packet = new BufferedMessages(message1, message2);
String actual = packetSerializer.build(packet);
String expected = "{\"type\":\"BUFFERED_MESSAGES\",\"messages\":[{\"type\":\"BUFFERED_MESSAGE\",\"timestamp\":23,\"payload\":true,\"sender\":\"Player #1\"},{\"type\":\"BUFFERED_MESSAGE\",\"timestamp\":42,\"payload\":true,\"sender\":\"Player #2\"}]}";
assertEquals(expected, actual);
}
示例5: testGameCreated
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
@Test
public void testGameCreated() throws PacketSerializationException {
Player player1 = getPlayer("Player #1");
Player player2 = getPlayer("Player #2");
Game game = new Game(
"Name #1", "TOY_RACER", player1, new Players(player1, player2), 20,
BooleanNode.valueOf(true)
);
Packet packet = new GameCreated(game);
String actual = packetSerializer.build(packet);
String expected = "{\"type\":\"GAME_CREATED\",\"game\":{\"name\":\"Name #1\","
+ "\"type\":\"TOY_RACER\",\"slots\":20,\"takers\":[\"Player #1\",\"Player #2\"]"
+ ",\"info\":true}}";
assertEquals(expected, actual);
}
示例6: testGameDeleted
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
@Test
public void testGameDeleted() throws PacketSerializationException {
Player player1 = getPlayer("Player #1");
Player player2 = getPlayer("Player #2");
Game game = new Game(
"Name #1", "TOY_RACER", player1, new Players(player1, player2), 20,
BooleanNode.valueOf(true)
);
Packet packet = new GameDeleted(game);
String actual = packetSerializer.build(packet);
String expected = "{\"type\":\"GAME_DELETED\",\"game\":\"Name #1\"}";
assertEquals(expected, actual);
}
示例7: testGameClosed
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
@Test
public void testGameClosed() throws PacketSerializationException {
Player player1 = getPlayer("Player #1");
Player player2 = getPlayer("Player #2");
Game game = new Game(
"Name #1", "TOY_RACER", player1, new Players(player1, player2), 20,
BooleanNode.valueOf(true)
);
Packet packet = new GameClosed(game);
String actual = packetSerializer.build(packet);
String expected = "{\"type\":\"GAME_CLOSED\",\"game\":\"Name #1\"}";
assertEquals(expected, actual);
}
示例8: testOpenGames
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
@Test
public void testOpenGames() throws PacketSerializationException {
Player player1 = getPlayer("Player #1");
Player player2 = getPlayer("Player #2");
Player player3 = getPlayer("Player #3");
Game game1 = new Game("Name #1", "TOY_RACER", player1, new Players(player1), 20,
BooleanNode.valueOf(true)
);
Game
game2 =
new Game("Name #2", "TOY_RACER", player2, new Players(player2, player3), 10,
BooleanNode.valueOf(false)
);
Packet packet = new OpenGames(Lists.newArrayList(game1, game2));
String actual = packetSerializer.build(packet);
String expected = "{\"type\":\"OPEN_GAMES\",\"games\":[{\"name\":\"Name #1\","
+ "\"type\":\"TOY_RACER\",\"slots\":20,\"takers\":[\"Player #1\"],\"info\":true},"
+ "{\"name\":\"Name #2\",\"type\":\"TOY_RACER\",\"slots\":10,\"takers\":"
+ "[\"Player #2\",\"Player #3\"],\"info\":false}]}";
assertEquals(expected, actual);
}
示例9: processPrimitive
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
private Object processPrimitive(final JsonNode prim) {
Object val;
if (prim instanceof BooleanNode) {
val = prim.getBooleanValue();
} else if (prim instanceof DoubleNode) {
val = prim.getDoubleValue();
} else if (prim instanceof IntNode) {
val = prim.getIntValue();
} else if (prim instanceof LongNode) {
val = prim.getLongValue();
} else {
val = prim.getTextValue();
}
return val;
}
示例10: createVersionField
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
/**
* Creates the version field.
*
* @return the field
*/
private Field createVersionField() {
Field versionField = new Field(VERSION, Schema.createUnion(Arrays.asList(
Schema.create(Type.INT), Schema.create(Type.NULL))), null, null);
versionField.addProp(DISPLAY_NAME, "Version");
versionField.addProp(DISPLAY_PROMPT, "Enter type version");
versionField.addProp(TYPE_VERSION, BooleanNode.valueOf(true));
versionField.addProp(FIELD_ACCESS, FieldAccess.HIDDEN.name().toLowerCase());
return versionField;
}
示例11: createDependenciesField
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
/**
* Creates the dependencies field.
*
* @return the field
*/
private Field createDependenciesField() {
Schema dependencyType = Schema.createRecord(DEPENDENCY_FIELD_TYPE, null, BASE_SCHEMA_FORM_NAMESPACE, false);
Field fqnField = new Field(FQN, Schema.create(Type.STRING), null, null);
Field versionField = new Field(VERSION, Schema.create(Type.INT), null, null);
dependencyType.setFields(Arrays.asList(fqnField, versionField));
Schema dependenciesArray = Schema.createArray(dependencyType);
Field dependenciesField = new Field(DEPENDENCIES, Schema.createUnion(Arrays.asList(
dependenciesArray, Schema.create(Type.NULL))), null, null);
dependenciesField.addProp(DISPLAY_NAME, "Dependencies");
dependenciesField.addProp(TYPE_DEPENDENCIES, BooleanNode.valueOf(true));
dependenciesField.addProp(FIELD_ACCESS, FieldAccess.HIDDEN.name().toLowerCase());
return dependenciesField;
}
示例12: createAddressableField
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
/**
* Creates the addressable field.
*
* @return the field
*/
private Field createAddressableField() {
Field addressableField = new Field(ADDRESSABLE, Schema.createUnion(Arrays.asList(
Schema.create(Type.BOOLEAN), Schema.create(Type.NULL))), null, null);
addressableField.addProp(DISPLAY_NAME, "Is addressable");
addressableField.addProp(BY_DEFAULT, BooleanNode.valueOf(true));
addressableField.addProp(DISPLAY_PROMPT, "Click to enable/disable partial updates support");
return addressableField;
}
示例13: customizeFieldSchema
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
@Override
protected void customizeFieldSchema(Schema fieldSchema, GenericRecord fieldType) {
if (fieldType != null && fieldType.getSchema().getName().equals(RECORD_FIELD_TYPE)) {
Boolean addressable = (Boolean) fieldType.get(ADDRESSABLE);
if (addressable != null && !addressable) {
fieldSchema.addProp(ADDRESSABLE, BooleanNode.getFalse());
}
}
}
示例14: testClientMessageWithSender
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
@Test
public void testClientMessageWithSender() throws PacketSerializationException {
ClientMessage message = new ClientMessage(1, BooleanNode.valueOf(true),
"CHAT_MESSAGE");
Packet packet = new ClientMessageWithSender(getPlayer("Player #1"), message);
String actual = packetSerializer.build(packet);
String expected = "{\"type\":\"CLIENT_MESSAGE\",\"timestamp\":1,\"payload\":true,\"contentType\":\"CHAT_MESSAGE\",\"sender\":\"Player #1\"}";
assertEquals(expected, actual);
}
示例15: testBufferedMessageWithSender
import org.codehaus.jackson.node.BooleanNode; //导入依赖的package包/类
@Test
public void testBufferedMessageWithSender() throws PacketSerializationException {
BufferedMessage message = new BufferedMessage(1, BooleanNode.valueOf(true));
Packet packet = new BufferedMessageWithSender(message, getPlayer("Player #1"));
String actual = packetSerializer.build(packet);
String expected = "{\"type\":\"BUFFERED_MESSAGE\",\"timestamp\":1,\"payload\":true,\"sender\":\"Player #1\"}";
assertEquals(expected, actual);
}