Java 类com.fasterxml.jackson.databind.node.BooleanNode 实例源码

项目:GitHub    文件:ArrayRuleTest.java   
@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()));
}
项目:GitHub    文件:ArrayRuleTest.java   
@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()));
}
项目:GitHub    文件:ArrayRuleTest.java   
@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()));
}
项目:GitHub    文件:ArrayRuleTest.java   
@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)));
}
项目:dataplatform-schema-lib    文件:PrimitiveObjectToJsonNode.java   
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 );
  }
}
项目:athena    文件:UiExtensionManager.java   
@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");
}
项目:athena    文件:DistributedNetworkConfigStore.java   
@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");
}
项目:site-infrastructure-tests    文件:JQueryLoadedTestCase.java   
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);
}
项目:site-infrastructure-tests    文件:DTMLoadedTestCase.java   
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);
}
项目:template-compiler    文件:JsonUtilsTest.java   
@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);
}
项目:judge-engine    文件:DeserializerTest.java   
@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")));
}
项目:judge-engine    文件:SerializerTest.java   
@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")));
}
项目:spacedog-server    文件:Json8.java   
@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());
}
项目:spacedog-server    文件:Json7.java   
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());
    }
项目:daikon    文件:JsonSchemaInferrer.java   
/**
 * 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));
    }
}
项目:lightblue-client    文件:ResultStream.java   
/**
 * Construct a StreamDoc from the json node
 */
public static StreamDoc fromJson(ObjectNode node) {
    StreamDoc ret=null;
    if(node!=null) {
        ret=new StreamDoc();
        JsonNode x=node.get("processed");
        if(x instanceof ObjectNode)
            ret.doc=(ObjectNode)x;
        x=node.get("resultMetadata");
        if(x instanceof ObjectNode) {
            ret.resultMetadata=ResultMetadata.fromJson((ObjectNode)x);
        }
        x=node.get("last");
        if(x instanceof BooleanNode)
            ret.lastDoc=x.asBoolean();
    }
    return ret;
}
项目:ineform    文件:JavaPropHandler.java   
@Override
public void setProp(HasProp hasProp, String group, String key, Object value) {
    try {
        ObjectNode groupJSON = getOrCreateJsonGroup(hasProp, group);
        if (value == null) {
            groupJSON.put(key, NullNode.getInstance());
        } else if (value instanceof Long) {
            groupJSON.put(key, LongNode.valueOf((Long) value));
        } else if (value instanceof Double) {
            groupJSON.put(key, DoubleNode.valueOf((Double) value));
        } else if (value instanceof Integer) {
            groupJSON.put(key, IntNode.valueOf((Integer) value));
        } else if (value instanceof Float) {
            groupJSON.put(key, new DoubleNode((double) value));
        } else if (value instanceof String) {
            groupJSON.put(key, TextNode.valueOf((String) value));
        } else if (value instanceof Boolean) {
            groupJSON.put(key, BooleanNode.valueOf((Boolean) value));
        }
        hasProp.setPropsJson(group, groupJSON.toString());
    } catch (Exception e) {
        logSetProp(hasProp, group, key, value);
    }
}
项目:walkmod-core    文件:AbstractYMLConfigurationAction.java   
public void createTransformation(ObjectNode transformationNode, TransformationConfig transCfg) {

        String name = transCfg.getName();
        if (name != null) {
            transformationNode.set("name", new TextNode(name));
        }
        String typeName = transCfg.getType();
        if (typeName != null) {
            transformationNode.set("type", new TextNode(typeName));
        }
        String mergePolicy = transCfg.getMergePolicy();
        if (mergePolicy != null) {
            transformationNode.set("merge-policy", new TextNode(mergePolicy));
        }
        if (transCfg.isMergeable()) {
            transformationNode.set("isMergeable", BooleanNode.TRUE);
        }
        Map<String, Object> params = transCfg.getParameters();
        if (params != null && !params.isEmpty()) {
            populateParams(transformationNode, params);
        }
    }
