@Override public boolean asBoolean() { return isNull ? super.asBoolean() : isTrue; }
/** * Returns the <code>boolean</code> value of the member with the specified name in this object. If * this object does not contain a member with this name, the given default value is returned. If * this object contains multiple members with the given name, the last one will be picked. If this * member's value does not represent a JSON <code>true</code> or <code>false</code> value, an * exception is thrown. * * @param name * the name of the member whose value is to be returned * @param defaultValue * the value to be returned if the requested member is missing * @return the value of the last member with the specified name, or the given default value if * this object does not contain a member with that name */ public boolean getBoolean(String name, boolean defaultValue) { JsonValue value = get(name); return value != null ? value.asBoolean() : defaultValue; }
@Override public boolean asBoolean() { return isNull ? super.asBoolean() : isTrue; }
@Override public boolean asBoolean() { return wrapped.asBoolean(); }
@Override protected Boolean getValue(JsonValue jsonValue) throws Exception { return jsonValue.asBoolean(); }
@Override public Boolean read(JsonValue jsonValue) throws Exception { return jsonValue.asBoolean(); }
@Override public boolean asBoolean() { return isNull ? super.asBoolean() : isTrue; }
public Boolean getAsBoolean(final String field){ JsonValue value = getAsJsonValue(field); if (value == null) { return null; } return value.asBoolean(); }
@Override void parseJSONMember(JsonObject.Member member) { JsonValue value = member.getValue(); String memberName = member.getName(); if (memberName.equals("can_download")) { this.canDownload = value.asBoolean(); } else if (memberName.equals("can_preview")) { this.canPreview = value.asBoolean(); } } }
public static boolean getBoolean(JsonValue value, String name) { JsonValue result = ((JsonObject) value).get(name); if (result == null) { return false; } return result.asBoolean(); } }
private boolean toBoolean(JsonValue jsonValue) { return jsonValue.isNull() ? false : jsonValue.asBoolean(); }
private boolean toBoolean(JsonValue jsonValue) { return jsonValue.isNull() ? false : jsonValue.asBoolean(); }
private boolean toBoolean(JsonValue jsonValue) { return jsonValue.isNull() ? false : jsonValue.asBoolean(); }
/** * Returns the <code>boolean</code> value of the member with the specified name in this object. If * this object does not contain a member with this name, the given default value is returned. If * this object contains multiple members with the given name, the last one will be picked. If this * member's value does not represent a JSON <code>true</code> or <code>false</code> value, an * exception is thrown. * * @param name * the name of the member whose value is to be returned * @param defaultValue * the value to be returned if the requested member is missing * @return the value of the last member with the specified name, or the given default value if * this object does not contain a member with that name */ public boolean getBoolean(String name, boolean defaultValue) { JsonValue value = get(name); return value != null ? value.asBoolean() : defaultValue; }
/** * Returns the <code>boolean</code> value of the member with the specified name in this object. If * this object does not contain a member with this name, the given default value is returned. If * this object contains multiple members with the given name, the last one will be picked. If this * member's value does not represent a JSON <code>true</code> or <code>false</code> value, an * exception is thrown. * * @param name * the name of the member whose value is to be returned * @param defaultValue * the value to be returned if the requested member is missing * @return the value of the last member with the specified name, or the given default value if * this object does not contain a member with that name */ public boolean getBoolean(String name, boolean defaultValue) { JsonValue value = get(name); return value != null ? value.asBoolean() : defaultValue; }
@Override public boolean asBoolean() { return isBoolean() ? isTrue() : super.asBoolean(); }
@Override void parseJSONMember(JsonObject.Member member) { JsonValue value = member.getValue(); String memberName = member.getName(); if (memberName.equals("id")) { this.id = value.asString(); } else if (memberName.equals("is_confirmed")) { this.isConfirmed = value.asBoolean(); } else if (memberName.equals("email")) { this.email = value.asString(); } } }
@Override public void loadAllContacts() throws ConnectionException { JsonObject object = Endpoints.GET_ALL_CONTACTS .open(this, getUsername(), "default") .as(JsonObject.class) .expect(200, "While loading contacts") .get(); for (JsonValue value : object.get("contacts").asArray()) { JsonObject obj = value.asObject(); if (obj.get("suggested") == null || !obj.get("suggested").asBoolean()) { if (!allContacts.containsKey(obj.get("id").asString())) { this.allContacts.put(obj.get("id").asString(), new ContactImpl(this, obj)); } } } }
@Override public void updateContactList() throws ConnectionException { JsonObject obj = Endpoints.GET_ALL_CONTACTS .open(this, getUsername(), "notification") .as(JsonObject.class) .expect(200, "While loading contacts") .get(); for (JsonValue value : obj.get("contacts").asArray()) { if (value.asObject().get("suggested") == null || !value.asObject().get("suggested").asBoolean()) { String id = value.asObject().get("id").asString(); ContactImpl impl = (ContactImpl) allContacts.get(id); if (impl == null) impl = (ContactImpl) loadContact(id); impl.update(value.asObject()); } } }
public void update(JsonObject contact) { this.username = contact.get("id").asString(); this.isAuthorized = contact.get("authorized").asBoolean(); this.isBlocked = contact.get("blocked").asBoolean(); this.displayName = Utils.getString(contact, "display_name"); this.avatarURL = Utils.getString(contact, "avatar_url"); this.mood = Utils.getString(contact, "mood"); this.type = Utils.getString(contact, "type"); this.authCertificate = Utils.getString(contact, "auth_certificate"); this.firstName = contact.get("name") == null ? null : Utils.getString(contact.get("name").asObject(), "first"); if (contact.get("locations") != null) { JsonObject locations = contact.get("locations").asArray().get(0).asObject(); this.country = locations.get("country") == null ? null : locations.get("country").asString(); this.city = locations.get("city") == null ? null : locations.get("city").asString(); } }