com.fasterxml.jackson.databind.node.BooleanNode Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.node.BooleanNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectToJsonNode.java From yosegi with Apache License 2.0 | 6 votes |
/** * Judge Java objects and create JsonNode. */ 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() ); } }
Example #2
Source File: JsonUtilsTest.java From template-compiler with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: AbstractYMLConfigurationAction.java From walkmod-core with GNU Lesser General Public License v3.0 | 6 votes |
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); } }
Example #4
Source File: ResourceCustomUpdateActionUtilsTest.java From commercetools-sync-java with Apache License 2.0 | 6 votes |
@Test void buildSetCustomFieldsUpdateActions_WithSameCustomFieldValues_ShouldNotBuildUpdateActions() { final BooleanNode oldBooleanFieldValue = JsonNodeFactory.instance.booleanNode(true); final ObjectNode oldLocalizedFieldValue = JsonNodeFactory.instance.objectNode().put("de", "rot"); final Map<String, JsonNode> oldCustomFields = new HashMap<>(); oldCustomFields.put("invisibleInShop", oldBooleanFieldValue); oldCustomFields.put("backgroundColor", oldLocalizedFieldValue); final Map<String, JsonNode> newCustomFields = new HashMap<>(); newCustomFields.put("invisibleInShop", oldBooleanFieldValue); newCustomFields.put("backgroundColor", oldLocalizedFieldValue); final List<UpdateAction<Category>> setCustomFieldsUpdateActions = buildSetCustomFieldsUpdateActions(oldCustomFields, newCustomFields, mock(Category.class), new CategoryCustomActionBuilder(),null, category -> null); assertThat(setCustomFieldsUpdateActions).isNotNull(); assertThat(setCustomFieldsUpdateActions).isEmpty(); }
Example #5
Source File: ModelFieldPathsJSONDeserializer.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
public PathChoice deserializePath(JsonNode node) throws JsonProcessingException { ArrayNode nodes = (ArrayNode) node.get(NODES); TextNode start = (TextNode)node.get(START); TextNode end = (TextNode)node.get(END); BooleanNode active = (BooleanNode)node.get(ACTIVE); boolean activebool = active!=null && active.asBoolean(); if(activebool){ if(nodes!=null && start!=null && end!=null){ List<Relationship> relations = new ArrayList<Relationship>(); for(int i=0; i<nodes.size(); i++){ relations.add(deserializeRelationship(nodes.get(i))); } return new PathChoice(relations, activebool); }else{ throw new JsonProcessingExceptionImpl("The nodes, start and end values of a path must be valorized. Error processing node "+node.toString()); } } return null; }
Example #6
Source File: DistributedNetworkConfigStore.java From onos with Apache License 2.0 | 6 votes |
@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"); }
Example #7
Source File: AbstractYMLConfigurationAction.java From walkmod-core with GNU Lesser General Public License v3.0 | 6 votes |
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); } }
Example #8
Source File: AndOperator.java From jslt with Apache License 2.0 | 5 votes |
public JsonNode apply(Scope scope, JsonNode input) { boolean v1 = NodeUtils.isTrue(left.apply(scope, input)); if (!v1) return BooleanNode.FALSE; boolean v2 = NodeUtils.isTrue(right.apply(scope, input)); return NodeUtils.toJson(v1 && v2); }
Example #9
Source File: JsonUtils.java From kogito-runtimes with Apache License 2.0 | 5 votes |
/** * Merge two JSON documents. * @param src JsonNode to be merged * @param target JsonNode to merge to */ public static void merge(JsonNode src, JsonNode target) { Iterator<Map.Entry<String, JsonNode>> fields = src.fields(); while (fields.hasNext()) { Map.Entry<String, JsonNode> entry = fields.next(); JsonNode subNode = entry.getValue(); switch (subNode.getNodeType()) { case OBJECT: writeObject(entry, target); break; case ARRAY: writeArray(entry, target); break; case STRING: updateObject(target, new TextNode(entry.getValue().textValue()), entry); break; case NUMBER: updateObject(target, new IntNode(entry.getValue().intValue()), entry); break; case BOOLEAN: updateObject(target, BooleanNode.valueOf(entry.getValue().booleanValue()), entry); break; default: logger.warn("Unrecognized data type {} "+subNode.getNodeType()); } } }
Example #10
Source File: JacksonScalars.java From graphql-spqr with Apache License 2.0 | 5 votes |
@Override public BooleanNode parseValue(Object input) { if (input instanceof Boolean) { return (Boolean) input ? BooleanNode.TRUE : BooleanNode.FALSE; } if (input instanceof BooleanNode) { return (BooleanNode) input; } throw valueParsingException(input, Boolean.class, BooleanNode.class); }
Example #11
Source File: JacksonScalars.java From graphql-spqr with Apache License 2.0 | 5 votes |
private static Map<Type, GraphQLScalarType> getScalarMapping() { Map<Type, GraphQLScalarType> scalarMapping = new HashMap<>(); scalarMapping.put(TextNode.class, JsonTextNode); scalarMapping.put(BooleanNode.class, JsonBooleanNode); scalarMapping.put(BinaryNode.class, JsonBinaryNode); scalarMapping.put(BigIntegerNode.class, JsonBigIntegerNode); scalarMapping.put(IntNode.class, JsonIntegerNode); scalarMapping.put(ShortNode.class, JsonShortNode); scalarMapping.put(DecimalNode.class, JsonDecimalNode); scalarMapping.put(FloatNode.class, JsonFloatNode); scalarMapping.put(DoubleNode.class, JsonDoubleNode); scalarMapping.put(NumericNode.class, JsonDecimalNode); return Collections.unmodifiableMap(scalarMapping); }
Example #12
Source File: JsonNodeToPrimitiveObject.java From yosegi with Apache License 2.0 | 5 votes |
/** * Converts JsonNode to PrimitiveObject. */ 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() ); } }
Example #13
Source File: IsJsonBoolean.java From java-hamcrest with Apache License 2.0 | 5 votes |
@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; } }
Example #14
Source File: IsJsonObject.java From java-hamcrest with Apache License 2.0 | 5 votes |
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); } }
Example #15
Source File: FlagsTest.java From vespa with Apache License 2.0 | 5 votes |
@Test public void testBoolean() { final boolean defaultValue = false; FlagSource source = mock(FlagSource.class); BooleanFlag booleanFlag = Flags.defineFeatureFlag("id", defaultValue, "description", "modification effect", FetchVector.Dimension.ZONE_ID, FetchVector.Dimension.HOSTNAME) .with(FetchVector.Dimension.ZONE_ID, "a-zone") .bindTo(source); assertThat(booleanFlag.id().toString(), equalTo("id")); when(source.fetch(eq(new FlagId("id")), any())).thenReturn(Optional.empty()); // default value without raw flag assertThat(booleanFlag.value(), equalTo(defaultValue)); ArgumentCaptor<FetchVector> vector = ArgumentCaptor.forClass(FetchVector.class); verify(source).fetch(any(), vector.capture()); // hostname is set by default assertThat(vector.getValue().getValue(FetchVector.Dimension.HOSTNAME).isPresent(), is(true)); assertThat(vector.getValue().getValue(FetchVector.Dimension.HOSTNAME).get(), is(not(emptyOrNullString()))); // zone is set because it was set on the unbound flag above assertThat(vector.getValue().getValue(FetchVector.Dimension.ZONE_ID), is(Optional.of("a-zone"))); // application and node type are not set assertThat(vector.getValue().getValue(FetchVector.Dimension.APPLICATION_ID), is(Optional.empty())); assertThat(vector.getValue().getValue(FetchVector.Dimension.NODE_TYPE), is(Optional.empty())); RawFlag rawFlag = mock(RawFlag.class); when(source.fetch(eq(new FlagId("id")), any())).thenReturn(Optional.of(rawFlag)); when(rawFlag.asJsonNode()).thenReturn(BooleanNode.getTrue()); // raw flag deserializes to true assertThat(booleanFlag.with(FetchVector.Dimension.APPLICATION_ID, "an-app").value(), equalTo(true)); verify(source, times(2)).fetch(any(), vector.capture()); // application was set on the (bound) flag. assertThat(vector.getValue().getValue(FetchVector.Dimension.APPLICATION_ID), is(Optional.of("an-app"))); }
Example #16
Source File: BooleanJsonPropertyMapper.java From rest-schemagen with Apache License 2.0 | 5 votes |
@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(); }
Example #17
Source File: NodeUtils.java From jslt with Apache License 2.0 | 5 votes |
public static boolean isTrue(JsonNode value) { return value != BooleanNode.FALSE && !(value.isObject() && value.size() == 0) && !(value.isTextual() && value.asText().length() == 0) && !(value.isArray() && value.size() == 0) && !(value.isNumber() && value.doubleValue() == 0.0) && !value.isNull(); }
Example #18
Source File: JsonExampleDeserializer.java From swagger-inflector with Apache License 2.0 | 5 votes |
private Example createExample(JsonNode node) { if (node instanceof ObjectNode) { ObjectExample obj = new ObjectExample(); ObjectNode on = (ObjectNode) node; for (Iterator<Entry<String, JsonNode>> x = on.fields(); x.hasNext(); ) { Entry<String, JsonNode> i = x.next(); String key = i.getKey(); JsonNode value = i.getValue(); obj.put(key, createExample(value)); } return obj; } else if (node instanceof ArrayNode) { ArrayExample arr = new ArrayExample(); ArrayNode an = (ArrayNode) node; for (JsonNode childNode : an) { arr.add(createExample(childNode)); } return arr; } else if (node instanceof DoubleNode) { return new DoubleExample(node.doubleValue()); } else if (node instanceof IntNode || node instanceof ShortNode) { return new IntegerExample(node.intValue()); } else if (node instanceof FloatNode) { return new FloatExample(node.floatValue()); } else if (node instanceof BigIntegerNode) { return new BigIntegerExample(node.bigIntegerValue()); } else if (node instanceof DecimalNode) { return new DecimalExample(node.decimalValue()); } else if (node instanceof LongNode) { return new LongExample(node.longValue()); } else if (node instanceof BooleanNode) { return new BooleanExample(node.booleanValue()); } else { return new StringExample(node.asText()); } }
Example #19
Source File: BooleanDeserializer.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public Boolean deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if(node instanceof BooleanNode) { BooleanNode bNode = (BooleanNode) node; return bNode.booleanValue(); } throw new JsonParseException(jsonParser, "il field " + jsonParser.getCurrentName() + " non e' di tipo " + Boolean.class.getName() + "."); }
Example #20
Source File: Serializer.java From james-project with Apache License 2.0 | 5 votes |
@Override public Optional<Boolean> deserialize(JsonNode json) { if (json instanceof BooleanNode) { return Optional.of(json.asBoolean()); } else { return Optional.empty(); } }
Example #21
Source File: SerializationTest.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Test void unmarshalCRDWithSchema() throws Exception { final String input = readYamlToString("/test-crd-schema.yml"); final CustomResourceDefinition crd = Serialization.unmarshal(input, CustomResourceDefinition.class); JSONSchemaProps spec = crd.getSpec() .getValidation() .getOpenAPIV3Schema() .getProperties() .get("spec"); assertEquals(spec.getRequired().size(), 3); assertEquals(spec.getRequired().get(0), "builderName"); assertEquals(spec.getRequired().get(1), "edges"); assertEquals(spec.getRequired().get(2), "dimensions"); Map<String, JSONSchemaProps> properties = spec.getProperties(); assertNotNull(properties.get("builderName")); assertEquals(properties.get("builderName").getExample(), new TextNode("builder-example")); assertEquals(properties.get("hollow").getDefault(), BooleanNode.FALSE); assertNotNull(properties.get("dimensions")); assertNotNull(properties.get("dimensions").getProperties().get("x")); assertEquals(properties.get("dimensions").getProperties().get("x").getDefault(), new IntNode(10)); String output = Serialization.asYaml(crd); assertEquals(input.trim(), output.trim()); }
Example #22
Source File: VariableTest.java From batfish with Apache License 2.0 | 5 votes |
@Test public void testEquals() { Variable variable = new Variable(); variable.setType(Type.INTEGER); Variable initialInstance = clone(variable); EqualsTester equalsTester = new EqualsTester(); equalsTester.addEqualityGroup(initialInstance, initialInstance).addEqualityGroup(new Object()); variable.setDescription("description"); equalsTester.addEqualityGroup(clone(variable)); variable.setDisplayName("display name"); equalsTester.addEqualityGroup(clone(variable)); variable.setFields(ImmutableMap.of("f", new Field())); equalsTester.addEqualityGroup(clone(variable)); variable.setLongDescription("long description"); equalsTester.addEqualityGroup(clone(variable)); variable.setMinElements(1); equalsTester.addEqualityGroup(clone(variable)); variable.setMinLength(1); equalsTester.addEqualityGroup(clone(variable)); variable.setOptional(true); equalsTester.addEqualityGroup(clone(variable)); variable.setType(Type.BOOLEAN); equalsTester.addEqualityGroup(clone(variable)); variable.setValue(BooleanNode.TRUE); equalsTester.addEqualityGroup(clone(variable)); variable.setValues(ImmutableList.of()); equalsTester.addEqualityGroup(clone(variable)); equalsTester.testEquals(); }
Example #23
Source File: JsonWrittenEventProvider.java From tasmo with Apache License 2.0 | 5 votes |
@Override public Boolean getBooleanField(String fieldname) { JsonNode value = fieldsNode.get(fieldname); if (value instanceof BooleanNode) { return value.booleanValue(); } else { return null; } }
Example #24
Source File: ApplicationSettings.java From gitlab4j-api with MIT License | 5 votes |
private Object jsonNodeToValue(JsonNode node) { Object value = node; if (node instanceof NullNode) { value = null; } else if (node instanceof TextNode) { value = node.asText(); } else if (node instanceof BooleanNode) { value = node.asBoolean(); } else if (node instanceof IntNode) { value = node.asInt(); } else if (node instanceof FloatNode) { value = (float)((FloatNode)node).asDouble(); } else if (node instanceof DoubleNode) { value = (float)((DoubleNode)node).asDouble(); } else if (node instanceof ArrayNode) { int numItems = node.size(); String[] values = new String[numItems]; for (int i = 0; i < numItems; i++) { values[i] = node.path(i).asText(); } value = values; } return (value); }
Example #25
Source File: BatchRequestBuilderErrors.java From simple-json-rpc with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void testBadId() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> { BatchRequestBuilder<?, ?> batchRequest = client.createBatchRequest(); batchRequest.getRequests() .add(batchRequest.request(BooleanNode.TRUE, "findPlayer", new ObjectMapper().createArrayNode().add("Steven").add("Stamkos"))); batchRequest.returnType(Player.class).execute(); }).withMessage("Wrong id=true"); }
Example #26
Source File: UiExtensionManager.java From onos with Apache License 2.0 | 5 votes |
@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"); }
Example #27
Source File: JsonDataModelInjector.java From onos with Apache License 2.0 | 5 votes |
/** * Inhales boolean data model on the filed of work-let. * * @param worklet work-let * @param context workflow context * @param field the field of work-let * @param model boolean data model for the field * @throws WorkflowException workflow exception */ private static void inhaleBoolean(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model) throws WorkflowException { if (!(Objects.equals(field.getType(), Boolean.class))) { throw new WorkflowException("Target field (" + field + ") is not Boolean"); } Boolean bool; try { field.setAccessible(true); bool = (Boolean) field.get(worklet); } catch (IllegalAccessException e) { throw new WorkflowException(e); } if (Objects.isNull(bool)) { return; } JsonDataModelTree tree = (JsonDataModelTree) context.data(); JsonNode jsonNode = tree.nodeAt(model.path()); if (Objects.isNull(jsonNode) || jsonNode instanceof MissingNode) { tree.setAt(model.path(), bool); } else if (!(jsonNode instanceof BooleanNode)) { throw new WorkflowException("Invalid boolean data model on (" + model.path() + ")"); } else { tree.remove(model.path()); tree.setAt(model.path(), bool); } }
Example #28
Source File: JsonDataModelTree.java From onos with Apache License 2.0 | 5 votes |
/** * Gets boolean on specific json pointer. * * @param ptr json pointer * @return boolean on specific json pointer * @throws WorkflowException workflow exception */ public Boolean booleanAt(JsonPointer ptr) throws WorkflowException { if (root == null || root instanceof MissingNode) { throw new WorkflowException("Invalid root node"); } JsonNode node = root.at(ptr); if (node instanceof MissingNode) { return null; } if (!(node instanceof BooleanNode)) { throw new WorkflowException("Invalid node(" + node + ") at " + ptr); } return ((BooleanNode) node).asBoolean(); }
Example #29
Source File: WorkplaceWorkflow.java From onos with Apache License 2.0 | 5 votes |
private boolean isSubmitted(WorkflowContext context) throws WorkflowException { JsonNode node = ((JsonDataModelTree) context.data()).nodeAt("/" + SUBMITTED); if (!(node instanceof BooleanNode)) { return false; } return node.asBoolean(); }
Example #30
Source File: JsonWrittenEventProvider.java From tasmo with Apache License 2.0 | 5 votes |
@Override public Boolean getBooleanField(String fieldname) { JsonNode value = fieldsNode.get(fieldname); if (value instanceof BooleanNode) { return value.booleanValue(); } else { return null; } }