项目:onos    文件:DistributedNetworkConfigStore.java   
@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");
}
项目:lightblue-core    文件:JsonUtils.java   
/**
 * Returns a Java object for a json value node based on the node type.
 */
public static Object valueFromJson(ValueNode node) {
    if (node instanceof NullNode) {
        return null;
    } else {
        if(node instanceof TextNode) {
            return node.textValue();
        } else if(node instanceof BooleanNode) {
            return node.booleanValue();
        } else if(node instanceof NumericNode) {
            return node.numberValue();
        } else {
            throw new RuntimeException("Unsupported node type:"+node.getClass().getName());
        }
    }
}
项目:walkmod-core    文件:AbstractYMLConfigurationAction.java   
public void createTransformation(ObjectNode transformationNode, TransformationConfig transCfg) {

        String name = transCfg.getName();
        if (name != null) {
            transformationNode.set("name", new TextNode(name));
        }
        String typeName = transCfg.getType();
        if (typeName != null) {
            transformationNode.set("type", new TextNode(typeName));
        }
        String mergePolicy = transCfg.getMergePolicy();
        if (mergePolicy != null) {
            transformationNode.set("merge-policy", new TextNode(mergePolicy));
        }
        if (transCfg.isMergeable()) {
            transformationNode.set("isMergeable", BooleanNode.TRUE);
        }
        Map<String, Object> params = transCfg.getParameters();
        if (params != null && !params.isEmpty()) {
            populateParams(transformationNode, params);
        }
    }
项目:dataplatform-schema-lib    文件:JsonNodeToPrimitiveObject.java   
public static PrimitiveObject get( final JsonNode jsonNode ) throws IOException{
  if( jsonNode instanceof TextNode ){
    return new StringObj( ( (TextNode)jsonNode ).textValue() );
  }
  else if( jsonNode instanceof BooleanNode ){
    return new BooleanObj( ( (BooleanNode)jsonNode ).booleanValue() );
  }
  else if( jsonNode instanceof IntNode ){
    return new IntegerObj( ( (IntNode)jsonNode ).intValue() );
  }
  else if( jsonNode instanceof LongNode ){
    return new LongObj( ( (LongNode)jsonNode ).longValue() );
  }
  else if( jsonNode instanceof DoubleNode ){
    return new DoubleObj( ( (DoubleNode)jsonNode ).doubleValue() );
  }
  else if( jsonNode instanceof BigIntegerNode ){
    return new StringObj( ( (BigIntegerNode)jsonNode ).bigIntegerValue().toString() );
  }
  else if( jsonNode instanceof DecimalNode ){
    return new StringObj( ( (DecimalNode)jsonNode ).decimalValue().toString() );
  }
  else if( jsonNode instanceof BinaryNode ){
    return new BytesObj( ( (BinaryNode)jsonNode ).binaryValue() );
  }
  else if( jsonNode instanceof POJONode ){
    return new BytesObj( ( (POJONode)jsonNode ).binaryValue() );
  }
  else if( jsonNode instanceof NullNode ){
    return NullObj.getInstance();
  }
  else if( jsonNode instanceof MissingNode ){
    return NullObj.getInstance();
  }
  else{
    return new StringObj( jsonNode.toString() );
  }
}
项目:dataplatform-schema-lib    文件:ObjectToJsonNode.java   
public static JsonNode get( final Object obj ) throws IOException{

    if( obj instanceof PrimitiveObject ){
      return PrimitiveObjectToJsonNode.get( (PrimitiveObject)obj );
    }
    else if( obj instanceof String ){
      return new TextNode( (String)obj );
    }
    else if( obj instanceof Boolean ){
      return BooleanNode.valueOf( (Boolean)obj );
    }
    else if( obj instanceof Short ){
      return IntNode.valueOf( ( (Short)obj ).intValue() );
    }
    else if( obj instanceof Integer ){
      return IntNode.valueOf( (Integer)obj );
    }
    else if( obj instanceof Long ){
      return new LongNode( (Long)obj );
    }
    else if( obj instanceof Float ){
      return new DoubleNode( ( (Float)obj ).doubleValue() );
    }
    else if( obj instanceof Double ){
      return new DoubleNode( (Double)obj );
    }
    else if( obj instanceof byte[] ){
      return new BinaryNode( (byte[])obj );
    }
    else if( obj == null ){
      return NullNode.getInstance();
    }
    else{
      return new TextNode( obj.toString() );
    }
  }
