builder.clear(); builder.isComplete(state.isComplete() || completeData);
builder.isComplete(true); } else { if (!objectIdForPointer.equals(NEW_OFFLINE_OBJECT_ID_PLACEHOLDER)) { builder.objectId(objectIdForPointer); builder.isComplete(false);
/** * Applies a {@code State} on top of this {@code Builder} instance. * * @param other The {@code State} to apply over this instance. * @return A new {@code Builder} instance. */ public T apply(State other) { if (other.objectId() != null) { objectId(other.objectId()); } if (other.createdAt() > 0) { createdAt(other.createdAt()); } if (other.updatedAt() > 0) { updatedAt(other.updatedAt()); } isComplete(isComplete || other.isComplete()); for (String key : other.keySet()) { put(key, other.get(key)); } availableKeys(other.availableKeys()); return self(); }
/** * Handles the result of {@code save}. * <p> * Should be called on success or failure. */ // TODO(grantland): Remove once we convert saveEventually and ParseUser.signUp/resolveLaziness // to controllers Task<Void> handleSaveResultAsync( final JSONObject result, final ParseOperationSet operationsBeforeSave) { ParseObject.State newState = null; if (result != null) { // Success synchronized (mutex) { final Map<String, ParseObject> fetchedObjects = collectFetchedObjects(); ParseDecoder decoder = new KnownParseObjectDecoder(fetchedObjects); newState = ParseObjectCoder.get().decode(getState().newBuilder().clear(), result, decoder) .isComplete(false) .build(); } } return handleSaveResultAsync(newState, operationsBeforeSave); }
/** * Retrieves a {@code ParseObject} from a file on disk in /2/ format. * * @param coder Current coder to decode the ParseObject. * @param file The file to retrieve the object from. * @param builder An empty builder which is used to generate a empty state and rebuild a ParseObject. * @return The {@code ParseObject} that was retrieved. If the file wasn't found, or the contents * of the file is an invalid {@code ParseObject}, returns {@code null}. * @see #saveToDisk(ParseObjectCurrentCoder, ParseObject, File) */ private static <T extends ParseObject> T getFromDisk( ParseObjectCurrentCoder coder, File file, ParseObject.State.Init builder) { JSONObject json; try { json = ParseFileUtils.readFileToJSONObject(file); } catch (IOException | JSONException e) { return null; } ParseObject.State newState = coder.decode(builder, json, ParseDecoder.get()) .isComplete(true) .build(); return ParseObject.from(newState); }
@Override public ParseObject.State then(Task<JSONObject> task) { JSONObject result = task.getResult(); // Copy and clear to create an new empty instance of the same type as `state` ParseObject.State.Init<?> builder = state.newBuilder().clear(); return coder.decode(builder, result, decoder) .isComplete(false) .build(); } }));
@Override public ParseObject.State then(Task<JSONObject> task) { JSONObject result = task.getResult(); // Copy and clear to create an new empty instance of the same type as `state` ParseObject.State.Init<?> builder = state.newBuilder().clear(); return coder.decode(builder, result, decoder) .isComplete(true) .build(); } });
@Override public ParseObject.State then(Task<JSONObject> task) { JSONObject result = task.getResult(); // Copy and clear to create an new empty instance of the same type as `state` ParseObject.State.Init<?> builder = state.newBuilder().clear(); return coder.decode(builder, result, decoder) .isComplete(false) .build(); } });