@Override
 protected void parseMember(JsonObject.Member member) {
   super.parseMember(member);
   try {
     JsonValue value = member.getValue();
     String memberName = member.getName();
     if ("roles".equals(memberName)) {
       this.writable =
           value
               .asArray()
               .values()
               .stream()
               .filter(JsonValue::isString)
               .map(JsonValue::asString)
               .anyMatch("write"::equalsIgnoreCase);
     } else if ("link".equals(memberName)) {
       link = new OneDriveSharingLink(value.asObject());
     } else if ("grantedTo".equals(memberName)) {
       grantedTo = new OneDriveIdentitySet(value.asObject());
     } else if ("inheritedFrom".equals(memberName)) {
       JsonObject valueObject = value.asObject();
       String id = valueObject.get("id").asString();
       OneDriveFolder inheritedFromFolder = new OneDriveFolder(getApi(), id);
       inheritedFrom = inheritedFromFolder.new Reference(valueObject);
     } else if ("shareId".equals(memberName)) {
       shareId = value.asString();
     }
   } catch (ParseException e) {
     throw new OneDriveRuntimeException("Parse failed, maybe a bug in client.", e);
   }
 }
Пример #2
0
 /**
  * Returns the <code>String</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 is picked. If this
  * member's value does not represent a JSON string, 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 String getString(String name, String defaultValue) {
   JsonValue value = get(name);
   return value != null ? value.asString() : defaultValue;
 }