项目:site-infrastructure-tests    文件:DTMIsInDebugModeTestCase.java   
public DTMIsInDebugModeTestCase(String pageURL, List<String> blockPatterns, Object params) {
    super(pageURL, blockPatterns);

    String note = "";
    if (BooleanNode.class.isAssignableFrom(params.getClass())) {
        _test = ((BooleanNode) params).asBoolean();
        if (!_test) {
            note = " (inactive)";
        }
    } else {
        _test = true;
    }

    setName(Tools.DTM + " in debug mode " + note + " - " + pageURL);
}
项目:java-hamcrest    文件:IsJsonBoolean.java   
@Override
protected boolean matchesNode(BooleanNode node, Description mismatchDescription) {
  final boolean value = node.asBoolean();

  if (booleanMatcher.matches(value)) {
    return true;
  } else {
    mismatchDescription.appendText("was a boolean node with value that ");
    booleanMatcher.describeMismatch(value, mismatchDescription);
    return false;
  }
}
项目:java-hamcrest    文件:IsJsonObject.java   
private static Matcher<JsonNode> createNodeMatcher(final JsonNode value) {
  final JsonNodeType nodeType = value.getNodeType();
  switch (nodeType) {
    case ARRAY:
      return IsJsonArray.jsonArray((ArrayNode) value);
    case BINARY:
      throw new UnsupportedOperationException(
          "Expected value contains a binary node, which is not implemented.");
    case BOOLEAN:
      return IsJsonBoolean.jsonBoolean((BooleanNode) value);
    case MISSING:
      return IsJsonMissing.jsonMissing((MissingNode) value);
    case NULL:
      return IsJsonNull.jsonNull((NullNode) value);
    case NUMBER:
      return IsJsonNumber.jsonNumber((NumericNode) value);
    case OBJECT:
      return IsJsonObject.jsonObject((ObjectNode) value);
    case POJO:
      throw new UnsupportedOperationException(
          "Expected value contains a POJO node, which is not implemented.");
    case STRING:
      return IsJsonText.jsonText((TextNode) value);
    default:
      throw new UnsupportedOperationException("Unsupported node type " + nodeType);
  }
}
项目:rest-schemagen    文件:BooleanJsonPropertyMapper.java   
@Override
public ObjectNode toJson(JsonProperty jsonProperty) {
    Function<Object,JsonNode> nodeCreator = value -> ((Boolean) value) ? BooleanNode.TRUE
            : BooleanNode.FALSE;
    return primitiveJsonPropertyBuilder.forProperty(jsonProperty)
            .withType("boolean")
            .withDefaultValue(BooleanNode.FALSE)
            .withDefaultAndAllowedValues(nodeCreator).build();
}
项目:judge-engine    文件:Serializer.java   
/**
 * Serialize primtive values to JSON .
 */
static <T> JsonNode primitiveToJson(final T value, final TypeNode type) {
  final JsonNode result;
  // for BinaryTreeNode
  if (value == null) {
    return NullNode.instance;
  }

  switch (type.getValue()) {
    case BOOL:
      result = BooleanNode.valueOf((Boolean) value);
      break;
    case CHAR:
      result = TextNode.valueOf(value.toString());
      break;
    case STRING:
      result = TextNode.valueOf((String) value);
      break;
    case DOUBLE:
      result = DoubleNode.valueOf((Double) value);
      break;
    case INT:
      result = IntNode.valueOf((Integer) value);
      break;
    case LONG:
      result = LongNode.valueOf((Long) value);
      break;
    default:
      throw new IllegalArgumentException("Unrecognized primitive type: " + type);
  }
  return result;
}
项目:spacedog-server    文件:JsonTest.java   
@Test
public void shouldSet() {
    JsonNode json = Json7.objectBuilder().object("riri").array("fifi")//
            .add(12).object().put("loulou", false).build();
    Json7.set(json, "riri.fifi.1.loulou", BooleanNode.TRUE);
    assertTrue(Json7.get(json, "riri.fifi.1.loulou").asBoolean());
}
项目:daikon    文件:JsonGenericRecordConverter.java   
/**
 * Get value from Json Node.
 * 
 * @param node
 * @return value from Json Node
 */
private Object getValue(JsonNode node) {
    if (node instanceof TextNode) {
        return node.textValue();
    } else if (node instanceof IntNode) {
        return node.intValue();
    } else if (node instanceof LongNode) {
        return node.longValue();
    } else if (node instanceof DoubleNode) {
        return node.doubleValue();
    } else if (node instanceof BooleanNode) {
        return node.booleanValue();
    }
    return null;
}
项目:java-u2flib-server    文件:FingerprintMatcherTest.java   
@Test
public void matchesIsFalseForNonArrayFingerprints() {
    JsonNode parameters = mock(JsonNode.class);
    when(parameters.get("fingerprints")).thenReturn(BooleanNode.TRUE);

    assertFalse(new FingerprintMatcher().matches(mock(X509Certificate.class), parameters));
}
项目:hamcrest-jackson    文件:IsJsonBooleanTest.java   
@Test
public void testMatches() {
    // Given
    BooleanNode booleanNode = jsonNodeFactory.booleanNode(true);
    IsJsonBoolean matcher = new IsJsonBoolean(true);

    // When
    boolean matches = matcher.matches(booleanNode);

    // Then
    assertTrue(matches);
}
项目:hamcrest-jackson    文件:IsJsonBooleanTest.java   
@Test
public void testMatches_false() {
    // Given
    BooleanNode booleanNode = jsonNodeFactory.booleanNode(false);
    IsJsonBoolean matcher = new IsJsonBoolean(true);

    // When
    boolean matches = matcher.matches(booleanNode);

    // Then
    assertFalse(matches);
}
项目:hamcrest-jackson    文件:IsJsonBooleanTest.java   
@Test
public void testDescribeMismatch() {
    // Given
    IsJsonBoolean matcher = new IsJsonBoolean(true);
    StringDescription description = new StringDescription();
    BooleanNode booleanNode = jsonNodeFactory.booleanNode(false);

    // When
    matcher.describeMismatch(booleanNode, description);

    // Then
    assertEquals("was \"false\"", description.toString());
}
项目:logback-steno    文件:SafeSerializationHelper.java   
/**
 * Safely serialize a value.
 *
 * @since 1.11.2
 * @param encoder The <code>StenoEncoder</code> instance.
 * @param value The <code>Object</code> instance to safely serialize.
 */
public static void safeEncodeValue(final StringBuilder encoder, @Nullable final Object value) {
    if (value == null) {
        encoder.append("null");
    } else if (value instanceof Map) {
        safeEncodeMap(encoder, (Map<?, ?>) value);
    } else if (value instanceof List) {
        safeEncodeList(encoder, (List<?>) value);
    } else if (value.getClass().isArray()) {
        safeEncodeArray(encoder, value);
    } else if (value instanceof LogValueMapFactory.LogValueMap) {
        safeEncodeLogValueMap(encoder, (LogValueMapFactory.LogValueMap) value);
    } else if (value instanceof Throwable) {
        safeEncodeThrowable(encoder, (Throwable) value);
    } else if (StenoSerializationHelper.isSimpleType(value)) {
        if (value instanceof Boolean) {
            encoder.append(BooleanNode.valueOf((Boolean) value).toString());
        } else if (value instanceof Double) {
            encoder.append(DoubleNode.valueOf((Double) value).toString());
        } else if (value instanceof Float) {
            encoder.append(FloatNode.valueOf((Float) value).toString());
        } else if (value instanceof Long) {
            encoder.append(LongNode.valueOf((Long) value).toString());
        } else if (value instanceof Integer) {
            encoder.append(IntNode.valueOf((Integer) value).toString());
        } else {
            encoder.append(new TextNode(value.toString()).toString());
        }
    } else {
        safeEncodeValue(encoder, LogReferenceOnly.of(value).toLogValue());
    }
}
项目:ineform    文件:JavaPropHandler.java   
@Override
public void setProp(HasProp o, String group, String key, Boolean value) {
    try {
        ObjectNode groupJSON = getOrCreateJsonGroup(o, group);
        if (value == null) {
            groupJSON.put(key, NullNode.getInstance());
        } else {
            groupJSON.put(key, BooleanNode.valueOf(value));
        }
        o.setPropsJson(group, groupJSON.toString());
    } catch (Exception e) {
        logSetProp(o, group, key, value);
    }
}
项目:tasmo    文件:JsonWrittenEventProvider.java   
@Override
public Boolean getBooleanField(String fieldname) {
    JsonNode value = fieldsNode.get(fieldname);
    if (value instanceof BooleanNode) {
        return value.booleanValue();
    } else {
        return null;
    }
}
项目:unravl    文件:Json.java   
public static Object unwrap(Object val) { // Can Jackson do this via
                                          // ObjectMapper.treeToValue()? The
                                          // spec is unclear
    Object result = val;
    ObjectMapper mapper = new ObjectMapper();
    if (val instanceof ObjectNode) {
        result = mapper.convertValue((ObjectNode) val, Map.class);
    } else if (val instanceof ArrayNode) {
        result = mapper.convertValue((ObjectNode) val, List.class);
    } else if (val instanceof NullNode) {
        result = null;
    } else if (val instanceof BooleanNode) {
        result = ((BooleanNode) val).booleanValue();
    } else if (val instanceof ShortNode) {
        result = ((ShortNode) val).shortValue();
    } else if (val instanceof IntNode) {
        result = ((IntNode) val).intValue();
    } else if (val instanceof LongNode) {
        result = ((LongNode) val).longValue();
    } else if (val instanceof DoubleNode) {
        result = ((DoubleNode) val).doubleValue();
    } else if (val instanceof FloatNode) {
        result = ((FloatNode) val).floatValue();
    } else if (val instanceof BigIntegerNode) {
        result = ((BigIntegerNode) val).bigIntegerValue();
    } else if (val instanceof DecimalNode) {
        result = ((DecimalNode) val).decimalValue();
    }
    return result;
}
项目:simple-json-rpc    文件:BatchRequestBuilderErrors.java   
@Test
@SuppressWarnings("unchecked")
public void testBadId() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Wrong id=true");

    BatchRequestBuilder<?, ?> batchRequest = client.createBatchRequest();
    batchRequest.getRequests()
            .add(batchRequest.request(BooleanNode.TRUE, "findPlayer",
                    new ObjectMapper().createArrayNode().add("Steven").add("Stamkos")));
    batchRequest.returnType(Player.class).execute();
}
项目:onos    文件:UiExtensionManager.java   
@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, UiSessionToken.class);

    prefsConsistentMap = storageService.<String, ObjectNode>consistentMapBuilder()
            .withName(ONOS_USER_PREFERENCES)
            .withSerializer(serializer)
            .withRelaxedReadConsistency()
            .build();
    prefsConsistentMap.addListener(prefsListener);
    prefs = prefsConsistentMap.asJavaMap();

    tokensConsistentMap = storageService.<UiSessionToken, String>consistentMapBuilder()
            .withName(ONOS_SESSION_TOKENS)
            .withSerializer(serializer)
            .withRelaxedReadConsistency()
            .build();
    tokens = tokensConsistentMap.asJavaMap();

    register(core);

    log.info("Started");
}