id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
157,900
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreRemoteMongoCollectionWriteModelContainer.java
CoreRemoteMongoCollectionWriteModelContainer.commit
@Override public boolean commit() { final CoreRemoteMongoCollection<DocumentT> collection = getCollection(); final List<WriteModel<DocumentT>> writeModels = getBulkWriteModels(); // define success as any one operation succeeding for now boolean success = true; for (final WriteModel<DocumentT> write : writeModels) { if (write instanceof ReplaceOneModel) { final ReplaceOneModel<DocumentT> replaceModel = ((ReplaceOneModel) write); final RemoteUpdateResult result = collection.updateOne(replaceModel.getFilter(), (Bson) replaceModel.getReplacement()); success = success && (result != null && result.getModifiedCount() == result.getMatchedCount()); } else if (write instanceof UpdateOneModel) { final UpdateOneModel<DocumentT> updateModel = ((UpdateOneModel) write); final RemoteUpdateResult result = collection.updateOne(updateModel.getFilter(), updateModel.getUpdate()); success = success && (result != null && result.getModifiedCount() == result.getMatchedCount()); } else if (write instanceof UpdateManyModel) { final UpdateManyModel<DocumentT> updateModel = ((UpdateManyModel) write); final RemoteUpdateResult result = collection.updateMany(updateModel.getFilter(), updateModel.getUpdate()); success = success && (result != null && result.getModifiedCount() == result.getMatchedCount()); } } return success; }
java
@Override public boolean commit() { final CoreRemoteMongoCollection<DocumentT> collection = getCollection(); final List<WriteModel<DocumentT>> writeModels = getBulkWriteModels(); // define success as any one operation succeeding for now boolean success = true; for (final WriteModel<DocumentT> write : writeModels) { if (write instanceof ReplaceOneModel) { final ReplaceOneModel<DocumentT> replaceModel = ((ReplaceOneModel) write); final RemoteUpdateResult result = collection.updateOne(replaceModel.getFilter(), (Bson) replaceModel.getReplacement()); success = success && (result != null && result.getModifiedCount() == result.getMatchedCount()); } else if (write instanceof UpdateOneModel) { final UpdateOneModel<DocumentT> updateModel = ((UpdateOneModel) write); final RemoteUpdateResult result = collection.updateOne(updateModel.getFilter(), updateModel.getUpdate()); success = success && (result != null && result.getModifiedCount() == result.getMatchedCount()); } else if (write instanceof UpdateManyModel) { final UpdateManyModel<DocumentT> updateModel = ((UpdateManyModel) write); final RemoteUpdateResult result = collection.updateMany(updateModel.getFilter(), updateModel.getUpdate()); success = success && (result != null && result.getModifiedCount() == result.getMatchedCount()); } } return success; }
[ "@", "Override", "public", "boolean", "commit", "(", ")", "{", "final", "CoreRemoteMongoCollection", "<", "DocumentT", ">", "collection", "=", "getCollection", "(", ")", ";", "final", "List", "<", "WriteModel", "<", "DocumentT", ">", ">", "writeModels", "=", "getBulkWriteModels", "(", ")", ";", "// define success as any one operation succeeding for now", "boolean", "success", "=", "true", ";", "for", "(", "final", "WriteModel", "<", "DocumentT", ">", "write", ":", "writeModels", ")", "{", "if", "(", "write", "instanceof", "ReplaceOneModel", ")", "{", "final", "ReplaceOneModel", "<", "DocumentT", ">", "replaceModel", "=", "(", "(", "ReplaceOneModel", ")", "write", ")", ";", "final", "RemoteUpdateResult", "result", "=", "collection", ".", "updateOne", "(", "replaceModel", ".", "getFilter", "(", ")", ",", "(", "Bson", ")", "replaceModel", ".", "getReplacement", "(", ")", ")", ";", "success", "=", "success", "&&", "(", "result", "!=", "null", "&&", "result", ".", "getModifiedCount", "(", ")", "==", "result", ".", "getMatchedCount", "(", ")", ")", ";", "}", "else", "if", "(", "write", "instanceof", "UpdateOneModel", ")", "{", "final", "UpdateOneModel", "<", "DocumentT", ">", "updateModel", "=", "(", "(", "UpdateOneModel", ")", "write", ")", ";", "final", "RemoteUpdateResult", "result", "=", "collection", ".", "updateOne", "(", "updateModel", ".", "getFilter", "(", ")", ",", "updateModel", ".", "getUpdate", "(", ")", ")", ";", "success", "=", "success", "&&", "(", "result", "!=", "null", "&&", "result", ".", "getModifiedCount", "(", ")", "==", "result", ".", "getMatchedCount", "(", ")", ")", ";", "}", "else", "if", "(", "write", "instanceof", "UpdateManyModel", ")", "{", "final", "UpdateManyModel", "<", "DocumentT", ">", "updateModel", "=", "(", "(", "UpdateManyModel", ")", "write", ")", ";", "final", "RemoteUpdateResult", "result", "=", "collection", ".", "updateMany", "(", "updateModel", ".", "getFilter", "(", ")", ",", "updateModel", ".", "getUpdate", "(", ")", ")", ";", "success", "=", "success", "&&", "(", "result", "!=", "null", "&&", "result", ".", "getModifiedCount", "(", ")", "==", "result", ".", "getMatchedCount", "(", ")", ")", ";", "}", "}", "return", "success", ";", "}" ]
Commits the writes to the remote collection.
[ "Commits", "the", "writes", "to", "the", "remote", "collection", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreRemoteMongoCollectionWriteModelContainer.java#L47-L76
157,901
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/StitchAppRequestClientImpl.java
StitchAppRequestClientImpl.doRequest
@Override public Response doRequest(final StitchRequest stitchReq) { initAppMetadata(clientAppId); return super.doRequestUrl(stitchReq, getHostname()); }
java
@Override public Response doRequest(final StitchRequest stitchReq) { initAppMetadata(clientAppId); return super.doRequestUrl(stitchReq, getHostname()); }
[ "@", "Override", "public", "Response", "doRequest", "(", "final", "StitchRequest", "stitchReq", ")", "{", "initAppMetadata", "(", "clientAppId", ")", ";", "return", "super", ".", "doRequestUrl", "(", "stitchReq", ",", "getHostname", "(", ")", ")", ";", "}" ]
Performs a request against a Stitch app server determined by the deployment model of the underlying app. Throws a Stitch specific exception if the request fails. @param stitchReq the request to perform. @return a {@link Response} to the request.
[ "Performs", "a", "request", "against", "a", "Stitch", "app", "server", "determined", "by", "the", "deployment", "model", "of", "the", "underlying", "app", ".", "Throws", "a", "Stitch", "specific", "exception", "if", "the", "request", "fails", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/StitchAppRequestClientImpl.java#L51-L56
157,902
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/StitchAppRequestClientImpl.java
StitchAppRequestClientImpl.doStreamRequest
@Override public EventStream doStreamRequest(final StitchRequest stitchReq) { initAppMetadata(clientAppId); return super.doStreamRequestUrl(stitchReq, getHostname()); }
java
@Override public EventStream doStreamRequest(final StitchRequest stitchReq) { initAppMetadata(clientAppId); return super.doStreamRequestUrl(stitchReq, getHostname()); }
[ "@", "Override", "public", "EventStream", "doStreamRequest", "(", "final", "StitchRequest", "stitchReq", ")", "{", "initAppMetadata", "(", "clientAppId", ")", ";", "return", "super", ".", "doStreamRequestUrl", "(", "stitchReq", ",", "getHostname", "(", ")", ")", ";", "}" ]
Performs a streaming request against a Stitch app server determined by the deployment model of the underlying app. Throws a Stitch specific exception if the request fails. @param stitchReq the request to perform. @return an {@link EventStream} that will provide response events.
[ "Performs", "a", "streaming", "request", "against", "a", "Stitch", "app", "server", "determined", "by", "the", "deployment", "model", "of", "the", "underlying", "app", ".", "Throws", "a", "Stitch", "specific", "exception", "if", "the", "request", "fails", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/StitchAppRequestClientImpl.java#L65-L70
157,903
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/UpdateDescription.java
UpdateDescription.toUpdateDocument
public BsonDocument toUpdateDocument() { final List<BsonElement> unsets = new ArrayList<>(); for (final String removedField : this.removedFields) { unsets.add(new BsonElement(removedField, new BsonBoolean(true))); } final BsonDocument updateDocument = new BsonDocument(); if (this.updatedFields.size() > 0) { updateDocument.append("$set", this.updatedFields); } if (unsets.size() > 0) { updateDocument.append("$unset", new BsonDocument(unsets)); } return updateDocument; }
java
public BsonDocument toUpdateDocument() { final List<BsonElement> unsets = new ArrayList<>(); for (final String removedField : this.removedFields) { unsets.add(new BsonElement(removedField, new BsonBoolean(true))); } final BsonDocument updateDocument = new BsonDocument(); if (this.updatedFields.size() > 0) { updateDocument.append("$set", this.updatedFields); } if (unsets.size() > 0) { updateDocument.append("$unset", new BsonDocument(unsets)); } return updateDocument; }
[ "public", "BsonDocument", "toUpdateDocument", "(", ")", "{", "final", "List", "<", "BsonElement", ">", "unsets", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "String", "removedField", ":", "this", ".", "removedFields", ")", "{", "unsets", ".", "add", "(", "new", "BsonElement", "(", "removedField", ",", "new", "BsonBoolean", "(", "true", ")", ")", ")", ";", "}", "final", "BsonDocument", "updateDocument", "=", "new", "BsonDocument", "(", ")", ";", "if", "(", "this", ".", "updatedFields", ".", "size", "(", ")", ">", "0", ")", "{", "updateDocument", ".", "append", "(", "\"$set\"", ",", "this", ".", "updatedFields", ")", ";", "}", "if", "(", "unsets", ".", "size", "(", ")", ">", "0", ")", "{", "updateDocument", ".", "append", "(", "\"$unset\"", ",", "new", "BsonDocument", "(", "unsets", ")", ")", ";", "}", "return", "updateDocument", ";", "}" ]
Convert this update description to an update document. @return an update document with the appropriate $set and $unset documents.
[ "Convert", "this", "update", "description", "to", "an", "update", "document", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/UpdateDescription.java#L84-L100
157,904
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/UpdateDescription.java
UpdateDescription.toBsonDocument
public BsonDocument toBsonDocument() { final BsonDocument updateDescDoc = new BsonDocument(); updateDescDoc.put( Fields.UPDATED_FIELDS_FIELD, this.getUpdatedFields()); final BsonArray removedFields = new BsonArray(); for (final String field : this.getRemovedFields()) { removedFields.add(new BsonString(field)); } updateDescDoc.put( Fields.REMOVED_FIELDS_FIELD, removedFields); return updateDescDoc; }
java
public BsonDocument toBsonDocument() { final BsonDocument updateDescDoc = new BsonDocument(); updateDescDoc.put( Fields.UPDATED_FIELDS_FIELD, this.getUpdatedFields()); final BsonArray removedFields = new BsonArray(); for (final String field : this.getRemovedFields()) { removedFields.add(new BsonString(field)); } updateDescDoc.put( Fields.REMOVED_FIELDS_FIELD, removedFields); return updateDescDoc; }
[ "public", "BsonDocument", "toBsonDocument", "(", ")", "{", "final", "BsonDocument", "updateDescDoc", "=", "new", "BsonDocument", "(", ")", ";", "updateDescDoc", ".", "put", "(", "Fields", ".", "UPDATED_FIELDS_FIELD", ",", "this", ".", "getUpdatedFields", "(", ")", ")", ";", "final", "BsonArray", "removedFields", "=", "new", "BsonArray", "(", ")", ";", "for", "(", "final", "String", "field", ":", "this", ".", "getRemovedFields", "(", ")", ")", "{", "removedFields", ".", "add", "(", "new", "BsonString", "(", "field", ")", ")", ";", "}", "updateDescDoc", ".", "put", "(", "Fields", ".", "REMOVED_FIELDS_FIELD", ",", "removedFields", ")", ";", "return", "updateDescDoc", ";", "}" ]
Converts this update description to its document representation as it would appear in a MongoDB Change Event. @return the update description document as it would appear in a change event
[ "Converts", "this", "update", "description", "to", "its", "document", "representation", "as", "it", "would", "appear", "in", "a", "MongoDB", "Change", "Event", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/UpdateDescription.java#L108-L123
157,905
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/UpdateDescription.java
UpdateDescription.fromBsonDocument
public static UpdateDescription fromBsonDocument(final BsonDocument document) { keyPresent(Fields.UPDATED_FIELDS_FIELD, document); keyPresent(Fields.REMOVED_FIELDS_FIELD, document); final BsonArray removedFieldsArr = document.getArray(Fields.REMOVED_FIELDS_FIELD); final Set<String> removedFields = new HashSet<>(removedFieldsArr.size()); for (final BsonValue field : removedFieldsArr) { removedFields.add(field.asString().getValue()); } return new UpdateDescription(document.getDocument(Fields.UPDATED_FIELDS_FIELD), removedFields); }
java
public static UpdateDescription fromBsonDocument(final BsonDocument document) { keyPresent(Fields.UPDATED_FIELDS_FIELD, document); keyPresent(Fields.REMOVED_FIELDS_FIELD, document); final BsonArray removedFieldsArr = document.getArray(Fields.REMOVED_FIELDS_FIELD); final Set<String> removedFields = new HashSet<>(removedFieldsArr.size()); for (final BsonValue field : removedFieldsArr) { removedFields.add(field.asString().getValue()); } return new UpdateDescription(document.getDocument(Fields.UPDATED_FIELDS_FIELD), removedFields); }
[ "public", "static", "UpdateDescription", "fromBsonDocument", "(", "final", "BsonDocument", "document", ")", "{", "keyPresent", "(", "Fields", ".", "UPDATED_FIELDS_FIELD", ",", "document", ")", ";", "keyPresent", "(", "Fields", ".", "REMOVED_FIELDS_FIELD", ",", "document", ")", ";", "final", "BsonArray", "removedFieldsArr", "=", "document", ".", "getArray", "(", "Fields", ".", "REMOVED_FIELDS_FIELD", ")", ";", "final", "Set", "<", "String", ">", "removedFields", "=", "new", "HashSet", "<>", "(", "removedFieldsArr", ".", "size", "(", ")", ")", ";", "for", "(", "final", "BsonValue", "field", ":", "removedFieldsArr", ")", "{", "removedFields", ".", "add", "(", "field", ".", "asString", "(", ")", ".", "getValue", "(", ")", ")", ";", "}", "return", "new", "UpdateDescription", "(", "document", ".", "getDocument", "(", "Fields", ".", "UPDATED_FIELDS_FIELD", ")", ",", "removedFields", ")", ";", "}" ]
Converts an update description BSON document from a MongoDB Change Event into an UpdateDescription object. @param document the @return the converted UpdateDescription
[ "Converts", "an", "update", "description", "BSON", "document", "from", "a", "MongoDB", "Change", "Event", "into", "an", "UpdateDescription", "object", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/UpdateDescription.java#L132-L144
157,906
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/UpdateDescription.java
UpdateDescription.merge
public UpdateDescription merge(@Nullable final UpdateDescription otherDescription) { if (otherDescription != null) { for (final Map.Entry<String, BsonValue> entry : this.updatedFields.entrySet()) { if (otherDescription.removedFields.contains(entry.getKey())) { this.updatedFields.remove(entry.getKey()); } } for (final String removedField : this.removedFields) { if (otherDescription.updatedFields.containsKey(removedField)) { this.removedFields.remove(removedField); } } this.removedFields.addAll(otherDescription.removedFields); this.updatedFields.putAll(otherDescription.updatedFields); } return this; }
java
public UpdateDescription merge(@Nullable final UpdateDescription otherDescription) { if (otherDescription != null) { for (final Map.Entry<String, BsonValue> entry : this.updatedFields.entrySet()) { if (otherDescription.removedFields.contains(entry.getKey())) { this.updatedFields.remove(entry.getKey()); } } for (final String removedField : this.removedFields) { if (otherDescription.updatedFields.containsKey(removedField)) { this.removedFields.remove(removedField); } } this.removedFields.addAll(otherDescription.removedFields); this.updatedFields.putAll(otherDescription.updatedFields); } return this; }
[ "public", "UpdateDescription", "merge", "(", "@", "Nullable", "final", "UpdateDescription", "otherDescription", ")", "{", "if", "(", "otherDescription", "!=", "null", ")", "{", "for", "(", "final", "Map", ".", "Entry", "<", "String", ",", "BsonValue", ">", "entry", ":", "this", ".", "updatedFields", ".", "entrySet", "(", ")", ")", "{", "if", "(", "otherDescription", ".", "removedFields", ".", "contains", "(", "entry", ".", "getKey", "(", ")", ")", ")", "{", "this", ".", "updatedFields", ".", "remove", "(", "entry", ".", "getKey", "(", ")", ")", ";", "}", "}", "for", "(", "final", "String", "removedField", ":", "this", ".", "removedFields", ")", "{", "if", "(", "otherDescription", ".", "updatedFields", ".", "containsKey", "(", "removedField", ")", ")", "{", "this", ".", "removedFields", ".", "remove", "(", "removedField", ")", ";", "}", "}", "this", ".", "removedFields", ".", "addAll", "(", "otherDescription", ".", "removedFields", ")", ";", "this", ".", "updatedFields", ".", "putAll", "(", "otherDescription", ".", "updatedFields", ")", ";", "}", "return", "this", ";", "}" ]
Unilaterally merge an update description into this update description. @param otherDescription the update description to merge into this @return this merged update description
[ "Unilaterally", "merge", "an", "update", "description", "into", "this", "update", "description", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/UpdateDescription.java#L151-L169
157,907
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/internal/CoreRemoteMongoCollectionImpl.java
CoreRemoteMongoCollectionImpl.watch
@Override @SuppressWarnings("unchecked") public Stream<ChangeEvent<DocumentT>> watch(final BsonValue... ids) throws InterruptedException, IOException { return operations.watch( new HashSet<>(Arrays.asList(ids)), false, documentClass ).execute(service); }
java
@Override @SuppressWarnings("unchecked") public Stream<ChangeEvent<DocumentT>> watch(final BsonValue... ids) throws InterruptedException, IOException { return operations.watch( new HashSet<>(Arrays.asList(ids)), false, documentClass ).execute(service); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Stream", "<", "ChangeEvent", "<", "DocumentT", ">", ">", "watch", "(", "final", "BsonValue", "...", "ids", ")", "throws", "InterruptedException", ",", "IOException", "{", "return", "operations", ".", "watch", "(", "new", "HashSet", "<>", "(", "Arrays", ".", "asList", "(", "ids", ")", ")", ",", "false", ",", "documentClass", ")", ".", "execute", "(", "service", ")", ";", "}" ]
Watches specified IDs in a collection. @param ids the ids to watch. @return the stream of change events.
[ "Watches", "specified", "IDs", "in", "a", "collection", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/internal/CoreRemoteMongoCollectionImpl.java#L709-L718
157,908
mongodb/stitch-android-sdk
android/services/mongodb-remote/src/main/java/com/mongodb/stitch/android/services/mongodb/remote/internal/SyncImpl.java
SyncImpl.updateSyncFrequency
public Task<Void> updateSyncFrequency(@NonNull final SyncFrequency syncFrequency) { return this.dispatcher.dispatchTask(new Callable<Void>() { @Override public Void call() throws Exception { SyncImpl.this.proxy.updateSyncFrequency(syncFrequency); return null; } }); }
java
public Task<Void> updateSyncFrequency(@NonNull final SyncFrequency syncFrequency) { return this.dispatcher.dispatchTask(new Callable<Void>() { @Override public Void call() throws Exception { SyncImpl.this.proxy.updateSyncFrequency(syncFrequency); return null; } }); }
[ "public", "Task", "<", "Void", ">", "updateSyncFrequency", "(", "@", "NonNull", "final", "SyncFrequency", "syncFrequency", ")", "{", "return", "this", ".", "dispatcher", ".", "dispatchTask", "(", "new", "Callable", "<", "Void", ">", "(", ")", "{", "@", "Override", "public", "Void", "call", "(", ")", "throws", "Exception", "{", "SyncImpl", ".", "this", ".", "proxy", ".", "updateSyncFrequency", "(", "syncFrequency", ")", ";", "return", "null", ";", "}", "}", ")", ";", "}" ]
Sets the SyncFrequency on this collection. @param syncFrequency the SyncFrequency that contains all the desired options @return A Task that completes when the SyncFrequency has been updated
[ "Sets", "the", "SyncFrequency", "on", "this", "collection", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/services/mongodb-remote/src/main/java/com/mongodb/stitch/android/services/mongodb/remote/internal/SyncImpl.java#L95-L103
157,909
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/EventDispatcher.java
EventDispatcher.emitEvent
public void emitEvent( final NamespaceSynchronizationConfig nsConfig, final ChangeEvent<BsonDocument> event) { listenersLock.lock(); try { if (nsConfig.getNamespaceListenerConfig() == null) { return; } final NamespaceListenerConfig namespaceListener = nsConfig.getNamespaceListenerConfig(); eventDispatcher.dispatch(() -> { try { if (namespaceListener.getEventListener() != null) { namespaceListener.getEventListener().onEvent( BsonUtils.getDocumentId(event.getDocumentKey()), ChangeEvents.transformChangeEventForUser( event, namespaceListener.getDocumentCodec())); } } catch (final Exception ex) { logger.error(String.format( Locale.US, "emitEvent ns=%s documentId=%s emit exception: %s", event.getNamespace(), BsonUtils.getDocumentId(event.getDocumentKey()), ex), ex); } return null; }); } finally { listenersLock.unlock(); } }
java
public void emitEvent( final NamespaceSynchronizationConfig nsConfig, final ChangeEvent<BsonDocument> event) { listenersLock.lock(); try { if (nsConfig.getNamespaceListenerConfig() == null) { return; } final NamespaceListenerConfig namespaceListener = nsConfig.getNamespaceListenerConfig(); eventDispatcher.dispatch(() -> { try { if (namespaceListener.getEventListener() != null) { namespaceListener.getEventListener().onEvent( BsonUtils.getDocumentId(event.getDocumentKey()), ChangeEvents.transformChangeEventForUser( event, namespaceListener.getDocumentCodec())); } } catch (final Exception ex) { logger.error(String.format( Locale.US, "emitEvent ns=%s documentId=%s emit exception: %s", event.getNamespace(), BsonUtils.getDocumentId(event.getDocumentKey()), ex), ex); } return null; }); } finally { listenersLock.unlock(); } }
[ "public", "void", "emitEvent", "(", "final", "NamespaceSynchronizationConfig", "nsConfig", ",", "final", "ChangeEvent", "<", "BsonDocument", ">", "event", ")", "{", "listenersLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "nsConfig", ".", "getNamespaceListenerConfig", "(", ")", "==", "null", ")", "{", "return", ";", "}", "final", "NamespaceListenerConfig", "namespaceListener", "=", "nsConfig", ".", "getNamespaceListenerConfig", "(", ")", ";", "eventDispatcher", ".", "dispatch", "(", "(", ")", "->", "{", "try", "{", "if", "(", "namespaceListener", ".", "getEventListener", "(", ")", "!=", "null", ")", "{", "namespaceListener", ".", "getEventListener", "(", ")", ".", "onEvent", "(", "BsonUtils", ".", "getDocumentId", "(", "event", ".", "getDocumentKey", "(", ")", ")", ",", "ChangeEvents", ".", "transformChangeEventForUser", "(", "event", ",", "namespaceListener", ".", "getDocumentCodec", "(", ")", ")", ")", ";", "}", "}", "catch", "(", "final", "Exception", "ex", ")", "{", "logger", ".", "error", "(", "String", ".", "format", "(", "Locale", ".", "US", ",", "\"emitEvent ns=%s documentId=%s emit exception: %s\"", ",", "event", ".", "getNamespace", "(", ")", ",", "BsonUtils", ".", "getDocumentId", "(", "event", ".", "getDocumentKey", "(", ")", ")", ",", "ex", ")", ",", "ex", ")", ";", "}", "return", "null", ";", "}", ")", ";", "}", "finally", "{", "listenersLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Emits a change event for the given document id. @param nsConfig the configuration for the namespace to which the document referred to by the change event belongs. @param event the change event.
[ "Emits", "a", "change", "event", "for", "the", "given", "document", "id", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/EventDispatcher.java#L50-L81
157,910
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/ChangeEvents.java
ChangeEvents.changeEventForLocalInsert
static ChangeEvent<BsonDocument> changeEventForLocalInsert( final MongoNamespace namespace, final BsonDocument document, final boolean writePending ) { final BsonValue docId = BsonUtils.getDocumentId(document); return new ChangeEvent<>( new BsonDocument(), OperationType.INSERT, document, namespace, new BsonDocument("_id", docId), null, writePending); }
java
static ChangeEvent<BsonDocument> changeEventForLocalInsert( final MongoNamespace namespace, final BsonDocument document, final boolean writePending ) { final BsonValue docId = BsonUtils.getDocumentId(document); return new ChangeEvent<>( new BsonDocument(), OperationType.INSERT, document, namespace, new BsonDocument("_id", docId), null, writePending); }
[ "static", "ChangeEvent", "<", "BsonDocument", ">", "changeEventForLocalInsert", "(", "final", "MongoNamespace", "namespace", ",", "final", "BsonDocument", "document", ",", "final", "boolean", "writePending", ")", "{", "final", "BsonValue", "docId", "=", "BsonUtils", ".", "getDocumentId", "(", "document", ")", ";", "return", "new", "ChangeEvent", "<>", "(", "new", "BsonDocument", "(", ")", ",", "OperationType", ".", "INSERT", ",", "document", ",", "namespace", ",", "new", "BsonDocument", "(", "\"_id\"", ",", "docId", ")", ",", "null", ",", "writePending", ")", ";", "}" ]
Generates a change event for a local insert of the given document in the given namespace. @param namespace the namespace where the document was inserted. @param document the document that was inserted. @return a change event for a local insert of the given document in the given namespace.
[ "Generates", "a", "change", "event", "for", "a", "local", "insert", "of", "the", "given", "document", "in", "the", "given", "namespace", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/ChangeEvents.java#L40-L54
157,911
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/ChangeEvents.java
ChangeEvents.changeEventForLocalUpdate
static ChangeEvent<BsonDocument> changeEventForLocalUpdate( final MongoNamespace namespace, final BsonValue documentId, final UpdateDescription update, final BsonDocument fullDocumentAfterUpdate, final boolean writePending ) { return new ChangeEvent<>( new BsonDocument(), OperationType.UPDATE, fullDocumentAfterUpdate, namespace, new BsonDocument("_id", documentId), update, writePending); }
java
static ChangeEvent<BsonDocument> changeEventForLocalUpdate( final MongoNamespace namespace, final BsonValue documentId, final UpdateDescription update, final BsonDocument fullDocumentAfterUpdate, final boolean writePending ) { return new ChangeEvent<>( new BsonDocument(), OperationType.UPDATE, fullDocumentAfterUpdate, namespace, new BsonDocument("_id", documentId), update, writePending); }
[ "static", "ChangeEvent", "<", "BsonDocument", ">", "changeEventForLocalUpdate", "(", "final", "MongoNamespace", "namespace", ",", "final", "BsonValue", "documentId", ",", "final", "UpdateDescription", "update", ",", "final", "BsonDocument", "fullDocumentAfterUpdate", ",", "final", "boolean", "writePending", ")", "{", "return", "new", "ChangeEvent", "<>", "(", "new", "BsonDocument", "(", ")", ",", "OperationType", ".", "UPDATE", ",", "fullDocumentAfterUpdate", ",", "namespace", ",", "new", "BsonDocument", "(", "\"_id\"", ",", "documentId", ")", ",", "update", ",", "writePending", ")", ";", "}" ]
Generates a change event for a local update of a document in the given namespace referring to the given document _id. @param namespace the namespace where the document was inserted. @param documentId the _id of the document that was updated. @param update the update specifier. @return a change event for a local update of a document in the given namespace referring to the given document _id.
[ "Generates", "a", "change", "event", "for", "a", "local", "update", "of", "a", "document", "in", "the", "given", "namespace", "referring", "to", "the", "given", "document", "_id", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/ChangeEvents.java#L66-L81
157,912
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/ChangeEvents.java
ChangeEvents.changeEventForLocalReplace
static ChangeEvent<BsonDocument> changeEventForLocalReplace( final MongoNamespace namespace, final BsonValue documentId, final BsonDocument document, final boolean writePending ) { return new ChangeEvent<>( new BsonDocument(), OperationType.REPLACE, document, namespace, new BsonDocument("_id", documentId), null, writePending); }
java
static ChangeEvent<BsonDocument> changeEventForLocalReplace( final MongoNamespace namespace, final BsonValue documentId, final BsonDocument document, final boolean writePending ) { return new ChangeEvent<>( new BsonDocument(), OperationType.REPLACE, document, namespace, new BsonDocument("_id", documentId), null, writePending); }
[ "static", "ChangeEvent", "<", "BsonDocument", ">", "changeEventForLocalReplace", "(", "final", "MongoNamespace", "namespace", ",", "final", "BsonValue", "documentId", ",", "final", "BsonDocument", "document", ",", "final", "boolean", "writePending", ")", "{", "return", "new", "ChangeEvent", "<>", "(", "new", "BsonDocument", "(", ")", ",", "OperationType", ".", "REPLACE", ",", "document", ",", "namespace", ",", "new", "BsonDocument", "(", "\"_id\"", ",", "documentId", ")", ",", "null", ",", "writePending", ")", ";", "}" ]
Generates a change event for a local replacement of a document in the given namespace referring to the given document _id. @param namespace the namespace where the document was inserted. @param documentId the _id of the document that was updated. @param document the replacement document. @return a change event for a local replacement of a document in the given namespace referring to the given document _id.
[ "Generates", "a", "change", "event", "for", "a", "local", "replacement", "of", "a", "document", "in", "the", "given", "namespace", "referring", "to", "the", "given", "document", "_id", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/ChangeEvents.java#L93-L107
157,913
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/ChangeEvents.java
ChangeEvents.changeEventForLocalDelete
static ChangeEvent<BsonDocument> changeEventForLocalDelete( final MongoNamespace namespace, final BsonValue documentId, final boolean writePending ) { return new ChangeEvent<>( new BsonDocument(), OperationType.DELETE, null, namespace, new BsonDocument("_id", documentId), null, writePending); }
java
static ChangeEvent<BsonDocument> changeEventForLocalDelete( final MongoNamespace namespace, final BsonValue documentId, final boolean writePending ) { return new ChangeEvent<>( new BsonDocument(), OperationType.DELETE, null, namespace, new BsonDocument("_id", documentId), null, writePending); }
[ "static", "ChangeEvent", "<", "BsonDocument", ">", "changeEventForLocalDelete", "(", "final", "MongoNamespace", "namespace", ",", "final", "BsonValue", "documentId", ",", "final", "boolean", "writePending", ")", "{", "return", "new", "ChangeEvent", "<>", "(", "new", "BsonDocument", "(", ")", ",", "OperationType", ".", "DELETE", ",", "null", ",", "namespace", ",", "new", "BsonDocument", "(", "\"_id\"", ",", "documentId", ")", ",", "null", ",", "writePending", ")", ";", "}" ]
Generates a change event for a local deletion of a document in the given namespace referring to the given document _id. @param namespace the namespace where the document was inserted. @param documentId the _id of the document that was updated. @return a change event for a local deletion of a document in the given namespace referring to the given document _id.
[ "Generates", "a", "change", "event", "for", "a", "local", "deletion", "of", "a", "document", "in", "the", "given", "namespace", "referring", "to", "the", "given", "document", "_id", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/ChangeEvents.java#L118-L131
157,914
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/Assertions.java
Assertions.notNull
public static <T> void notNull(final String name, final T value) { if (value == null) { throw new IllegalArgumentException(name + " can not be null"); } }
java
public static <T> void notNull(final String name, final T value) { if (value == null) { throw new IllegalArgumentException(name + " can not be null"); } }
[ "public", "static", "<", "T", ">", "void", "notNull", "(", "final", "String", "name", ",", "final", "T", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "name", "+", "\" can not be null\"", ")", ";", "}", "}" ]
Throw IllegalArgumentException if the value is null. @param name the parameter name. @param value the value that should not be null. @param <T> the value type. @throws IllegalArgumentException if value is null.
[ "Throw", "IllegalArgumentException", "if", "the", "value", "is", "null", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/Assertions.java#L30-L34
157,915
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/Assertions.java
Assertions.keyPresent
public static void keyPresent(final String key, final Map<String, ?> map) { if (!map.containsKey(key)) { throw new IllegalStateException( String.format("expected %s to be present", key)); } }
java
public static void keyPresent(final String key, final Map<String, ?> map) { if (!map.containsKey(key)) { throw new IllegalStateException( String.format("expected %s to be present", key)); } }
[ "public", "static", "void", "keyPresent", "(", "final", "String", "key", ",", "final", "Map", "<", "String", ",", "?", ">", "map", ")", "{", "if", "(", "!", "map", ".", "containsKey", "(", "key", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "String", ".", "format", "(", "\"expected %s to be present\"", ",", "key", ")", ")", ";", "}", "}" ]
Throw IllegalStateException if key is not present in map. @param key the key to expect. @param map the map to search. @throws IllegalArgumentException if key is not in map.
[ "Throw", "IllegalStateException", "if", "key", "is", "not", "present", "in", "map", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/Assertions.java#L42-L47
157,916
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/BsonUtils.java
BsonUtils.copyOfDocument
public static BsonDocument copyOfDocument(final BsonDocument document) { final BsonDocument newDocument = new BsonDocument(); for (final Map.Entry<String, BsonValue> kv : document.entrySet()) { newDocument.put(kv.getKey(), kv.getValue()); } return newDocument; }
java
public static BsonDocument copyOfDocument(final BsonDocument document) { final BsonDocument newDocument = new BsonDocument(); for (final Map.Entry<String, BsonValue> kv : document.entrySet()) { newDocument.put(kv.getKey(), kv.getValue()); } return newDocument; }
[ "public", "static", "BsonDocument", "copyOfDocument", "(", "final", "BsonDocument", "document", ")", "{", "final", "BsonDocument", "newDocument", "=", "new", "BsonDocument", "(", ")", ";", "for", "(", "final", "Map", ".", "Entry", "<", "String", ",", "BsonValue", ">", "kv", ":", "document", ".", "entrySet", "(", ")", ")", "{", "newDocument", ".", "put", "(", "kv", ".", "getKey", "(", ")", ",", "kv", ".", "getValue", "(", ")", ")", ";", "}", "return", "newDocument", ";", "}" ]
Returns a copy of the given document. @param document the document to copy. @return a copy of the given document.
[ "Returns", "a", "copy", "of", "the", "given", "document", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/BsonUtils.java#L150-L156
157,917
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/DefaultSyncConflictResolvers.java
DefaultSyncConflictResolvers.localWins
public static <T> ConflictHandler<T> localWins() { return new ConflictHandler<T>() { @Override public T resolveConflict( final BsonValue documentId, final ChangeEvent<T> localEvent, final ChangeEvent<T> remoteEvent ) { return localEvent.getFullDocument(); } }; }
java
public static <T> ConflictHandler<T> localWins() { return new ConflictHandler<T>() { @Override public T resolveConflict( final BsonValue documentId, final ChangeEvent<T> localEvent, final ChangeEvent<T> remoteEvent ) { return localEvent.getFullDocument(); } }; }
[ "public", "static", "<", "T", ">", "ConflictHandler", "<", "T", ">", "localWins", "(", ")", "{", "return", "new", "ConflictHandler", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "T", "resolveConflict", "(", "final", "BsonValue", "documentId", ",", "final", "ChangeEvent", "<", "T", ">", "localEvent", ",", "final", "ChangeEvent", "<", "T", ">", "remoteEvent", ")", "{", "return", "localEvent", ".", "getFullDocument", "(", ")", ";", "}", "}", ";", "}" ]
The local event will decide the next state of the document in question. @param <T> the type of class represented by the document in the change event. @return the local full document which may be null.
[ "The", "local", "event", "will", "decide", "the", "next", "state", "of", "the", "document", "in", "question", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/DefaultSyncConflictResolvers.java#L53-L64
157,918
mongodb/stitch-android-sdk
android/examples/todo/src/main/java/com/mongodb/stitch/android/examples/todo/TodoItem.java
TodoItem.isTodoItem
public static boolean isTodoItem(final Document todoItemDoc) { return todoItemDoc.containsKey(ID_KEY) && todoItemDoc.containsKey(TASK_KEY) && todoItemDoc.containsKey(CHECKED_KEY); }
java
public static boolean isTodoItem(final Document todoItemDoc) { return todoItemDoc.containsKey(ID_KEY) && todoItemDoc.containsKey(TASK_KEY) && todoItemDoc.containsKey(CHECKED_KEY); }
[ "public", "static", "boolean", "isTodoItem", "(", "final", "Document", "todoItemDoc", ")", "{", "return", "todoItemDoc", ".", "containsKey", "(", "ID_KEY", ")", "&&", "todoItemDoc", ".", "containsKey", "(", "TASK_KEY", ")", "&&", "todoItemDoc", ".", "containsKey", "(", "CHECKED_KEY", ")", ";", "}" ]
Returns if a MongoDB document is a todo item.
[ "Returns", "if", "a", "MongoDB", "document", "is", "a", "todo", "item", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/examples/todo/src/main/java/com/mongodb/stitch/android/examples/todo/TodoItem.java#L49-L53
157,919
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.recover
void recover() { final List<NamespaceSynchronizationConfig> nsConfigs = new ArrayList<>(); for (final MongoNamespace ns : this.syncConfig.getSynchronizedNamespaces()) { nsConfigs.add(this.syncConfig.getNamespaceConfig(ns)); } for (final NamespaceSynchronizationConfig nsConfig : nsConfigs) { nsConfig.getLock().writeLock().lock(); } try { for (final NamespaceSynchronizationConfig nsConfig : nsConfigs) { nsConfig.getLock().writeLock().lock(); try { recoverNamespace(nsConfig); } finally { nsConfig.getLock().writeLock().unlock(); } } } finally { for (final NamespaceSynchronizationConfig nsConfig : nsConfigs) { nsConfig.getLock().writeLock().unlock(); } } }
java
void recover() { final List<NamespaceSynchronizationConfig> nsConfigs = new ArrayList<>(); for (final MongoNamespace ns : this.syncConfig.getSynchronizedNamespaces()) { nsConfigs.add(this.syncConfig.getNamespaceConfig(ns)); } for (final NamespaceSynchronizationConfig nsConfig : nsConfigs) { nsConfig.getLock().writeLock().lock(); } try { for (final NamespaceSynchronizationConfig nsConfig : nsConfigs) { nsConfig.getLock().writeLock().lock(); try { recoverNamespace(nsConfig); } finally { nsConfig.getLock().writeLock().unlock(); } } } finally { for (final NamespaceSynchronizationConfig nsConfig : nsConfigs) { nsConfig.getLock().writeLock().unlock(); } } }
[ "void", "recover", "(", ")", "{", "final", "List", "<", "NamespaceSynchronizationConfig", ">", "nsConfigs", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "MongoNamespace", "ns", ":", "this", ".", "syncConfig", ".", "getSynchronizedNamespaces", "(", ")", ")", "{", "nsConfigs", ".", "add", "(", "this", ".", "syncConfig", ".", "getNamespaceConfig", "(", "ns", ")", ")", ";", "}", "for", "(", "final", "NamespaceSynchronizationConfig", "nsConfig", ":", "nsConfigs", ")", "{", "nsConfig", ".", "getLock", "(", ")", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "}", "try", "{", "for", "(", "final", "NamespaceSynchronizationConfig", "nsConfig", ":", "nsConfigs", ")", "{", "nsConfig", ".", "getLock", "(", ")", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "recoverNamespace", "(", "nsConfig", ")", ";", "}", "finally", "{", "nsConfig", ".", "getLock", "(", ")", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}", "}", "finally", "{", "for", "(", "final", "NamespaceSynchronizationConfig", "nsConfig", ":", "nsConfigs", ")", "{", "nsConfig", ".", "getLock", "(", ")", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}", "}" ]
Recovers the state of synchronization in case a system failure happened. The goal is to revert to a known, good state.
[ "Recovers", "the", "state", "of", "synchronization", "in", "case", "a", "system", "failure", "happened", ".", "The", "goal", "is", "to", "revert", "to", "a", "known", "good", "state", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L197-L220
157,920
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.recoverNamespace
private void recoverNamespace(final NamespaceSynchronizationConfig nsConfig) { final MongoCollection<BsonDocument> undoCollection = getUndoCollection(nsConfig.getNamespace()); final MongoCollection<BsonDocument> localCollection = getLocalCollection(nsConfig.getNamespace()); final List<BsonDocument> undoDocs = undoCollection.find().into(new ArrayList<>()); final Set<BsonValue> recoveredIds = new HashSet<>(); // Replace local docs with undo docs. Presence of an undo doc implies we had a system failure // during a write. This covers updates and deletes. for (final BsonDocument undoDoc : undoDocs) { final BsonValue documentId = BsonUtils.getDocumentId(undoDoc); final BsonDocument filter = getDocumentIdFilter(documentId); localCollection.findOneAndReplace( filter, undoDoc, new FindOneAndReplaceOptions().upsert(true)); recoveredIds.add(documentId); } // If we recovered a document, but its pending writes are set to do something else, then the // failure occurred after the pending writes were set, but before the undo document was // deleted. In this case, we should restore the document to the state that the pending // write indicates. There is a possibility that the pending write is from before the failed // operation, but in that case, the findOneAndReplace or delete is a no-op since restoring // the document to the state of the change event would be the same as recovering the undo // document. for (final CoreDocumentSynchronizationConfig docConfig : nsConfig.getSynchronizedDocuments()) { final BsonValue documentId = docConfig.getDocumentId(); final BsonDocument filter = getDocumentIdFilter(documentId); if (recoveredIds.contains(docConfig.getDocumentId())) { final ChangeEvent<BsonDocument> pendingWrite = docConfig.getLastUncommittedChangeEvent(); if (pendingWrite != null) { switch (pendingWrite.getOperationType()) { case INSERT: case UPDATE: case REPLACE: localCollection.findOneAndReplace( filter, pendingWrite.getFullDocument(), new FindOneAndReplaceOptions().upsert(true) ); break; case DELETE: localCollection.deleteOne(filter); break; default: // There should never be pending writes with an unknown event type, but if someone // is messing with the config collection we want to stop the synchronizer to prevent // further data corruption. throw new IllegalStateException( "there should not be a pending write with an unknown event type" ); } } } } // Delete all of our undo documents. If we've reached this point, we've recovered the local // collection to the state we want with respect to all of our undo documents. If we fail before // these deletes or while carrying out the deletes, but after recovering the documents to // their desired state, that's okay because the next recovery pass will be effectively a no-op // up to this point. for (final BsonValue recoveredId : recoveredIds) { undoCollection.deleteOne(getDocumentIdFilter(recoveredId)); } // Find local documents for which there are no document configs and delete them. This covers // inserts, upserts, and desync deletes. This will occur on any recovery pass regardless of // the documents in the undo collection, so it's fine that we do this after deleting the undo // documents. localCollection.deleteMany(new BsonDocument( "_id", new BsonDocument( "$nin", new BsonArray(new ArrayList<>( this.syncConfig.getSynchronizedDocumentIds(nsConfig.getNamespace())))))); }
java
private void recoverNamespace(final NamespaceSynchronizationConfig nsConfig) { final MongoCollection<BsonDocument> undoCollection = getUndoCollection(nsConfig.getNamespace()); final MongoCollection<BsonDocument> localCollection = getLocalCollection(nsConfig.getNamespace()); final List<BsonDocument> undoDocs = undoCollection.find().into(new ArrayList<>()); final Set<BsonValue> recoveredIds = new HashSet<>(); // Replace local docs with undo docs. Presence of an undo doc implies we had a system failure // during a write. This covers updates and deletes. for (final BsonDocument undoDoc : undoDocs) { final BsonValue documentId = BsonUtils.getDocumentId(undoDoc); final BsonDocument filter = getDocumentIdFilter(documentId); localCollection.findOneAndReplace( filter, undoDoc, new FindOneAndReplaceOptions().upsert(true)); recoveredIds.add(documentId); } // If we recovered a document, but its pending writes are set to do something else, then the // failure occurred after the pending writes were set, but before the undo document was // deleted. In this case, we should restore the document to the state that the pending // write indicates. There is a possibility that the pending write is from before the failed // operation, but in that case, the findOneAndReplace or delete is a no-op since restoring // the document to the state of the change event would be the same as recovering the undo // document. for (final CoreDocumentSynchronizationConfig docConfig : nsConfig.getSynchronizedDocuments()) { final BsonValue documentId = docConfig.getDocumentId(); final BsonDocument filter = getDocumentIdFilter(documentId); if (recoveredIds.contains(docConfig.getDocumentId())) { final ChangeEvent<BsonDocument> pendingWrite = docConfig.getLastUncommittedChangeEvent(); if (pendingWrite != null) { switch (pendingWrite.getOperationType()) { case INSERT: case UPDATE: case REPLACE: localCollection.findOneAndReplace( filter, pendingWrite.getFullDocument(), new FindOneAndReplaceOptions().upsert(true) ); break; case DELETE: localCollection.deleteOne(filter); break; default: // There should never be pending writes with an unknown event type, but if someone // is messing with the config collection we want to stop the synchronizer to prevent // further data corruption. throw new IllegalStateException( "there should not be a pending write with an unknown event type" ); } } } } // Delete all of our undo documents. If we've reached this point, we've recovered the local // collection to the state we want with respect to all of our undo documents. If we fail before // these deletes or while carrying out the deletes, but after recovering the documents to // their desired state, that's okay because the next recovery pass will be effectively a no-op // up to this point. for (final BsonValue recoveredId : recoveredIds) { undoCollection.deleteOne(getDocumentIdFilter(recoveredId)); } // Find local documents for which there are no document configs and delete them. This covers // inserts, upserts, and desync deletes. This will occur on any recovery pass regardless of // the documents in the undo collection, so it's fine that we do this after deleting the undo // documents. localCollection.deleteMany(new BsonDocument( "_id", new BsonDocument( "$nin", new BsonArray(new ArrayList<>( this.syncConfig.getSynchronizedDocumentIds(nsConfig.getNamespace())))))); }
[ "private", "void", "recoverNamespace", "(", "final", "NamespaceSynchronizationConfig", "nsConfig", ")", "{", "final", "MongoCollection", "<", "BsonDocument", ">", "undoCollection", "=", "getUndoCollection", "(", "nsConfig", ".", "getNamespace", "(", ")", ")", ";", "final", "MongoCollection", "<", "BsonDocument", ">", "localCollection", "=", "getLocalCollection", "(", "nsConfig", ".", "getNamespace", "(", ")", ")", ";", "final", "List", "<", "BsonDocument", ">", "undoDocs", "=", "undoCollection", ".", "find", "(", ")", ".", "into", "(", "new", "ArrayList", "<>", "(", ")", ")", ";", "final", "Set", "<", "BsonValue", ">", "recoveredIds", "=", "new", "HashSet", "<>", "(", ")", ";", "// Replace local docs with undo docs. Presence of an undo doc implies we had a system failure", "// during a write. This covers updates and deletes.", "for", "(", "final", "BsonDocument", "undoDoc", ":", "undoDocs", ")", "{", "final", "BsonValue", "documentId", "=", "BsonUtils", ".", "getDocumentId", "(", "undoDoc", ")", ";", "final", "BsonDocument", "filter", "=", "getDocumentIdFilter", "(", "documentId", ")", ";", "localCollection", ".", "findOneAndReplace", "(", "filter", ",", "undoDoc", ",", "new", "FindOneAndReplaceOptions", "(", ")", ".", "upsert", "(", "true", ")", ")", ";", "recoveredIds", ".", "add", "(", "documentId", ")", ";", "}", "// If we recovered a document, but its pending writes are set to do something else, then the", "// failure occurred after the pending writes were set, but before the undo document was", "// deleted. In this case, we should restore the document to the state that the pending", "// write indicates. There is a possibility that the pending write is from before the failed", "// operation, but in that case, the findOneAndReplace or delete is a no-op since restoring", "// the document to the state of the change event would be the same as recovering the undo", "// document.", "for", "(", "final", "CoreDocumentSynchronizationConfig", "docConfig", ":", "nsConfig", ".", "getSynchronizedDocuments", "(", ")", ")", "{", "final", "BsonValue", "documentId", "=", "docConfig", ".", "getDocumentId", "(", ")", ";", "final", "BsonDocument", "filter", "=", "getDocumentIdFilter", "(", "documentId", ")", ";", "if", "(", "recoveredIds", ".", "contains", "(", "docConfig", ".", "getDocumentId", "(", ")", ")", ")", "{", "final", "ChangeEvent", "<", "BsonDocument", ">", "pendingWrite", "=", "docConfig", ".", "getLastUncommittedChangeEvent", "(", ")", ";", "if", "(", "pendingWrite", "!=", "null", ")", "{", "switch", "(", "pendingWrite", ".", "getOperationType", "(", ")", ")", "{", "case", "INSERT", ":", "case", "UPDATE", ":", "case", "REPLACE", ":", "localCollection", ".", "findOneAndReplace", "(", "filter", ",", "pendingWrite", ".", "getFullDocument", "(", ")", ",", "new", "FindOneAndReplaceOptions", "(", ")", ".", "upsert", "(", "true", ")", ")", ";", "break", ";", "case", "DELETE", ":", "localCollection", ".", "deleteOne", "(", "filter", ")", ";", "break", ";", "default", ":", "// There should never be pending writes with an unknown event type, but if someone", "// is messing with the config collection we want to stop the synchronizer to prevent", "// further data corruption.", "throw", "new", "IllegalStateException", "(", "\"there should not be a pending write with an unknown event type\"", ")", ";", "}", "}", "}", "}", "// Delete all of our undo documents. If we've reached this point, we've recovered the local", "// collection to the state we want with respect to all of our undo documents. If we fail before", "// these deletes or while carrying out the deletes, but after recovering the documents to", "// their desired state, that's okay because the next recovery pass will be effectively a no-op", "// up to this point.", "for", "(", "final", "BsonValue", "recoveredId", ":", "recoveredIds", ")", "{", "undoCollection", ".", "deleteOne", "(", "getDocumentIdFilter", "(", "recoveredId", ")", ")", ";", "}", "// Find local documents for which there are no document configs and delete them. This covers", "// inserts, upserts, and desync deletes. This will occur on any recovery pass regardless of", "// the documents in the undo collection, so it's fine that we do this after deleting the undo", "// documents.", "localCollection", ".", "deleteMany", "(", "new", "BsonDocument", "(", "\"_id\"", ",", "new", "BsonDocument", "(", "\"$nin\"", ",", "new", "BsonArray", "(", "new", "ArrayList", "<>", "(", "this", ".", "syncConfig", ".", "getSynchronizedDocumentIds", "(", "nsConfig", ".", "getNamespace", "(", ")", ")", ")", ")", ")", ")", ")", ";", "}" ]
Recovers the state of synchronization for a namespace in case a system failure happened. The goal is to revert the namespace to a known, good state. This method itself is resilient to failures, since it doesn't delete any documents from the undo collection until the collection is in the desired state with respect to those documents.
[ "Recovers", "the", "state", "of", "synchronization", "for", "a", "namespace", "in", "case", "a", "system", "failure", "happened", ".", "The", "goal", "is", "to", "revert", "the", "namespace", "to", "a", "known", "good", "state", ".", "This", "method", "itself", "is", "resilient", "to", "failures", "since", "it", "doesn", "t", "delete", "any", "documents", "from", "the", "undo", "collection", "until", "the", "collection", "is", "in", "the", "desired", "state", "with", "respect", "to", "those", "documents", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L228-L305
157,921
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.wipeInMemorySettings
public void wipeInMemorySettings() { this.waitUntilInitialized(); syncLock.lock(); try { this.instanceChangeStreamListener.stop(); if (instancesColl.find().first() == null) { throw new IllegalStateException("expected to find instance configuration"); } this.syncConfig = new InstanceSynchronizationConfig(configDb); this.instanceChangeStreamListener = new InstanceChangeStreamListenerImpl( syncConfig, service, networkMonitor, authMonitor ); this.isConfigured = false; this.stop(); } finally { syncLock.unlock(); } }
java
public void wipeInMemorySettings() { this.waitUntilInitialized(); syncLock.lock(); try { this.instanceChangeStreamListener.stop(); if (instancesColl.find().first() == null) { throw new IllegalStateException("expected to find instance configuration"); } this.syncConfig = new InstanceSynchronizationConfig(configDb); this.instanceChangeStreamListener = new InstanceChangeStreamListenerImpl( syncConfig, service, networkMonitor, authMonitor ); this.isConfigured = false; this.stop(); } finally { syncLock.unlock(); } }
[ "public", "void", "wipeInMemorySettings", "(", ")", "{", "this", ".", "waitUntilInitialized", "(", ")", ";", "syncLock", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "instanceChangeStreamListener", ".", "stop", "(", ")", ";", "if", "(", "instancesColl", ".", "find", "(", ")", ".", "first", "(", ")", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"expected to find instance configuration\"", ")", ";", "}", "this", ".", "syncConfig", "=", "new", "InstanceSynchronizationConfig", "(", "configDb", ")", ";", "this", ".", "instanceChangeStreamListener", "=", "new", "InstanceChangeStreamListenerImpl", "(", "syncConfig", ",", "service", ",", "networkMonitor", ",", "authMonitor", ")", ";", "this", ".", "isConfigured", "=", "false", ";", "this", ".", "stop", "(", ")", ";", "}", "finally", "{", "syncLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Reloads the synchronization config. This wipes all in-memory synchronization settings.
[ "Reloads", "the", "synchronization", "config", ".", "This", "wipes", "all", "in", "-", "memory", "synchronization", "settings", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L337-L358
157,922
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.start
public void start() { syncLock.lock(); try { if (!this.isConfigured) { return; } instanceChangeStreamListener.stop(); if (listenersEnabled) { instanceChangeStreamListener.start(); } if (syncThread == null) { syncThread = new Thread( new DataSynchronizerRunner( new WeakReference<>(this), networkMonitor, logger ), "dataSynchronizerRunnerThread" ); } if (syncThreadEnabled && !isRunning) { syncThread.start(); isRunning = true; } } finally { syncLock.unlock(); } }
java
public void start() { syncLock.lock(); try { if (!this.isConfigured) { return; } instanceChangeStreamListener.stop(); if (listenersEnabled) { instanceChangeStreamListener.start(); } if (syncThread == null) { syncThread = new Thread( new DataSynchronizerRunner( new WeakReference<>(this), networkMonitor, logger ), "dataSynchronizerRunnerThread" ); } if (syncThreadEnabled && !isRunning) { syncThread.start(); isRunning = true; } } finally { syncLock.unlock(); } }
[ "public", "void", "start", "(", ")", "{", "syncLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "!", "this", ".", "isConfigured", ")", "{", "return", ";", "}", "instanceChangeStreamListener", ".", "stop", "(", ")", ";", "if", "(", "listenersEnabled", ")", "{", "instanceChangeStreamListener", ".", "start", "(", ")", ";", "}", "if", "(", "syncThread", "==", "null", ")", "{", "syncThread", "=", "new", "Thread", "(", "new", "DataSynchronizerRunner", "(", "new", "WeakReference", "<>", "(", "this", ")", ",", "networkMonitor", ",", "logger", ")", ",", "\"dataSynchronizerRunnerThread\"", ")", ";", "}", "if", "(", "syncThreadEnabled", "&&", "!", "isRunning", ")", "{", "syncThread", ".", "start", "(", ")", ";", "isRunning", "=", "true", ";", "}", "}", "finally", "{", "syncLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Starts data synchronization in a background thread.
[ "Starts", "data", "synchronization", "in", "a", "background", "thread", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L541-L569
157,923
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.stop
public void stop() { syncLock.lock(); try { if (syncThread == null) { return; } instanceChangeStreamListener.stop(); syncThread.interrupt(); try { syncThread.join(); } catch (final InterruptedException e) { return; } syncThread = null; isRunning = false; } finally { syncLock.unlock(); } }
java
public void stop() { syncLock.lock(); try { if (syncThread == null) { return; } instanceChangeStreamListener.stop(); syncThread.interrupt(); try { syncThread.join(); } catch (final InterruptedException e) { return; } syncThread = null; isRunning = false; } finally { syncLock.unlock(); } }
[ "public", "void", "stop", "(", ")", "{", "syncLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "syncThread", "==", "null", ")", "{", "return", ";", "}", "instanceChangeStreamListener", ".", "stop", "(", ")", ";", "syncThread", ".", "interrupt", "(", ")", ";", "try", "{", "syncThread", ".", "join", "(", ")", ";", "}", "catch", "(", "final", "InterruptedException", "e", ")", "{", "return", ";", "}", "syncThread", "=", "null", ";", "isRunning", "=", "false", ";", "}", "finally", "{", "syncLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Stops the background data synchronization thread.
[ "Stops", "the", "background", "data", "synchronization", "thread", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L592-L610
157,924
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.close
public void close() { this.waitUntilInitialized(); this.ongoingOperationsGroup.blockAndWait(); syncLock.lock(); try { if (this.networkMonitor != null) { this.networkMonitor.removeNetworkStateListener(this); } this.dispatcher.close(); stop(); this.localClient.close(); } finally { syncLock.unlock(); } }
java
public void close() { this.waitUntilInitialized(); this.ongoingOperationsGroup.blockAndWait(); syncLock.lock(); try { if (this.networkMonitor != null) { this.networkMonitor.removeNetworkStateListener(this); } this.dispatcher.close(); stop(); this.localClient.close(); } finally { syncLock.unlock(); } }
[ "public", "void", "close", "(", ")", "{", "this", ".", "waitUntilInitialized", "(", ")", ";", "this", ".", "ongoingOperationsGroup", ".", "blockAndWait", "(", ")", ";", "syncLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "this", ".", "networkMonitor", "!=", "null", ")", "{", "this", ".", "networkMonitor", ".", "removeNetworkStateListener", "(", "this", ")", ";", "}", "this", ".", "dispatcher", ".", "close", "(", ")", ";", "stop", "(", ")", ";", "this", ".", "localClient", ".", "close", "(", ")", ";", "}", "finally", "{", "syncLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Stops the background data synchronization thread and releases the local client.
[ "Stops", "the", "background", "data", "synchronization", "thread", "and", "releases", "the", "local", "client", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L615-L631
157,925
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.doSyncPass
public boolean doSyncPass() { if (!this.isConfigured || !syncLock.tryLock()) { return false; } try { if (logicalT == Long.MAX_VALUE) { if (logger.isInfoEnabled()) { logger.info("reached max logical time; resetting back to 0"); } logicalT = 0; } logicalT++; if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass START", logicalT)); } if (networkMonitor == null || !networkMonitor.isConnected()) { if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass END - Network disconnected", logicalT)); } return false; } if (authMonitor == null || !authMonitor.tryIsLoggedIn()) { if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass END - Logged out", logicalT)); } return false; } syncRemoteToLocal(); syncLocalToRemote(); if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass END", logicalT)); } } catch (InterruptedException e) { if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass INTERRUPTED", logicalT)); } return false; } finally { syncLock.unlock(); } return true; }
java
public boolean doSyncPass() { if (!this.isConfigured || !syncLock.tryLock()) { return false; } try { if (logicalT == Long.MAX_VALUE) { if (logger.isInfoEnabled()) { logger.info("reached max logical time; resetting back to 0"); } logicalT = 0; } logicalT++; if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass START", logicalT)); } if (networkMonitor == null || !networkMonitor.isConnected()) { if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass END - Network disconnected", logicalT)); } return false; } if (authMonitor == null || !authMonitor.tryIsLoggedIn()) { if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass END - Logged out", logicalT)); } return false; } syncRemoteToLocal(); syncLocalToRemote(); if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass END", logicalT)); } } catch (InterruptedException e) { if (logger.isInfoEnabled()) { logger.info(String.format( Locale.US, "t='%d': doSyncPass INTERRUPTED", logicalT)); } return false; } finally { syncLock.unlock(); } return true; }
[ "public", "boolean", "doSyncPass", "(", ")", "{", "if", "(", "!", "this", ".", "isConfigured", "||", "!", "syncLock", ".", "tryLock", "(", ")", ")", "{", "return", "false", ";", "}", "try", "{", "if", "(", "logicalT", "==", "Long", ".", "MAX_VALUE", ")", "{", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "\"reached max logical time; resetting back to 0\"", ")", ";", "}", "logicalT", "=", "0", ";", "}", "logicalT", "++", ";", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "String", ".", "format", "(", "Locale", ".", "US", ",", "\"t='%d': doSyncPass START\"", ",", "logicalT", ")", ")", ";", "}", "if", "(", "networkMonitor", "==", "null", "||", "!", "networkMonitor", ".", "isConnected", "(", ")", ")", "{", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "String", ".", "format", "(", "Locale", ".", "US", ",", "\"t='%d': doSyncPass END - Network disconnected\"", ",", "logicalT", ")", ")", ";", "}", "return", "false", ";", "}", "if", "(", "authMonitor", "==", "null", "||", "!", "authMonitor", ".", "tryIsLoggedIn", "(", ")", ")", "{", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "String", ".", "format", "(", "Locale", ".", "US", ",", "\"t='%d': doSyncPass END - Logged out\"", ",", "logicalT", ")", ")", ";", "}", "return", "false", ";", "}", "syncRemoteToLocal", "(", ")", ";", "syncLocalToRemote", "(", ")", ";", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "String", ".", "format", "(", "Locale", ".", "US", ",", "\"t='%d': doSyncPass END\"", ",", "logicalT", ")", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "String", ".", "format", "(", "Locale", ".", "US", ",", "\"t='%d': doSyncPass INTERRUPTED\"", ",", "logicalT", ")", ")", ";", "}", "return", "false", ";", "}", "finally", "{", "syncLock", ".", "unlock", "(", ")", ";", "}", "return", "true", ";", "}" ]
Performs a single synchronization pass in both the local and remote directions; the order of which does not matter. If switching the order produces different results after one pass, then there is a bug. @return whether or not the synchronization pass was successful.
[ "Performs", "a", "single", "synchronization", "pass", "in", "both", "the", "local", "and", "remote", "directions", ";", "the", "order", "of", "which", "does", "not", "matter", ".", "If", "switching", "the", "order", "produces", "different", "results", "after", "one", "pass", "then", "there", "is", "a", "bug", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L642-L701
157,926
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.resolveConflict
@CheckReturnValue private LocalSyncWriteModelContainer resolveConflict( final NamespaceSynchronizationConfig nsConfig, final CoreDocumentSynchronizationConfig docConfig, final ChangeEvent<BsonDocument> remoteEvent ) { return resolveConflict(nsConfig, docConfig, docConfig.getLastUncommittedChangeEvent(), remoteEvent); }
java
@CheckReturnValue private LocalSyncWriteModelContainer resolveConflict( final NamespaceSynchronizationConfig nsConfig, final CoreDocumentSynchronizationConfig docConfig, final ChangeEvent<BsonDocument> remoteEvent ) { return resolveConflict(nsConfig, docConfig, docConfig.getLastUncommittedChangeEvent(), remoteEvent); }
[ "@", "CheckReturnValue", "private", "LocalSyncWriteModelContainer", "resolveConflict", "(", "final", "NamespaceSynchronizationConfig", "nsConfig", ",", "final", "CoreDocumentSynchronizationConfig", "docConfig", ",", "final", "ChangeEvent", "<", "BsonDocument", ">", "remoteEvent", ")", "{", "return", "resolveConflict", "(", "nsConfig", ",", "docConfig", ",", "docConfig", ".", "getLastUncommittedChangeEvent", "(", ")", ",", "remoteEvent", ")", ";", "}" ]
Resolves a conflict between a synchronized document's local and remote state. The resolution will result in either the document being desynchronized or being replaced with some resolved state based on the conflict resolver specified for the document. Uses the last uncommitted local event as the local state. @param nsConfig the namespace synchronization config of the namespace where the document lives. @param docConfig the configuration of the document that describes the resolver and current state. @param remoteEvent the remote change event that is conflicting.
[ "Resolves", "a", "conflict", "between", "a", "synchronized", "document", "s", "local", "and", "remote", "state", ".", "The", "resolution", "will", "result", "in", "either", "the", "document", "being", "desynchronized", "or", "being", "replaced", "with", "some", "resolved", "state", "based", "on", "the", "conflict", "resolver", "specified", "for", "the", "document", ".", "Uses", "the", "last", "uncommitted", "local", "event", "as", "the", "local", "state", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L1681-L1689
157,927
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.resolveConflictWithResolver
@SuppressWarnings("unchecked") private static Object resolveConflictWithResolver( final ConflictHandler conflictResolver, final BsonValue documentId, final ChangeEvent localEvent, final ChangeEvent remoteEvent ) { return conflictResolver.resolveConflict( documentId, localEvent, remoteEvent); }
java
@SuppressWarnings("unchecked") private static Object resolveConflictWithResolver( final ConflictHandler conflictResolver, final BsonValue documentId, final ChangeEvent localEvent, final ChangeEvent remoteEvent ) { return conflictResolver.resolveConflict( documentId, localEvent, remoteEvent); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "Object", "resolveConflictWithResolver", "(", "final", "ConflictHandler", "conflictResolver", ",", "final", "BsonValue", "documentId", ",", "final", "ChangeEvent", "localEvent", ",", "final", "ChangeEvent", "remoteEvent", ")", "{", "return", "conflictResolver", ".", "resolveConflict", "(", "documentId", ",", "localEvent", ",", "remoteEvent", ")", ";", "}" ]
Returns the resolution of resolving the conflict between a local and remote event using the given conflict resolver. @param conflictResolver the conflict resolver to use. @param documentId the document id related to the conflicted events. @param localEvent the conflicted local event. @param remoteEvent the conflicted remote event. @return the resolution to the conflict.
[ "Returns", "the", "resolution", "of", "resolving", "the", "conflict", "between", "a", "local", "and", "remote", "event", "using", "the", "given", "conflict", "resolver", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L1853-L1864
157,928
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.addWatcher
public void addWatcher(final MongoNamespace namespace, final Callback<ChangeEvent<BsonDocument>, Object> watcher) { instanceChangeStreamListener.addWatcher(namespace, watcher); }
java
public void addWatcher(final MongoNamespace namespace, final Callback<ChangeEvent<BsonDocument>, Object> watcher) { instanceChangeStreamListener.addWatcher(namespace, watcher); }
[ "public", "void", "addWatcher", "(", "final", "MongoNamespace", "namespace", ",", "final", "Callback", "<", "ChangeEvent", "<", "BsonDocument", ">", ",", "Object", ">", "watcher", ")", "{", "instanceChangeStreamListener", ".", "addWatcher", "(", "namespace", ",", "watcher", ")", ";", "}" ]
Queues up a callback to be removed and invoked on the next change event.
[ "Queues", "up", "a", "callback", "to", "be", "removed", "and", "invoked", "on", "the", "next", "change", "event", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L1907-L1910
157,929
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.getSynchronizedDocuments
public Set<CoreDocumentSynchronizationConfig> getSynchronizedDocuments( final MongoNamespace namespace ) { this.waitUntilInitialized(); try { ongoingOperationsGroup.enter(); return this.syncConfig.getSynchronizedDocuments(namespace); } finally { ongoingOperationsGroup.exit(); } }
java
public Set<CoreDocumentSynchronizationConfig> getSynchronizedDocuments( final MongoNamespace namespace ) { this.waitUntilInitialized(); try { ongoingOperationsGroup.enter(); return this.syncConfig.getSynchronizedDocuments(namespace); } finally { ongoingOperationsGroup.exit(); } }
[ "public", "Set", "<", "CoreDocumentSynchronizationConfig", ">", "getSynchronizedDocuments", "(", "final", "MongoNamespace", "namespace", ")", "{", "this", ".", "waitUntilInitialized", "(", ")", ";", "try", "{", "ongoingOperationsGroup", ".", "enter", "(", ")", ";", "return", "this", ".", "syncConfig", ".", "getSynchronizedDocuments", "(", "namespace", ")", ";", "}", "finally", "{", "ongoingOperationsGroup", ".", "exit", "(", ")", ";", "}", "}" ]
Returns the set of synchronized documents in a namespace. @param namespace the namespace to get synchronized documents for. @return the set of synchronized documents in a namespace.
[ "Returns", "the", "set", "of", "synchronized", "documents", "in", "a", "namespace", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L1944-L1954
157,930
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.getPausedDocumentIds
public Set<BsonValue> getPausedDocumentIds(final MongoNamespace namespace) { this.waitUntilInitialized(); try { ongoingOperationsGroup.enter(); final Set<BsonValue> pausedDocumentIds = new HashSet<>(); for (final CoreDocumentSynchronizationConfig config : this.syncConfig.getSynchronizedDocuments(namespace)) { if (config.isPaused()) { pausedDocumentIds.add(config.getDocumentId()); } } return pausedDocumentIds; } finally { ongoingOperationsGroup.exit(); } }
java
public Set<BsonValue> getPausedDocumentIds(final MongoNamespace namespace) { this.waitUntilInitialized(); try { ongoingOperationsGroup.enter(); final Set<BsonValue> pausedDocumentIds = new HashSet<>(); for (final CoreDocumentSynchronizationConfig config : this.syncConfig.getSynchronizedDocuments(namespace)) { if (config.isPaused()) { pausedDocumentIds.add(config.getDocumentId()); } } return pausedDocumentIds; } finally { ongoingOperationsGroup.exit(); } }
[ "public", "Set", "<", "BsonValue", ">", "getPausedDocumentIds", "(", "final", "MongoNamespace", "namespace", ")", "{", "this", ".", "waitUntilInitialized", "(", ")", ";", "try", "{", "ongoingOperationsGroup", ".", "enter", "(", ")", ";", "final", "Set", "<", "BsonValue", ">", "pausedDocumentIds", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "final", "CoreDocumentSynchronizationConfig", "config", ":", "this", ".", "syncConfig", ".", "getSynchronizedDocuments", "(", "namespace", ")", ")", "{", "if", "(", "config", ".", "isPaused", "(", ")", ")", "{", "pausedDocumentIds", ".", "add", "(", "config", ".", "getDocumentId", "(", ")", ")", ";", "}", "}", "return", "pausedDocumentIds", ";", "}", "finally", "{", "ongoingOperationsGroup", ".", "exit", "(", ")", ";", "}", "}" ]
Return the set of synchronized document _ids in a namespace that have been paused due to an irrecoverable error. @param namespace the namespace to get paused document _ids for. @return the set of paused document _ids in a namespace
[ "Return", "the", "set", "of", "synchronized", "document", "_ids", "in", "a", "namespace", "that", "have", "been", "paused", "due", "to", "an", "irrecoverable", "error", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L1979-L1997
157,931
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.resumeSyncForDocument
boolean resumeSyncForDocument( final MongoNamespace namespace, final BsonValue documentId ) { if (namespace == null || documentId == null) { return false; } final NamespaceSynchronizationConfig namespaceSynchronizationConfig; final CoreDocumentSynchronizationConfig config; if ((namespaceSynchronizationConfig = syncConfig.getNamespaceConfig(namespace)) == null || (config = namespaceSynchronizationConfig.getSynchronizedDocument(documentId)) == null) { return false; } config.setPaused(false); return !config.isPaused(); }
java
boolean resumeSyncForDocument( final MongoNamespace namespace, final BsonValue documentId ) { if (namespace == null || documentId == null) { return false; } final NamespaceSynchronizationConfig namespaceSynchronizationConfig; final CoreDocumentSynchronizationConfig config; if ((namespaceSynchronizationConfig = syncConfig.getNamespaceConfig(namespace)) == null || (config = namespaceSynchronizationConfig.getSynchronizedDocument(documentId)) == null) { return false; } config.setPaused(false); return !config.isPaused(); }
[ "boolean", "resumeSyncForDocument", "(", "final", "MongoNamespace", "namespace", ",", "final", "BsonValue", "documentId", ")", "{", "if", "(", "namespace", "==", "null", "||", "documentId", "==", "null", ")", "{", "return", "false", ";", "}", "final", "NamespaceSynchronizationConfig", "namespaceSynchronizationConfig", ";", "final", "CoreDocumentSynchronizationConfig", "config", ";", "if", "(", "(", "namespaceSynchronizationConfig", "=", "syncConfig", ".", "getNamespaceConfig", "(", "namespace", ")", ")", "==", "null", "||", "(", "config", "=", "namespaceSynchronizationConfig", ".", "getSynchronizedDocument", "(", "documentId", ")", ")", "==", "null", ")", "{", "return", "false", ";", "}", "config", ".", "setPaused", "(", "false", ")", ";", "return", "!", "config", ".", "isPaused", "(", ")", ";", "}" ]
A document that is paused no longer has remote updates applied to it. Any local updates to this document cause it to be resumed. An example of pausing a document is when a conflict is being resolved for that document and the handler throws an exception. This method allows you to resume sync for a document. @param namespace namespace for the document @param documentId the id of the document to resume syncing @return true if successfully resumed, false if the document could not be found or there was an error resuming
[ "A", "document", "that", "is", "paused", "no", "longer", "has", "remote", "updates", "applied", "to", "it", ".", "Any", "local", "updates", "to", "this", "document", "cause", "it", "to", "be", "resumed", ".", "An", "example", "of", "pausing", "a", "document", "is", "when", "a", "conflict", "is", "being", "resolved", "for", "that", "document", "and", "the", "handler", "throws", "an", "exception", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L2083-L2101
157,932
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.insertOne
void insertOne(final MongoNamespace namespace, final BsonDocument document) { this.waitUntilInitialized(); try { ongoingOperationsGroup.enter(); // Remove forbidden fields from the document before inserting it into the local collection. final BsonDocument docForStorage = sanitizeDocument(document); final NamespaceSynchronizationConfig nsConfig = this.syncConfig.getNamespaceConfig(namespace); final Lock lock = nsConfig.getLock().writeLock(); lock.lock(); final ChangeEvent<BsonDocument> event; final BsonValue documentId; try { getLocalCollection(namespace).insertOne(docForStorage); documentId = BsonUtils.getDocumentId(docForStorage); event = ChangeEvents.changeEventForLocalInsert(namespace, docForStorage, true); final CoreDocumentSynchronizationConfig config = syncConfig.addAndGetSynchronizedDocument( namespace, documentId ); config.setSomePendingWritesAndSave(logicalT, event); } finally { lock.unlock(); } checkAndInsertNamespaceListener(namespace); eventDispatcher.emitEvent(nsConfig, event); } finally { ongoingOperationsGroup.exit(); } }
java
void insertOne(final MongoNamespace namespace, final BsonDocument document) { this.waitUntilInitialized(); try { ongoingOperationsGroup.enter(); // Remove forbidden fields from the document before inserting it into the local collection. final BsonDocument docForStorage = sanitizeDocument(document); final NamespaceSynchronizationConfig nsConfig = this.syncConfig.getNamespaceConfig(namespace); final Lock lock = nsConfig.getLock().writeLock(); lock.lock(); final ChangeEvent<BsonDocument> event; final BsonValue documentId; try { getLocalCollection(namespace).insertOne(docForStorage); documentId = BsonUtils.getDocumentId(docForStorage); event = ChangeEvents.changeEventForLocalInsert(namespace, docForStorage, true); final CoreDocumentSynchronizationConfig config = syncConfig.addAndGetSynchronizedDocument( namespace, documentId ); config.setSomePendingWritesAndSave(logicalT, event); } finally { lock.unlock(); } checkAndInsertNamespaceListener(namespace); eventDispatcher.emitEvent(nsConfig, event); } finally { ongoingOperationsGroup.exit(); } }
[ "void", "insertOne", "(", "final", "MongoNamespace", "namespace", ",", "final", "BsonDocument", "document", ")", "{", "this", ".", "waitUntilInitialized", "(", ")", ";", "try", "{", "ongoingOperationsGroup", ".", "enter", "(", ")", ";", "// Remove forbidden fields from the document before inserting it into the local collection.", "final", "BsonDocument", "docForStorage", "=", "sanitizeDocument", "(", "document", ")", ";", "final", "NamespaceSynchronizationConfig", "nsConfig", "=", "this", ".", "syncConfig", ".", "getNamespaceConfig", "(", "namespace", ")", ";", "final", "Lock", "lock", "=", "nsConfig", ".", "getLock", "(", ")", ".", "writeLock", "(", ")", ";", "lock", ".", "lock", "(", ")", ";", "final", "ChangeEvent", "<", "BsonDocument", ">", "event", ";", "final", "BsonValue", "documentId", ";", "try", "{", "getLocalCollection", "(", "namespace", ")", ".", "insertOne", "(", "docForStorage", ")", ";", "documentId", "=", "BsonUtils", ".", "getDocumentId", "(", "docForStorage", ")", ";", "event", "=", "ChangeEvents", ".", "changeEventForLocalInsert", "(", "namespace", ",", "docForStorage", ",", "true", ")", ";", "final", "CoreDocumentSynchronizationConfig", "config", "=", "syncConfig", ".", "addAndGetSynchronizedDocument", "(", "namespace", ",", "documentId", ")", ";", "config", ".", "setSomePendingWritesAndSave", "(", "logicalT", ",", "event", ")", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "checkAndInsertNamespaceListener", "(", "namespace", ")", ";", "eventDispatcher", ".", "emitEvent", "(", "nsConfig", ",", "event", ")", ";", "}", "finally", "{", "ongoingOperationsGroup", ".", "exit", "(", ")", ";", "}", "}" ]
Inserts a single document locally and being to synchronize it based on its _id. Inserting a document with the same _id twice will result in a duplicate key exception. @param namespace the namespace to put the document in. @param document the document to insert.
[ "Inserts", "a", "single", "document", "locally", "and", "being", "to", "synchronize", "it", "based", "on", "its", "_id", ".", "Inserting", "a", "document", "with", "the", "same", "_id", "twice", "will", "result", "in", "a", "duplicate", "key", "exception", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L2247-L2278
157,933
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.deleteMany
DeleteResult deleteMany(final MongoNamespace namespace, final Bson filter) { this.waitUntilInitialized(); try { ongoingOperationsGroup.enter(); final List<ChangeEvent<BsonDocument>> eventsToEmit = new ArrayList<>(); final DeleteResult result; final NamespaceSynchronizationConfig nsConfig = this.syncConfig.getNamespaceConfig(namespace); final Lock lock = nsConfig.getLock().writeLock(); lock.lock(); try { final MongoCollection<BsonDocument> localCollection = getLocalCollection(namespace); final MongoCollection<BsonDocument> undoCollection = getUndoCollection(namespace); final Set<BsonValue> idsToDelete = localCollection .find(filter) .map(new Function<BsonDocument, BsonValue>() { @Override @NonNull public BsonValue apply(@NonNull final BsonDocument bsonDocument) { undoCollection.insertOne(bsonDocument); return BsonUtils.getDocumentId(bsonDocument); } }).into(new HashSet<>()); result = localCollection.deleteMany(filter); for (final BsonValue documentId : idsToDelete) { final CoreDocumentSynchronizationConfig config = syncConfig.getSynchronizedDocument(namespace, documentId); if (config == null) { continue; } final ChangeEvent<BsonDocument> event = ChangeEvents.changeEventForLocalDelete(namespace, documentId, true); // this block is to trigger coalescence for a delete after insert if (config.getLastUncommittedChangeEvent() != null && config.getLastUncommittedChangeEvent().getOperationType() == OperationType.INSERT) { desyncDocumentsFromRemote(nsConfig, config.getDocumentId()) .commitAndClear(); undoCollection.deleteOne(getDocumentIdFilter(documentId)); continue; } config.setSomePendingWritesAndSave(logicalT, event); undoCollection.deleteOne(getDocumentIdFilter(documentId)); eventsToEmit.add(event); } checkAndDeleteNamespaceListener(namespace); } finally { lock.unlock(); } for (final ChangeEvent<BsonDocument> event : eventsToEmit) { eventDispatcher.emitEvent(nsConfig, event); } return result; } finally { ongoingOperationsGroup.exit(); } }
java
DeleteResult deleteMany(final MongoNamespace namespace, final Bson filter) { this.waitUntilInitialized(); try { ongoingOperationsGroup.enter(); final List<ChangeEvent<BsonDocument>> eventsToEmit = new ArrayList<>(); final DeleteResult result; final NamespaceSynchronizationConfig nsConfig = this.syncConfig.getNamespaceConfig(namespace); final Lock lock = nsConfig.getLock().writeLock(); lock.lock(); try { final MongoCollection<BsonDocument> localCollection = getLocalCollection(namespace); final MongoCollection<BsonDocument> undoCollection = getUndoCollection(namespace); final Set<BsonValue> idsToDelete = localCollection .find(filter) .map(new Function<BsonDocument, BsonValue>() { @Override @NonNull public BsonValue apply(@NonNull final BsonDocument bsonDocument) { undoCollection.insertOne(bsonDocument); return BsonUtils.getDocumentId(bsonDocument); } }).into(new HashSet<>()); result = localCollection.deleteMany(filter); for (final BsonValue documentId : idsToDelete) { final CoreDocumentSynchronizationConfig config = syncConfig.getSynchronizedDocument(namespace, documentId); if (config == null) { continue; } final ChangeEvent<BsonDocument> event = ChangeEvents.changeEventForLocalDelete(namespace, documentId, true); // this block is to trigger coalescence for a delete after insert if (config.getLastUncommittedChangeEvent() != null && config.getLastUncommittedChangeEvent().getOperationType() == OperationType.INSERT) { desyncDocumentsFromRemote(nsConfig, config.getDocumentId()) .commitAndClear(); undoCollection.deleteOne(getDocumentIdFilter(documentId)); continue; } config.setSomePendingWritesAndSave(logicalT, event); undoCollection.deleteOne(getDocumentIdFilter(documentId)); eventsToEmit.add(event); } checkAndDeleteNamespaceListener(namespace); } finally { lock.unlock(); } for (final ChangeEvent<BsonDocument> event : eventsToEmit) { eventDispatcher.emitEvent(nsConfig, event); } return result; } finally { ongoingOperationsGroup.exit(); } }
[ "DeleteResult", "deleteMany", "(", "final", "MongoNamespace", "namespace", ",", "final", "Bson", "filter", ")", "{", "this", ".", "waitUntilInitialized", "(", ")", ";", "try", "{", "ongoingOperationsGroup", ".", "enter", "(", ")", ";", "final", "List", "<", "ChangeEvent", "<", "BsonDocument", ">", ">", "eventsToEmit", "=", "new", "ArrayList", "<>", "(", ")", ";", "final", "DeleteResult", "result", ";", "final", "NamespaceSynchronizationConfig", "nsConfig", "=", "this", ".", "syncConfig", ".", "getNamespaceConfig", "(", "namespace", ")", ";", "final", "Lock", "lock", "=", "nsConfig", ".", "getLock", "(", ")", ".", "writeLock", "(", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "final", "MongoCollection", "<", "BsonDocument", ">", "localCollection", "=", "getLocalCollection", "(", "namespace", ")", ";", "final", "MongoCollection", "<", "BsonDocument", ">", "undoCollection", "=", "getUndoCollection", "(", "namespace", ")", ";", "final", "Set", "<", "BsonValue", ">", "idsToDelete", "=", "localCollection", ".", "find", "(", "filter", ")", ".", "map", "(", "new", "Function", "<", "BsonDocument", ",", "BsonValue", ">", "(", ")", "{", "@", "Override", "@", "NonNull", "public", "BsonValue", "apply", "(", "@", "NonNull", "final", "BsonDocument", "bsonDocument", ")", "{", "undoCollection", ".", "insertOne", "(", "bsonDocument", ")", ";", "return", "BsonUtils", ".", "getDocumentId", "(", "bsonDocument", ")", ";", "}", "}", ")", ".", "into", "(", "new", "HashSet", "<>", "(", ")", ")", ";", "result", "=", "localCollection", ".", "deleteMany", "(", "filter", ")", ";", "for", "(", "final", "BsonValue", "documentId", ":", "idsToDelete", ")", "{", "final", "CoreDocumentSynchronizationConfig", "config", "=", "syncConfig", ".", "getSynchronizedDocument", "(", "namespace", ",", "documentId", ")", ";", "if", "(", "config", "==", "null", ")", "{", "continue", ";", "}", "final", "ChangeEvent", "<", "BsonDocument", ">", "event", "=", "ChangeEvents", ".", "changeEventForLocalDelete", "(", "namespace", ",", "documentId", ",", "true", ")", ";", "// this block is to trigger coalescence for a delete after insert", "if", "(", "config", ".", "getLastUncommittedChangeEvent", "(", ")", "!=", "null", "&&", "config", ".", "getLastUncommittedChangeEvent", "(", ")", ".", "getOperationType", "(", ")", "==", "OperationType", ".", "INSERT", ")", "{", "desyncDocumentsFromRemote", "(", "nsConfig", ",", "config", ".", "getDocumentId", "(", ")", ")", ".", "commitAndClear", "(", ")", ";", "undoCollection", ".", "deleteOne", "(", "getDocumentIdFilter", "(", "documentId", ")", ")", ";", "continue", ";", "}", "config", ".", "setSomePendingWritesAndSave", "(", "logicalT", ",", "event", ")", ";", "undoCollection", ".", "deleteOne", "(", "getDocumentIdFilter", "(", "documentId", ")", ")", ";", "eventsToEmit", ".", "add", "(", "event", ")", ";", "}", "checkAndDeleteNamespaceListener", "(", "namespace", ")", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "for", "(", "final", "ChangeEvent", "<", "BsonDocument", ">", "event", ":", "eventsToEmit", ")", "{", "eventDispatcher", ".", "emitEvent", "(", "nsConfig", ",", "event", ")", ";", "}", "return", "result", ";", "}", "finally", "{", "ongoingOperationsGroup", ".", "exit", "(", ")", ";", "}", "}" ]
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified. @param filter the query filter to apply the the delete operation @return the result of the remove many operation
[ "Removes", "all", "documents", "from", "the", "collection", "that", "match", "the", "given", "query", "filter", ".", "If", "no", "documents", "match", "the", "collection", "is", "not", "modified", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L2782-L2846
157,934
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.getUndoCollection
MongoCollection<BsonDocument> getUndoCollection(final MongoNamespace namespace) { return localClient .getDatabase(String.format("sync_undo_%s", namespace.getDatabaseName())) .getCollection(namespace.getCollectionName(), BsonDocument.class) .withCodecRegistry(MongoClientSettings.getDefaultCodecRegistry()); }
java
MongoCollection<BsonDocument> getUndoCollection(final MongoNamespace namespace) { return localClient .getDatabase(String.format("sync_undo_%s", namespace.getDatabaseName())) .getCollection(namespace.getCollectionName(), BsonDocument.class) .withCodecRegistry(MongoClientSettings.getDefaultCodecRegistry()); }
[ "MongoCollection", "<", "BsonDocument", ">", "getUndoCollection", "(", "final", "MongoNamespace", "namespace", ")", "{", "return", "localClient", ".", "getDatabase", "(", "String", ".", "format", "(", "\"sync_undo_%s\"", ",", "namespace", ".", "getDatabaseName", "(", ")", ")", ")", ".", "getCollection", "(", "namespace", ".", "getCollectionName", "(", ")", ",", "BsonDocument", ".", "class", ")", ".", "withCodecRegistry", "(", "MongoClientSettings", ".", "getDefaultCodecRegistry", "(", ")", ")", ";", "}" ]
Returns the undo collection representing the given namespace for recording documents that may need to be reverted after a system failure. @param namespace the namespace referring to the undo collection. @return the undo collection representing the given namespace for recording documents that may need to be reverted after a system failure.
[ "Returns", "the", "undo", "collection", "representing", "the", "given", "namespace", "for", "recording", "documents", "that", "may", "need", "to", "be", "reverted", "after", "a", "system", "failure", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L3022-L3027
157,935
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.getLocalCollection
private <T> MongoCollection<T> getLocalCollection( final MongoNamespace namespace, final Class<T> resultClass, final CodecRegistry codecRegistry ) { return localClient .getDatabase(String.format("sync_user_%s", namespace.getDatabaseName())) .getCollection(namespace.getCollectionName(), resultClass) .withCodecRegistry(codecRegistry); }
java
private <T> MongoCollection<T> getLocalCollection( final MongoNamespace namespace, final Class<T> resultClass, final CodecRegistry codecRegistry ) { return localClient .getDatabase(String.format("sync_user_%s", namespace.getDatabaseName())) .getCollection(namespace.getCollectionName(), resultClass) .withCodecRegistry(codecRegistry); }
[ "private", "<", "T", ">", "MongoCollection", "<", "T", ">", "getLocalCollection", "(", "final", "MongoNamespace", "namespace", ",", "final", "Class", "<", "T", ">", "resultClass", ",", "final", "CodecRegistry", "codecRegistry", ")", "{", "return", "localClient", ".", "getDatabase", "(", "String", ".", "format", "(", "\"sync_user_%s\"", ",", "namespace", ".", "getDatabaseName", "(", ")", ")", ")", ".", "getCollection", "(", "namespace", ".", "getCollectionName", "(", ")", ",", "resultClass", ")", ".", "withCodecRegistry", "(", "codecRegistry", ")", ";", "}" ]
Returns the local collection representing the given namespace. @param namespace the namespace referring to the local collection. @param resultClass the {@link Class} that represents documents in the collection. @param <T> the type documents in the collection. @return the local collection representing the given namespace.
[ "Returns", "the", "local", "collection", "representing", "the", "given", "namespace", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L3037-L3046
157,936
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.getLocalCollection
MongoCollection<BsonDocument> getLocalCollection(final MongoNamespace namespace) { return getLocalCollection( namespace, BsonDocument.class, MongoClientSettings.getDefaultCodecRegistry()); }
java
MongoCollection<BsonDocument> getLocalCollection(final MongoNamespace namespace) { return getLocalCollection( namespace, BsonDocument.class, MongoClientSettings.getDefaultCodecRegistry()); }
[ "MongoCollection", "<", "BsonDocument", ">", "getLocalCollection", "(", "final", "MongoNamespace", "namespace", ")", "{", "return", "getLocalCollection", "(", "namespace", ",", "BsonDocument", ".", "class", ",", "MongoClientSettings", ".", "getDefaultCodecRegistry", "(", ")", ")", ";", "}" ]
Returns the local collection representing the given namespace for raw document operations. @param namespace the namespace referring to the local collection. @return the local collection representing the given namespace for raw document operations.
[ "Returns", "the", "local", "collection", "representing", "the", "given", "namespace", "for", "raw", "document", "operations", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L3054-L3059
157,937
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.getRemoteCollection
private <T> CoreRemoteMongoCollection<T> getRemoteCollection( final MongoNamespace namespace, final Class<T> resultClass ) { return remoteClient .getDatabase(namespace.getDatabaseName()) .getCollection(namespace.getCollectionName(), resultClass); }
java
private <T> CoreRemoteMongoCollection<T> getRemoteCollection( final MongoNamespace namespace, final Class<T> resultClass ) { return remoteClient .getDatabase(namespace.getDatabaseName()) .getCollection(namespace.getCollectionName(), resultClass); }
[ "private", "<", "T", ">", "CoreRemoteMongoCollection", "<", "T", ">", "getRemoteCollection", "(", "final", "MongoNamespace", "namespace", ",", "final", "Class", "<", "T", ">", "resultClass", ")", "{", "return", "remoteClient", ".", "getDatabase", "(", "namespace", ".", "getDatabaseName", "(", ")", ")", ".", "getCollection", "(", "namespace", ".", "getCollectionName", "(", ")", ",", "resultClass", ")", ";", "}" ]
Returns the remote collection representing the given namespace. @param namespace the namespace referring to the remote collection. @param resultClass the {@link Class} that represents documents in the collection. @param <T> the type documents in the collection. @return the remote collection representing the given namespace.
[ "Returns", "the", "remote", "collection", "representing", "the", "given", "namespace", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L3069-L3076
157,938
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.sanitizeDocument
static BsonDocument sanitizeDocument(final BsonDocument document) { if (document == null) { return null; } if (document.containsKey(DOCUMENT_VERSION_FIELD)) { final BsonDocument clonedDoc = document.clone(); clonedDoc.remove(DOCUMENT_VERSION_FIELD); return clonedDoc; } return document; }
java
static BsonDocument sanitizeDocument(final BsonDocument document) { if (document == null) { return null; } if (document.containsKey(DOCUMENT_VERSION_FIELD)) { final BsonDocument clonedDoc = document.clone(); clonedDoc.remove(DOCUMENT_VERSION_FIELD); return clonedDoc; } return document; }
[ "static", "BsonDocument", "sanitizeDocument", "(", "final", "BsonDocument", "document", ")", "{", "if", "(", "document", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "document", ".", "containsKey", "(", "DOCUMENT_VERSION_FIELD", ")", ")", "{", "final", "BsonDocument", "clonedDoc", "=", "document", ".", "clone", "(", ")", ";", "clonedDoc", ".", "remove", "(", "DOCUMENT_VERSION_FIELD", ")", ";", "return", "clonedDoc", ";", "}", "return", "document", ";", "}" ]
Given a BSON document, remove any forbidden fields and return the document. If no changes are made, the original document reference is returned. If changes are made, a cloned copy of the document with the changes will be returned. @param document the document from which to remove forbidden fields @return a BsonDocument without any forbidden fields.
[ "Given", "a", "BSON", "document", "remove", "any", "forbidden", "fields", "and", "return", "the", "document", ".", "If", "no", "changes", "are", "made", "the", "original", "document", "reference", "is", "returned", ".", "If", "changes", "are", "made", "a", "cloned", "copy", "of", "the", "document", "with", "the", "changes", "will", "be", "returned", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L3169-L3180
157,939
mongodb/stitch-android-sdk
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java
DataSynchronizer.withNewVersion
private static BsonDocument withNewVersion( final BsonDocument document, final BsonDocument newVersion ) { final BsonDocument newDocument = BsonUtils.copyOfDocument(document); newDocument.put(DOCUMENT_VERSION_FIELD, newVersion); return newDocument; }
java
private static BsonDocument withNewVersion( final BsonDocument document, final BsonDocument newVersion ) { final BsonDocument newDocument = BsonUtils.copyOfDocument(document); newDocument.put(DOCUMENT_VERSION_FIELD, newVersion); return newDocument; }
[ "private", "static", "BsonDocument", "withNewVersion", "(", "final", "BsonDocument", "document", ",", "final", "BsonDocument", "newVersion", ")", "{", "final", "BsonDocument", "newDocument", "=", "BsonUtils", ".", "copyOfDocument", "(", "document", ")", ";", "newDocument", ".", "put", "(", "DOCUMENT_VERSION_FIELD", ",", "newVersion", ")", ";", "return", "newDocument", ";", "}" ]
Adds and returns a document with a new version to the given document. @param document the document to attach a new version to. @param newVersion the version to attach to the document @return a document with a new version to the given document.
[ "Adds", "and", "returns", "a", "document", "with", "a", "new", "version", "to", "the", "given", "document", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L3189-L3196
157,940
mongodb/stitch-android-sdk
android/services/mongodb-local/src/main/java/com/mongodb/stitch/android/services/mongodb/local/LocalMongoDbService.java
LocalMongoDbService.clearallLocalDBs
public static void clearallLocalDBs() { for (final Map.Entry<MongoClient, Boolean> entry : localInstances.entrySet()) { for (final String dbName : entry.getKey().listDatabaseNames()) { entry.getKey().getDatabase(dbName).drop(); } } }
java
public static void clearallLocalDBs() { for (final Map.Entry<MongoClient, Boolean> entry : localInstances.entrySet()) { for (final String dbName : entry.getKey().listDatabaseNames()) { entry.getKey().getDatabase(dbName).drop(); } } }
[ "public", "static", "void", "clearallLocalDBs", "(", ")", "{", "for", "(", "final", "Map", ".", "Entry", "<", "MongoClient", ",", "Boolean", ">", "entry", ":", "localInstances", ".", "entrySet", "(", ")", ")", "{", "for", "(", "final", "String", "dbName", ":", "entry", ".", "getKey", "(", ")", ".", "listDatabaseNames", "(", ")", ")", "{", "entry", ".", "getKey", "(", ")", ".", "getDatabase", "(", "dbName", ")", ".", "drop", "(", ")", ";", "}", "}", "}" ]
Helper function that drops all local databases for every client.
[ "Helper", "function", "that", "drops", "all", "local", "databases", "for", "every", "client", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/services/mongodb-local/src/main/java/com/mongodb/stitch/android/services/mongodb/local/LocalMongoDbService.java#L62-L68
157,941
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/StitchObjectMapper.java
StitchObjectMapper.withCodecRegistry
public StitchObjectMapper withCodecRegistry(final CodecRegistry codecRegistry) { // We can't detect if their codecRegistry has any duplicate providers. There's also a chance // that putting ours first may prevent decoding of some of their classes if for example they // have their own way of decoding an Integer. final CodecRegistry newReg = CodecRegistries.fromRegistries(BsonUtils.DEFAULT_CODEC_REGISTRY, codecRegistry); return new StitchObjectMapper(this, newReg); }
java
public StitchObjectMapper withCodecRegistry(final CodecRegistry codecRegistry) { // We can't detect if their codecRegistry has any duplicate providers. There's also a chance // that putting ours first may prevent decoding of some of their classes if for example they // have their own way of decoding an Integer. final CodecRegistry newReg = CodecRegistries.fromRegistries(BsonUtils.DEFAULT_CODEC_REGISTRY, codecRegistry); return new StitchObjectMapper(this, newReg); }
[ "public", "StitchObjectMapper", "withCodecRegistry", "(", "final", "CodecRegistry", "codecRegistry", ")", "{", "// We can't detect if their codecRegistry has any duplicate providers. There's also a chance", "// that putting ours first may prevent decoding of some of their classes if for example they", "// have their own way of decoding an Integer.", "final", "CodecRegistry", "newReg", "=", "CodecRegistries", ".", "fromRegistries", "(", "BsonUtils", ".", "DEFAULT_CODEC_REGISTRY", ",", "codecRegistry", ")", ";", "return", "new", "StitchObjectMapper", "(", "this", ",", "newReg", ")", ";", "}" ]
Applies the given codec registry to be used alongside the default codec registry. @param codecRegistry the codec registry to merge in. @return an {@link StitchObjectMapper} with the merged codec registries.
[ "Applies", "the", "given", "codec", "registry", "to", "be", "used", "alongside", "the", "default", "codec", "registry", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/StitchObjectMapper.java#L107-L114
157,942
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/Stream.java
Stream.nextEvent
public StitchEvent<T> nextEvent() throws IOException { final Event nextEvent = eventStream.nextEvent(); if (nextEvent == null) { return null; } return StitchEvent.fromEvent(nextEvent, this.decoder); }
java
public StitchEvent<T> nextEvent() throws IOException { final Event nextEvent = eventStream.nextEvent(); if (nextEvent == null) { return null; } return StitchEvent.fromEvent(nextEvent, this.decoder); }
[ "public", "StitchEvent", "<", "T", ">", "nextEvent", "(", ")", "throws", "IOException", "{", "final", "Event", "nextEvent", "=", "eventStream", ".", "nextEvent", "(", ")", ";", "if", "(", "nextEvent", "==", "null", ")", "{", "return", "null", ";", "}", "return", "StitchEvent", ".", "fromEvent", "(", "nextEvent", ",", "this", ".", "decoder", ")", ";", "}" ]
Fetch the next event from a given stream @return the next event @throws IOException any io exception that could occur
[ "Fetch", "the", "next", "event", "from", "a", "given", "stream" ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/Stream.java#L52-L59
157,943
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/auth/internal/CoreStitchAuth.java
CoreStitchAuth.getUser
@Nullable public StitchUserT getUser() { authLock.readLock().lock(); try { return activeUser; } finally { authLock.readLock().unlock(); } }
java
@Nullable public StitchUserT getUser() { authLock.readLock().lock(); try { return activeUser; } finally { authLock.readLock().unlock(); } }
[ "@", "Nullable", "public", "StitchUserT", "getUser", "(", ")", "{", "authLock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "return", "activeUser", ";", "}", "finally", "{", "authLock", ".", "readLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Returns the active logged in user.
[ "Returns", "the", "active", "logged", "in", "user", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/auth/internal/CoreStitchAuth.java#L196-L204
157,944
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/auth/internal/CoreStitchAuth.java
CoreStitchAuth.doAuthenticatedRequest
private synchronized Response doAuthenticatedRequest( final StitchAuthRequest stitchReq, final AuthInfo authInfo ) { try { return requestClient.doRequest(prepareAuthRequest(stitchReq, authInfo)); } catch (final StitchServiceException ex) { return handleAuthFailure(ex, stitchReq); } }
java
private synchronized Response doAuthenticatedRequest( final StitchAuthRequest stitchReq, final AuthInfo authInfo ) { try { return requestClient.doRequest(prepareAuthRequest(stitchReq, authInfo)); } catch (final StitchServiceException ex) { return handleAuthFailure(ex, stitchReq); } }
[ "private", "synchronized", "Response", "doAuthenticatedRequest", "(", "final", "StitchAuthRequest", "stitchReq", ",", "final", "AuthInfo", "authInfo", ")", "{", "try", "{", "return", "requestClient", ".", "doRequest", "(", "prepareAuthRequest", "(", "stitchReq", ",", "authInfo", ")", ")", ";", "}", "catch", "(", "final", "StitchServiceException", "ex", ")", "{", "return", "handleAuthFailure", "(", "ex", ",", "stitchReq", ")", ";", "}", "}" ]
Internal method which performs the authenticated request by preparing the auth request with the provided auth info and request.
[ "Internal", "method", "which", "performs", "the", "authenticated", "request", "by", "preparing", "the", "auth", "request", "with", "the", "provided", "auth", "info", "and", "request", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/auth/internal/CoreStitchAuth.java#L234-L243
157,945
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/auth/internal/CoreStitchAuth.java
CoreStitchAuth.tryRefreshAccessToken
private void tryRefreshAccessToken(final Long reqStartedAt) { authLock.writeLock().lock(); try { if (!isLoggedIn()) { throw new StitchClientException(StitchClientErrorCode.LOGGED_OUT_DURING_REQUEST); } try { final Jwt jwt = Jwt.fromEncoded(getAuthInfo().getAccessToken()); if (jwt.getIssuedAt() >= reqStartedAt) { return; } } catch (final IOException e) { // Swallow } // retry refreshAccessToken(); } finally { authLock.writeLock().unlock(); } }
java
private void tryRefreshAccessToken(final Long reqStartedAt) { authLock.writeLock().lock(); try { if (!isLoggedIn()) { throw new StitchClientException(StitchClientErrorCode.LOGGED_OUT_DURING_REQUEST); } try { final Jwt jwt = Jwt.fromEncoded(getAuthInfo().getAccessToken()); if (jwt.getIssuedAt() >= reqStartedAt) { return; } } catch (final IOException e) { // Swallow } // retry refreshAccessToken(); } finally { authLock.writeLock().unlock(); } }
[ "private", "void", "tryRefreshAccessToken", "(", "final", "Long", "reqStartedAt", ")", "{", "authLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "!", "isLoggedIn", "(", ")", ")", "{", "throw", "new", "StitchClientException", "(", "StitchClientErrorCode", ".", "LOGGED_OUT_DURING_REQUEST", ")", ";", "}", "try", "{", "final", "Jwt", "jwt", "=", "Jwt", ".", "fromEncoded", "(", "getAuthInfo", "(", ")", ".", "getAccessToken", "(", ")", ")", ";", "if", "(", "jwt", ".", "getIssuedAt", "(", ")", ">=", "reqStartedAt", ")", "{", "return", ";", "}", "}", "catch", "(", "final", "IOException", "e", ")", "{", "// Swallow", "}", "// retry", "refreshAccessToken", "(", ")", ";", "}", "finally", "{", "authLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
prevent too many refreshes happening one after the other.
[ "prevent", "too", "many", "refreshes", "happening", "one", "after", "the", "other", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/auth/internal/CoreStitchAuth.java#L570-L591
157,946
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/auth/internal/CoreStitchAuth.java
CoreStitchAuth.doLogin
private StitchUserT doLogin(final StitchCredential credential, final boolean asLinkRequest) { final Response response = doLoginRequest(credential, asLinkRequest); final StitchUserT previousUser = activeUser; final StitchUserT user = processLoginResponse(credential, response, asLinkRequest); if (asLinkRequest) { onUserLinked(user); } else { onUserLoggedIn(user); onActiveUserChanged(activeUser, previousUser); } return user; }
java
private StitchUserT doLogin(final StitchCredential credential, final boolean asLinkRequest) { final Response response = doLoginRequest(credential, asLinkRequest); final StitchUserT previousUser = activeUser; final StitchUserT user = processLoginResponse(credential, response, asLinkRequest); if (asLinkRequest) { onUserLinked(user); } else { onUserLoggedIn(user); onActiveUserChanged(activeUser, previousUser); } return user; }
[ "private", "StitchUserT", "doLogin", "(", "final", "StitchCredential", "credential", ",", "final", "boolean", "asLinkRequest", ")", "{", "final", "Response", "response", "=", "doLoginRequest", "(", "credential", ",", "asLinkRequest", ")", ";", "final", "StitchUserT", "previousUser", "=", "activeUser", ";", "final", "StitchUserT", "user", "=", "processLoginResponse", "(", "credential", ",", "response", ",", "asLinkRequest", ")", ";", "if", "(", "asLinkRequest", ")", "{", "onUserLinked", "(", "user", ")", ";", "}", "else", "{", "onUserLoggedIn", "(", "user", ")", ";", "onActiveUserChanged", "(", "activeUser", ",", "previousUser", ")", ";", "}", "return", "user", ";", "}" ]
callers of doLogin should be serialized before calling in.
[ "callers", "of", "doLogin", "should", "be", "serialized", "before", "calling", "in", "." ]
159b9334b1f1a827285544be5ee20cdf7b04e4cc
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/auth/internal/CoreStitchAuth.java#L631-L645
157,947
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/Interval.java
Interval.parseStartExtended
private static Interval parseStartExtended(CharSequence startStr, CharSequence endStr) { Instant start = Instant.parse(startStr); if (endStr.length() > 0) { char c = endStr.charAt(0); if (c == 'P' || c == 'p') { PeriodDuration amount = PeriodDuration.parse(endStr); // addition of PeriodDuration only supported by OffsetDateTime, // but to make that work need to move point being added to closer to EPOCH long move = start.isBefore(Instant.EPOCH) ? 1000 * 86400 : -1000 * 86400; Instant end = start.plusSeconds(move).atOffset(ZoneOffset.UTC).plus(amount).toInstant().minusSeconds(move); return Interval.of(start, end); } } // infer offset from start if not specified by end return parseEndDateTime(start, ZoneOffset.UTC, endStr); }
java
private static Interval parseStartExtended(CharSequence startStr, CharSequence endStr) { Instant start = Instant.parse(startStr); if (endStr.length() > 0) { char c = endStr.charAt(0); if (c == 'P' || c == 'p') { PeriodDuration amount = PeriodDuration.parse(endStr); // addition of PeriodDuration only supported by OffsetDateTime, // but to make that work need to move point being added to closer to EPOCH long move = start.isBefore(Instant.EPOCH) ? 1000 * 86400 : -1000 * 86400; Instant end = start.plusSeconds(move).atOffset(ZoneOffset.UTC).plus(amount).toInstant().minusSeconds(move); return Interval.of(start, end); } } // infer offset from start if not specified by end return parseEndDateTime(start, ZoneOffset.UTC, endStr); }
[ "private", "static", "Interval", "parseStartExtended", "(", "CharSequence", "startStr", ",", "CharSequence", "endStr", ")", "{", "Instant", "start", "=", "Instant", ".", "parse", "(", "startStr", ")", ";", "if", "(", "endStr", ".", "length", "(", ")", ">", "0", ")", "{", "char", "c", "=", "endStr", ".", "charAt", "(", "0", ")", ";", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "{", "PeriodDuration", "amount", "=", "PeriodDuration", ".", "parse", "(", "endStr", ")", ";", "// addition of PeriodDuration only supported by OffsetDateTime,", "// but to make that work need to move point being added to closer to EPOCH", "long", "move", "=", "start", ".", "isBefore", "(", "Instant", ".", "EPOCH", ")", "?", "1000", "*", "86400", ":", "-", "1000", "*", "86400", ";", "Instant", "end", "=", "start", ".", "plusSeconds", "(", "move", ")", ".", "atOffset", "(", "ZoneOffset", ".", "UTC", ")", ".", "plus", "(", "amount", ")", ".", "toInstant", "(", ")", ".", "minusSeconds", "(", "move", ")", ";", "return", "Interval", ".", "of", "(", "start", ",", "end", ")", ";", "}", "}", "// infer offset from start if not specified by end", "return", "parseEndDateTime", "(", "start", ",", "ZoneOffset", ".", "UTC", ",", "endStr", ")", ";", "}" ]
handle case where Instant is outside the bounds of OffsetDateTime
[ "handle", "case", "where", "Instant", "is", "outside", "the", "bounds", "of", "OffsetDateTime" ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/Interval.java#L203-L218
157,948
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/Interval.java
Interval.parseEndDateTime
private static Interval parseEndDateTime(Instant start, ZoneOffset offset, CharSequence endStr) { try { TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest(endStr, OffsetDateTime::from, LocalDateTime::from); if (temporal instanceof OffsetDateTime) { OffsetDateTime odt = (OffsetDateTime) temporal; return Interval.of(start, odt.toInstant()); } else { // infer offset from start if not specified by end LocalDateTime ldt = (LocalDateTime) temporal; return Interval.of(start, ldt.toInstant(offset)); } } catch (DateTimeParseException ex) { Instant end = Instant.parse(endStr); return Interval.of(start, end); } }
java
private static Interval parseEndDateTime(Instant start, ZoneOffset offset, CharSequence endStr) { try { TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest(endStr, OffsetDateTime::from, LocalDateTime::from); if (temporal instanceof OffsetDateTime) { OffsetDateTime odt = (OffsetDateTime) temporal; return Interval.of(start, odt.toInstant()); } else { // infer offset from start if not specified by end LocalDateTime ldt = (LocalDateTime) temporal; return Interval.of(start, ldt.toInstant(offset)); } } catch (DateTimeParseException ex) { Instant end = Instant.parse(endStr); return Interval.of(start, end); } }
[ "private", "static", "Interval", "parseEndDateTime", "(", "Instant", "start", ",", "ZoneOffset", "offset", ",", "CharSequence", "endStr", ")", "{", "try", "{", "TemporalAccessor", "temporal", "=", "DateTimeFormatter", ".", "ISO_DATE_TIME", ".", "parseBest", "(", "endStr", ",", "OffsetDateTime", "::", "from", ",", "LocalDateTime", "::", "from", ")", ";", "if", "(", "temporal", "instanceof", "OffsetDateTime", ")", "{", "OffsetDateTime", "odt", "=", "(", "OffsetDateTime", ")", "temporal", ";", "return", "Interval", ".", "of", "(", "start", ",", "odt", ".", "toInstant", "(", ")", ")", ";", "}", "else", "{", "// infer offset from start if not specified by end", "LocalDateTime", "ldt", "=", "(", "LocalDateTime", ")", "temporal", ";", "return", "Interval", ".", "of", "(", "start", ",", "ldt", ".", "toInstant", "(", "offset", ")", ")", ";", "}", "}", "catch", "(", "DateTimeParseException", "ex", ")", "{", "Instant", "end", "=", "Instant", ".", "parse", "(", "endStr", ")", ";", "return", "Interval", ".", "of", "(", "start", ",", "end", ")", ";", "}", "}" ]
parse when there are two date-times
[ "parse", "when", "there", "are", "two", "date", "-", "times" ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/Interval.java#L221-L236
157,949
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/AccountingChronology.java
AccountingChronology.date
@Override public AccountingDate date(int prolepticYear, int month, int dayOfMonth) { return AccountingDate.of(this, prolepticYear, month, dayOfMonth); }
java
@Override public AccountingDate date(int prolepticYear, int month, int dayOfMonth) { return AccountingDate.of(this, prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "AccountingDate", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "AccountingDate", ".", "of", "(", "this", ",", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Accounting calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the Accounting local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Accounting", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/AccountingChronology.java#L307-L310
157,950
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/AccountingChronology.java
AccountingChronology.dateYearDay
@Override public AccountingDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public AccountingDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "AccountingDate", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in Accounting calendar system from the era, year-of-era and day-of-year fields. @param era the Accounting era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the Accounting local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code AccountingEra}
[ "Obtains", "a", "local", "date", "in", "Accounting", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/AccountingChronology.java#L323-L326
157,951
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/AccountingChronology.java
AccountingChronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<AccountingDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<AccountingDate>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<AccountingDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<AccountingDate>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "AccountingDate", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "AccountingDate", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Accounting local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Accounting local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Accounting", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/AccountingChronology.java#L426-L430
157,952
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/AccountingChronology.java
AccountingChronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<AccountingDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<AccountingDate>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<AccountingDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<AccountingDate>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "AccountingDate", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "AccountingDate", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Accounting zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Accounting zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Accounting", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/AccountingChronology.java#L439-L443
157,953
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/CopticChronology.java
CopticChronology.date
@Override public CopticDate date(int prolepticYear, int month, int dayOfMonth) { return CopticDate.of(prolepticYear, month, dayOfMonth); }
java
@Override public CopticDate date(int prolepticYear, int month, int dayOfMonth) { return CopticDate.of(prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "CopticDate", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "CopticDate", ".", "of", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Coptic calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the Coptic local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Coptic", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/CopticChronology.java#L167-L170
157,954
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/CopticChronology.java
CopticChronology.dateYearDay
@Override public CopticDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public CopticDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "CopticDate", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in Coptic calendar system from the era, year-of-era and day-of-year fields. @param era the Coptic era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the Coptic local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code CopticEra}
[ "Obtains", "a", "local", "date", "in", "Coptic", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/CopticChronology.java#L183-L186
157,955
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/CopticChronology.java
CopticChronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<CopticDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<CopticDate>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<CopticDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<CopticDate>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "CopticDate", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "CopticDate", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Coptic local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Coptic local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Coptic", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/CopticChronology.java#L286-L290
157,956
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/CopticChronology.java
CopticChronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<CopticDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<CopticDate>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<CopticDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<CopticDate>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "CopticDate", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "CopticDate", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Coptic zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Coptic zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Coptic", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/CopticChronology.java#L299-L303
157,957
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/YearQuarter.java
YearQuarter.with
private YearQuarter with(int newYear, Quarter newQuarter) { if (year == newYear && quarter == newQuarter) { return this; } return new YearQuarter(newYear, newQuarter); }
java
private YearQuarter with(int newYear, Quarter newQuarter) { if (year == newYear && quarter == newQuarter) { return this; } return new YearQuarter(newYear, newQuarter); }
[ "private", "YearQuarter", "with", "(", "int", "newYear", ",", "Quarter", "newQuarter", ")", "{", "if", "(", "year", "==", "newYear", "&&", "quarter", "==", "newQuarter", ")", "{", "return", "this", ";", "}", "return", "new", "YearQuarter", "(", "newYear", ",", "newQuarter", ")", ";", "}" ]
Returns a copy of this year-quarter with the new year and quarter, checking to see if a new object is in fact required. @param newYear the year to represent, validated from MIN_YEAR to MAX_YEAR @param newQuarter the quarter-of-year to represent, validated not null @return the year-quarter, not null
[ "Returns", "a", "copy", "of", "this", "year", "-", "quarter", "with", "the", "new", "year", "and", "quarter", "checking", "to", "see", "if", "a", "new", "object", "is", "in", "fact", "required", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/YearQuarter.java#L308-L313
157,958
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/BritishCutoverChronology.java
BritishCutoverChronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<BritishCutoverDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<BritishCutoverDate>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<BritishCutoverDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<BritishCutoverDate>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "BritishCutoverDate", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "BritishCutoverDate", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a British Cutover local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the British Cutover local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "British", "Cutover", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/BritishCutoverChronology.java#L370-L374
157,959
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/BritishCutoverChronology.java
BritishCutoverChronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<BritishCutoverDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<BritishCutoverDate>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<BritishCutoverDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<BritishCutoverDate>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "BritishCutoverDate", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "BritishCutoverDate", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a British Cutover zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the British Cutover zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "British", "Cutover", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/BritishCutoverChronology.java#L383-L387
157,960
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/YearWeek.java
YearWeek.weekRange
private static int weekRange(int weekBasedYear) { LocalDate date = LocalDate.of(weekBasedYear, 1, 1); // 53 weeks if year starts on Thursday, or Wed in a leap year if (date.getDayOfWeek() == THURSDAY || (date.getDayOfWeek() == WEDNESDAY && date.isLeapYear())) { return 53; } return 52; }
java
private static int weekRange(int weekBasedYear) { LocalDate date = LocalDate.of(weekBasedYear, 1, 1); // 53 weeks if year starts on Thursday, or Wed in a leap year if (date.getDayOfWeek() == THURSDAY || (date.getDayOfWeek() == WEDNESDAY && date.isLeapYear())) { return 53; } return 52; }
[ "private", "static", "int", "weekRange", "(", "int", "weekBasedYear", ")", "{", "LocalDate", "date", "=", "LocalDate", ".", "of", "(", "weekBasedYear", ",", "1", ",", "1", ")", ";", "// 53 weeks if year starts on Thursday, or Wed in a leap year", "if", "(", "date", ".", "getDayOfWeek", "(", ")", "==", "THURSDAY", "||", "(", "date", ".", "getDayOfWeek", "(", ")", "==", "WEDNESDAY", "&&", "date", ".", "isLeapYear", "(", ")", ")", ")", "{", "return", "53", ";", "}", "return", "52", ";", "}" ]
from IsoFields in ThreeTen-Backport
[ "from", "IsoFields", "in", "ThreeTen", "-", "Backport" ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/YearWeek.java#L193-L200
157,961
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/YearWeek.java
YearWeek.with
private YearWeek with(int newYear, int newWeek) { if (year == newYear && week == newWeek) { return this; } return of(newYear, newWeek); }
java
private YearWeek with(int newYear, int newWeek) { if (year == newYear && week == newWeek) { return this; } return of(newYear, newWeek); }
[ "private", "YearWeek", "with", "(", "int", "newYear", ",", "int", "newWeek", ")", "{", "if", "(", "year", "==", "newYear", "&&", "week", "==", "newWeek", ")", "{", "return", "this", ";", "}", "return", "of", "(", "newYear", ",", "newWeek", ")", ";", "}" ]
Returns a copy of this year-week with the new year and week, checking to see if a new object is in fact required. @param newYear the year to represent, validated from MIN_YEAR to MAX_YEAR @param newWeek the week to represent, validated from 1 to 53 @return the year-week, not null
[ "Returns", "a", "copy", "of", "this", "year", "-", "week", "with", "the", "new", "year", "and", "week", "checking", "to", "see", "if", "a", "new", "object", "is", "in", "fact", "required", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/YearWeek.java#L303-L308
157,962
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/scale/SystemUtcRules.java
SystemUtcRules.register
void register(long mjDay, int leapAdjustment) { if (leapAdjustment != -1 && leapAdjustment != 1) { throw new IllegalArgumentException("Leap adjustment must be -1 or 1"); } Data data = dataRef.get(); int pos = Arrays.binarySearch(data.dates, mjDay); int currentAdj = pos > 0 ? data.offsets[pos] - data.offsets[pos - 1] : 0; if (currentAdj == leapAdjustment) { return; // matches previous definition } if (mjDay <= data.dates[data.dates.length - 1]) { throw new IllegalArgumentException("Date must be after the last configured leap second date"); } long[] dates = Arrays.copyOf(data.dates, data.dates.length + 1); int[] offsets = Arrays.copyOf(data.offsets, data.offsets.length + 1); long[] taiSeconds = Arrays.copyOf(data.taiSeconds, data.taiSeconds.length + 1); int offset = offsets[offsets.length - 2] + leapAdjustment; dates[dates.length - 1] = mjDay; offsets[offsets.length - 1] = offset; taiSeconds[taiSeconds.length - 1] = tai(mjDay, offset); Data newData = new Data(dates, offsets, taiSeconds); if (dataRef.compareAndSet(data, newData) == false) { throw new ConcurrentModificationException("Unable to update leap second rules as they have already been updated"); } }
java
void register(long mjDay, int leapAdjustment) { if (leapAdjustment != -1 && leapAdjustment != 1) { throw new IllegalArgumentException("Leap adjustment must be -1 or 1"); } Data data = dataRef.get(); int pos = Arrays.binarySearch(data.dates, mjDay); int currentAdj = pos > 0 ? data.offsets[pos] - data.offsets[pos - 1] : 0; if (currentAdj == leapAdjustment) { return; // matches previous definition } if (mjDay <= data.dates[data.dates.length - 1]) { throw new IllegalArgumentException("Date must be after the last configured leap second date"); } long[] dates = Arrays.copyOf(data.dates, data.dates.length + 1); int[] offsets = Arrays.copyOf(data.offsets, data.offsets.length + 1); long[] taiSeconds = Arrays.copyOf(data.taiSeconds, data.taiSeconds.length + 1); int offset = offsets[offsets.length - 2] + leapAdjustment; dates[dates.length - 1] = mjDay; offsets[offsets.length - 1] = offset; taiSeconds[taiSeconds.length - 1] = tai(mjDay, offset); Data newData = new Data(dates, offsets, taiSeconds); if (dataRef.compareAndSet(data, newData) == false) { throw new ConcurrentModificationException("Unable to update leap second rules as they have already been updated"); } }
[ "void", "register", "(", "long", "mjDay", ",", "int", "leapAdjustment", ")", "{", "if", "(", "leapAdjustment", "!=", "-", "1", "&&", "leapAdjustment", "!=", "1", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Leap adjustment must be -1 or 1\"", ")", ";", "}", "Data", "data", "=", "dataRef", ".", "get", "(", ")", ";", "int", "pos", "=", "Arrays", ".", "binarySearch", "(", "data", ".", "dates", ",", "mjDay", ")", ";", "int", "currentAdj", "=", "pos", ">", "0", "?", "data", ".", "offsets", "[", "pos", "]", "-", "data", ".", "offsets", "[", "pos", "-", "1", "]", ":", "0", ";", "if", "(", "currentAdj", "==", "leapAdjustment", ")", "{", "return", ";", "// matches previous definition", "}", "if", "(", "mjDay", "<=", "data", ".", "dates", "[", "data", ".", "dates", ".", "length", "-", "1", "]", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Date must be after the last configured leap second date\"", ")", ";", "}", "long", "[", "]", "dates", "=", "Arrays", ".", "copyOf", "(", "data", ".", "dates", ",", "data", ".", "dates", ".", "length", "+", "1", ")", ";", "int", "[", "]", "offsets", "=", "Arrays", ".", "copyOf", "(", "data", ".", "offsets", ",", "data", ".", "offsets", ".", "length", "+", "1", ")", ";", "long", "[", "]", "taiSeconds", "=", "Arrays", ".", "copyOf", "(", "data", ".", "taiSeconds", ",", "data", ".", "taiSeconds", ".", "length", "+", "1", ")", ";", "int", "offset", "=", "offsets", "[", "offsets", ".", "length", "-", "2", "]", "+", "leapAdjustment", ";", "dates", "[", "dates", ".", "length", "-", "1", "]", "=", "mjDay", ";", "offsets", "[", "offsets", ".", "length", "-", "1", "]", "=", "offset", ";", "taiSeconds", "[", "taiSeconds", ".", "length", "-", "1", "]", "=", "tai", "(", "mjDay", ",", "offset", ")", ";", "Data", "newData", "=", "new", "Data", "(", "dates", ",", "offsets", ",", "taiSeconds", ")", ";", "if", "(", "dataRef", ".", "compareAndSet", "(", "data", ",", "newData", ")", "==", "false", ")", "{", "throw", "new", "ConcurrentModificationException", "(", "\"Unable to update leap second rules as they have already been updated\"", ")", ";", "}", "}" ]
Adds a new leap second to these rules. @param mjDay the Modified Julian Day that the leap second occurs at the end of @param leapAdjustment the leap seconds to add/remove at the end of the day, either -1 or 1 @throws IllegalArgumentException if the leap adjustment is invalid @throws IllegalArgumentException if the day is before or equal the last known leap second day and the definition does not match a previously registered leap @throws ConcurrentModificationException if another thread updates the rules at the same time
[ "Adds", "a", "new", "leap", "second", "to", "these", "rules", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/scale/SystemUtcRules.java#L136-L160
157,963
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/scale/SystemUtcRules.java
SystemUtcRules.loadLeapSeconds
private static Data loadLeapSeconds() { Data bestData = null; URL url = null; try { // this is the new location of the file, working on Java 8, Java 9 class path and Java 9 module path Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources("META-INF/" + LEAP_SECONDS_TXT); while (en.hasMoreElements()) { url = en.nextElement(); Data candidate = loadLeapSeconds(url); if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) { bestData = candidate; } } // this location does not work on Java 9 module path because the resource is encapsulated en = Thread.currentThread().getContextClassLoader().getResources(LEAP_SECONDS_TXT); while (en.hasMoreElements()) { url = en.nextElement(); Data candidate = loadLeapSeconds(url); if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) { bestData = candidate; } } // this location is the canonical one, and class-based loading works on Java 9 module path url = SystemUtcRules.class.getResource("/" + LEAP_SECONDS_TXT); if (url != null) { Data candidate = loadLeapSeconds(url); if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) { bestData = candidate; } } } catch (Exception ex) { throw new RuntimeException("Unable to load time-zone rule data: " + url, ex); } if (bestData == null) { // no data on classpath, but we allow manual registration of leap seconds // setup basic known data - MJD 1972-01-01 is 41317L, where offset was 10 bestData = new Data(new long[] {41317L}, new int[] {10}, new long[] {tai(41317L, 10)}); } return bestData; }
java
private static Data loadLeapSeconds() { Data bestData = null; URL url = null; try { // this is the new location of the file, working on Java 8, Java 9 class path and Java 9 module path Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources("META-INF/" + LEAP_SECONDS_TXT); while (en.hasMoreElements()) { url = en.nextElement(); Data candidate = loadLeapSeconds(url); if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) { bestData = candidate; } } // this location does not work on Java 9 module path because the resource is encapsulated en = Thread.currentThread().getContextClassLoader().getResources(LEAP_SECONDS_TXT); while (en.hasMoreElements()) { url = en.nextElement(); Data candidate = loadLeapSeconds(url); if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) { bestData = candidate; } } // this location is the canonical one, and class-based loading works on Java 9 module path url = SystemUtcRules.class.getResource("/" + LEAP_SECONDS_TXT); if (url != null) { Data candidate = loadLeapSeconds(url); if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) { bestData = candidate; } } } catch (Exception ex) { throw new RuntimeException("Unable to load time-zone rule data: " + url, ex); } if (bestData == null) { // no data on classpath, but we allow manual registration of leap seconds // setup basic known data - MJD 1972-01-01 is 41317L, where offset was 10 bestData = new Data(new long[] {41317L}, new int[] {10}, new long[] {tai(41317L, 10)}); } return bestData; }
[ "private", "static", "Data", "loadLeapSeconds", "(", ")", "{", "Data", "bestData", "=", "null", ";", "URL", "url", "=", "null", ";", "try", "{", "// this is the new location of the file, working on Java 8, Java 9 class path and Java 9 module path", "Enumeration", "<", "URL", ">", "en", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResources", "(", "\"META-INF/\"", "+", "LEAP_SECONDS_TXT", ")", ";", "while", "(", "en", ".", "hasMoreElements", "(", ")", ")", "{", "url", "=", "en", ".", "nextElement", "(", ")", ";", "Data", "candidate", "=", "loadLeapSeconds", "(", "url", ")", ";", "if", "(", "bestData", "==", "null", "||", "candidate", ".", "getNewestDate", "(", ")", ">", "bestData", ".", "getNewestDate", "(", ")", ")", "{", "bestData", "=", "candidate", ";", "}", "}", "// this location does not work on Java 9 module path because the resource is encapsulated", "en", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResources", "(", "LEAP_SECONDS_TXT", ")", ";", "while", "(", "en", ".", "hasMoreElements", "(", ")", ")", "{", "url", "=", "en", ".", "nextElement", "(", ")", ";", "Data", "candidate", "=", "loadLeapSeconds", "(", "url", ")", ";", "if", "(", "bestData", "==", "null", "||", "candidate", ".", "getNewestDate", "(", ")", ">", "bestData", ".", "getNewestDate", "(", ")", ")", "{", "bestData", "=", "candidate", ";", "}", "}", "// this location is the canonical one, and class-based loading works on Java 9 module path", "url", "=", "SystemUtcRules", ".", "class", ".", "getResource", "(", "\"/\"", "+", "LEAP_SECONDS_TXT", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "Data", "candidate", "=", "loadLeapSeconds", "(", "url", ")", ";", "if", "(", "bestData", "==", "null", "||", "candidate", ".", "getNewestDate", "(", ")", ">", "bestData", ".", "getNewestDate", "(", ")", ")", "{", "bestData", "=", "candidate", ";", "}", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unable to load time-zone rule data: \"", "+", "url", ",", "ex", ")", ";", "}", "if", "(", "bestData", "==", "null", ")", "{", "// no data on classpath, but we allow manual registration of leap seconds", "// setup basic known data - MJD 1972-01-01 is 41317L, where offset was 10", "bestData", "=", "new", "Data", "(", "new", "long", "[", "]", "{", "41317L", "}", ",", "new", "int", "[", "]", "{", "10", "}", ",", "new", "long", "[", "]", "{", "tai", "(", "41317L", ",", "10", ")", "}", ")", ";", "}", "return", "bestData", ";", "}" ]
Loads the rules from files in the class loader, often jar files. @return the list of loaded rules, not null @throws Exception if an error occurs
[ "Loads", "the", "rules", "from", "files", "in", "the", "class", "loader", "often", "jar", "files", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/scale/SystemUtcRules.java#L216-L255
157,964
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/scale/SystemUtcRules.java
SystemUtcRules.loadLeapSeconds
private static Data loadLeapSeconds(URL url) throws ClassNotFoundException, IOException { List<String> lines; try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) { lines = reader.lines().collect(Collectors.toList()); } List<Long> dates = new ArrayList<>(); List<Integer> offsets = new ArrayList<>(); for (String line : lines) { line = line.trim(); if (line.isEmpty() || line.startsWith("#")) { continue; } Matcher matcher = LEAP_FILE_FORMAT.matcher(line); if (matcher.matches() == false) { throw new StreamCorruptedException("Invalid leap second file"); } dates.add(LocalDate.parse(matcher.group(1)).getLong(JulianFields.MODIFIED_JULIAN_DAY)); offsets.add(Integer.valueOf(matcher.group(2))); } long[] datesData = new long[dates.size()]; int[] offsetsData = new int[dates.size()]; long[] taiData = new long[dates.size()]; for (int i = 0; i < datesData.length; i++) { datesData[i] = dates.get(i); offsetsData[i] = offsets.get(i); taiData[i] = tai(datesData[i], offsetsData[i]); } return new Data(datesData, offsetsData, taiData); }
java
private static Data loadLeapSeconds(URL url) throws ClassNotFoundException, IOException { List<String> lines; try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) { lines = reader.lines().collect(Collectors.toList()); } List<Long> dates = new ArrayList<>(); List<Integer> offsets = new ArrayList<>(); for (String line : lines) { line = line.trim(); if (line.isEmpty() || line.startsWith("#")) { continue; } Matcher matcher = LEAP_FILE_FORMAT.matcher(line); if (matcher.matches() == false) { throw new StreamCorruptedException("Invalid leap second file"); } dates.add(LocalDate.parse(matcher.group(1)).getLong(JulianFields.MODIFIED_JULIAN_DAY)); offsets.add(Integer.valueOf(matcher.group(2))); } long[] datesData = new long[dates.size()]; int[] offsetsData = new int[dates.size()]; long[] taiData = new long[dates.size()]; for (int i = 0; i < datesData.length; i++) { datesData[i] = dates.get(i); offsetsData[i] = offsets.get(i); taiData[i] = tai(datesData[i], offsetsData[i]); } return new Data(datesData, offsetsData, taiData); }
[ "private", "static", "Data", "loadLeapSeconds", "(", "URL", "url", ")", "throws", "ClassNotFoundException", ",", "IOException", "{", "List", "<", "String", ">", "lines", ";", "try", "(", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "url", ".", "openStream", "(", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ")", ")", "{", "lines", "=", "reader", ".", "lines", "(", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "}", "List", "<", "Long", ">", "dates", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "Integer", ">", "offsets", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "line", ":", "lines", ")", "{", "line", "=", "line", ".", "trim", "(", ")", ";", "if", "(", "line", ".", "isEmpty", "(", ")", "||", "line", ".", "startsWith", "(", "\"#\"", ")", ")", "{", "continue", ";", "}", "Matcher", "matcher", "=", "LEAP_FILE_FORMAT", ".", "matcher", "(", "line", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", "==", "false", ")", "{", "throw", "new", "StreamCorruptedException", "(", "\"Invalid leap second file\"", ")", ";", "}", "dates", ".", "add", "(", "LocalDate", ".", "parse", "(", "matcher", ".", "group", "(", "1", ")", ")", ".", "getLong", "(", "JulianFields", ".", "MODIFIED_JULIAN_DAY", ")", ")", ";", "offsets", ".", "add", "(", "Integer", ".", "valueOf", "(", "matcher", ".", "group", "(", "2", ")", ")", ")", ";", "}", "long", "[", "]", "datesData", "=", "new", "long", "[", "dates", ".", "size", "(", ")", "]", ";", "int", "[", "]", "offsetsData", "=", "new", "int", "[", "dates", ".", "size", "(", ")", "]", ";", "long", "[", "]", "taiData", "=", "new", "long", "[", "dates", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "datesData", ".", "length", ";", "i", "++", ")", "{", "datesData", "[", "i", "]", "=", "dates", ".", "get", "(", "i", ")", ";", "offsetsData", "[", "i", "]", "=", "offsets", ".", "get", "(", "i", ")", ";", "taiData", "[", "i", "]", "=", "tai", "(", "datesData", "[", "i", "]", ",", "offsetsData", "[", "i", "]", ")", ";", "}", "return", "new", "Data", "(", "datesData", ",", "offsetsData", ",", "taiData", ")", ";", "}" ]
Loads the leap second rules from a URL, often in a jar file. @param url the jar file to load, not null @throws Exception if an error occurs
[ "Loads", "the", "leap", "second", "rules", "from", "a", "URL", "often", "in", "a", "jar", "file", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/scale/SystemUtcRules.java#L263-L291
157,965
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/InternationalFixedDate.java
InternationalFixedDate.create
static InternationalFixedDate create(int prolepticYear, int month, int dayOfMonth) { YEAR_RANGE.checkValidValue(prolepticYear, ChronoField.YEAR_OF_ERA); MONTH_OF_YEAR_RANGE.checkValidValue(month, ChronoField.MONTH_OF_YEAR); DAY_OF_MONTH_RANGE.checkValidValue(dayOfMonth, ChronoField.DAY_OF_MONTH); if (dayOfMonth == DAYS_IN_LONG_MONTH && month != 6 && month != MONTHS_IN_YEAR) { throw new DateTimeException("Invalid date: " + prolepticYear + '/' + month + '/' + dayOfMonth); } if (month == 6 && dayOfMonth == DAYS_IN_LONG_MONTH && !INSTANCE.isLeapYear(prolepticYear)) { throw new DateTimeException("Invalid Leap Day as '" + prolepticYear + "' is not a leap year"); } return new InternationalFixedDate(prolepticYear, month, dayOfMonth); }
java
static InternationalFixedDate create(int prolepticYear, int month, int dayOfMonth) { YEAR_RANGE.checkValidValue(prolepticYear, ChronoField.YEAR_OF_ERA); MONTH_OF_YEAR_RANGE.checkValidValue(month, ChronoField.MONTH_OF_YEAR); DAY_OF_MONTH_RANGE.checkValidValue(dayOfMonth, ChronoField.DAY_OF_MONTH); if (dayOfMonth == DAYS_IN_LONG_MONTH && month != 6 && month != MONTHS_IN_YEAR) { throw new DateTimeException("Invalid date: " + prolepticYear + '/' + month + '/' + dayOfMonth); } if (month == 6 && dayOfMonth == DAYS_IN_LONG_MONTH && !INSTANCE.isLeapYear(prolepticYear)) { throw new DateTimeException("Invalid Leap Day as '" + prolepticYear + "' is not a leap year"); } return new InternationalFixedDate(prolepticYear, month, dayOfMonth); }
[ "static", "InternationalFixedDate", "create", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "YEAR_RANGE", ".", "checkValidValue", "(", "prolepticYear", ",", "ChronoField", ".", "YEAR_OF_ERA", ")", ";", "MONTH_OF_YEAR_RANGE", ".", "checkValidValue", "(", "month", ",", "ChronoField", ".", "MONTH_OF_YEAR", ")", ";", "DAY_OF_MONTH_RANGE", ".", "checkValidValue", "(", "dayOfMonth", ",", "ChronoField", ".", "DAY_OF_MONTH", ")", ";", "if", "(", "dayOfMonth", "==", "DAYS_IN_LONG_MONTH", "&&", "month", "!=", "6", "&&", "month", "!=", "MONTHS_IN_YEAR", ")", "{", "throw", "new", "DateTimeException", "(", "\"Invalid date: \"", "+", "prolepticYear", "+", "'", "'", "+", "month", "+", "'", "'", "+", "dayOfMonth", ")", ";", "}", "if", "(", "month", "==", "6", "&&", "dayOfMonth", "==", "DAYS_IN_LONG_MONTH", "&&", "!", "INSTANCE", ".", "isLeapYear", "(", "prolepticYear", ")", ")", "{", "throw", "new", "DateTimeException", "(", "\"Invalid Leap Day as '\"", "+", "prolepticYear", "+", "\"' is not a leap year\"", ")", ";", "}", "return", "new", "InternationalFixedDate", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Factory method, validates the given triplet year, month and dayOfMonth. @param prolepticYear the International fixed proleptic-year @param month the International fixed month, from 1 to 13 @param dayOfMonth the International fixed day-of-month, from 1 to 28 (29 for Leap Day or Year Day) @return the International fixed date @throws DateTimeException if the date is invalid
[ "Factory", "method", "validates", "the", "given", "triplet", "year", "month", "and", "dayOfMonth", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedDate.java#L335-L347
157,966
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/JulianChronology.java
JulianChronology.date
@Override public JulianDate date(int prolepticYear, int month, int dayOfMonth) { return JulianDate.of(prolepticYear, month, dayOfMonth); }
java
@Override public JulianDate date(int prolepticYear, int month, int dayOfMonth) { return JulianDate.of(prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "JulianDate", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "JulianDate", ".", "of", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Julian calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the Julian local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Julian", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/JulianChronology.java#L185-L188
157,967
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/JulianChronology.java
JulianChronology.dateYearDay
@Override public JulianDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public JulianDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "JulianDate", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in Julian calendar system from the era, year-of-era and day-of-year fields. @param era the Julian era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the Julian local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code JulianEra}
[ "Obtains", "a", "local", "date", "in", "Julian", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/JulianChronology.java#L201-L204
157,968
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/JulianChronology.java
JulianChronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<JulianDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<JulianDate>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<JulianDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<JulianDate>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "JulianDate", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "JulianDate", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Julian local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Julian local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Julian", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/JulianChronology.java#L304-L308
157,969
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/JulianChronology.java
JulianChronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<JulianDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<JulianDate>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<JulianDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<JulianDate>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "JulianDate", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "JulianDate", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Julian zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Julian zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Julian", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/JulianChronology.java#L317-L321
157,970
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java
Symmetry454Chronology.date
@Override public Symmetry454Date date(int prolepticYear, int month, int dayOfMonth) { return Symmetry454Date.of(prolepticYear, month, dayOfMonth); }
java
@Override public Symmetry454Date date(int prolepticYear, int month, int dayOfMonth) { return Symmetry454Date.of(prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "Symmetry454Date", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "Symmetry454Date", ".", "of", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Symmetry454 calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the Symmetry454 local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Symmetry454", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java#L264-L267
157,971
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java
Symmetry454Chronology.dateYearDay
@Override public Symmetry454Date dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public Symmetry454Date dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "Symmetry454Date", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in Symmetry454 calendar system from the era, year-of-era and day-of-year fields. @param era the Symmetry454 era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the Symmetry454 local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code IsoEra}
[ "Obtains", "a", "local", "date", "in", "Symmetry454", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java#L280-L283
157,972
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java
Symmetry454Chronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<Symmetry454Date> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<Symmetry454Date>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<Symmetry454Date> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<Symmetry454Date>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "Symmetry454Date", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "Symmetry454Date", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Symmetry454 local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Symmetry454 local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Symmetry454", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java#L383-L387
157,973
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java
Symmetry454Chronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<Symmetry454Date> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<Symmetry454Date>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<Symmetry454Date> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<Symmetry454Date>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "Symmetry454Date", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "Symmetry454Date", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Symmetry454 zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Symmetry454 zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Symmetry454", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java#L396-L400
157,974
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java
Symmetry010Chronology.date
@Override public Symmetry010Date date(int prolepticYear, int month, int dayOfMonth) { return Symmetry010Date.of(prolepticYear, month, dayOfMonth); }
java
@Override public Symmetry010Date date(int prolepticYear, int month, int dayOfMonth) { return Symmetry010Date.of(prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "Symmetry010Date", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "Symmetry010Date", ".", "of", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Symmetry010 calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the Symmetry010 local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Symmetry010", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java#L271-L274
157,975
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java
Symmetry010Chronology.dateYearDay
@Override public Symmetry010Date dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public Symmetry010Date dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "Symmetry010Date", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in Symmetry010 calendar system from the era, year-of-era and day-of-year fields. @param era the Symmetry010 era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the Symmetry010 local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code IsoEra}
[ "Obtains", "a", "local", "date", "in", "Symmetry010", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java#L287-L290
157,976
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java
Symmetry010Chronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<Symmetry010Date> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<Symmetry010Date>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<Symmetry010Date> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<Symmetry010Date>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "Symmetry010Date", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "Symmetry010Date", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Symmetry010 local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Symmetry010 local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Symmetry010", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java#L390-L394
157,977
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java
Symmetry010Chronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<Symmetry010Date> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<Symmetry010Date>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<Symmetry010Date> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<Symmetry010Date>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "Symmetry010Date", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "Symmetry010Date", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Symmetry010 zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Symmetry010 zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Symmetry010", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java#L403-L407
157,978
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/PaxChronology.java
PaxChronology.date
@Override public PaxDate date(int prolepticYear, int month, int dayOfMonth) { return PaxDate.of(prolepticYear, month, dayOfMonth); }
java
@Override public PaxDate date(int prolepticYear, int month, int dayOfMonth) { return PaxDate.of(prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "PaxDate", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "PaxDate", ".", "of", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Pax calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the Pax local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Pax", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/PaxChronology.java#L221-L224
157,979
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/PaxChronology.java
PaxChronology.dateYearDay
@Override public PaxDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public PaxDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "PaxDate", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in Pax calendar system from the era, year-of-era and day-of-year fields. @param era the Pax era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the Pax local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code PaxEra}
[ "Obtains", "a", "local", "date", "in", "Pax", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/PaxChronology.java#L237-L240
157,980
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/PaxChronology.java
PaxChronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<PaxDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<PaxDate>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<PaxDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<PaxDate>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "PaxDate", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "PaxDate", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Pax local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Pax local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Pax", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/PaxChronology.java#L340-L344
157,981
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/PaxChronology.java
PaxChronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<PaxDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<PaxDate>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<PaxDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<PaxDate>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "PaxDate", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "PaxDate", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Pax zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Pax zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Pax", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/PaxChronology.java#L353-L357
157,982
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/EthiopicChronology.java
EthiopicChronology.date
@Override public EthiopicDate date(Era era, int yearOfEra, int month, int dayOfMonth) { return date(prolepticYear(era, yearOfEra), month, dayOfMonth); }
java
@Override public EthiopicDate date(Era era, int yearOfEra, int month, int dayOfMonth) { return date(prolepticYear(era, yearOfEra), month, dayOfMonth); }
[ "@", "Override", "public", "EthiopicDate", "date", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "date", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Ethiopic calendar system from the era, year-of-era, month-of-year and day-of-month fields. @param era the Ethiopic era, not null @param yearOfEra the year-of-era @param month the month-of-year @param dayOfMonth the day-of-month @return the Ethiopic local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code EthiopicEra}
[ "Obtains", "a", "local", "date", "in", "Ethiopic", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L152-L155
157,983
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/EthiopicChronology.java
EthiopicChronology.date
@Override public EthiopicDate date(int prolepticYear, int month, int dayOfMonth) { return EthiopicDate.of(prolepticYear, month, dayOfMonth); }
java
@Override public EthiopicDate date(int prolepticYear, int month, int dayOfMonth) { return EthiopicDate.of(prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "EthiopicDate", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "EthiopicDate", ".", "of", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Ethiopic calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the Ethiopic local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Ethiopic", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L167-L170
157,984
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/EthiopicChronology.java
EthiopicChronology.dateYearDay
@Override public EthiopicDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public EthiopicDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "EthiopicDate", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in Ethiopic calendar system from the era, year-of-era and day-of-year fields. @param era the Ethiopic era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the Ethiopic local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code EthiopicEra}
[ "Obtains", "a", "local", "date", "in", "Ethiopic", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L183-L186
157,985
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/EthiopicChronology.java
EthiopicChronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<EthiopicDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<EthiopicDate>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<EthiopicDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<EthiopicDate>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "EthiopicDate", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "EthiopicDate", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Ethiopic local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Ethiopic local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Ethiopic", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L286-L290
157,986
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/EthiopicChronology.java
EthiopicChronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<EthiopicDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<EthiopicDate>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<EthiopicDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<EthiopicDate>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "EthiopicDate", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "EthiopicDate", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Ethiopic zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Ethiopic zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Ethiopic", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L299-L303
157,987
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/DiscordianChronology.java
DiscordianChronology.date
@Override public DiscordianDate date(int prolepticYear, int month, int dayOfMonth) { return DiscordianDate.of(prolepticYear, month, dayOfMonth); }
java
@Override public DiscordianDate date(int prolepticYear, int month, int dayOfMonth) { return DiscordianDate.of(prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "DiscordianDate", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "DiscordianDate", ".", "of", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in Discordian calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the Discordian local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Discordian", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/DiscordianChronology.java#L229-L232
157,988
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/DiscordianChronology.java
DiscordianChronology.dateYearDay
@Override public DiscordianDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public DiscordianDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "DiscordianDate", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in Discordian calendar system from the era, year-of-era and day-of-year fields. @param era the Discordian era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the Discordian local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code DiscordianEra}
[ "Obtains", "a", "local", "date", "in", "Discordian", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/DiscordianChronology.java#L245-L248
157,989
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/DiscordianChronology.java
DiscordianChronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<DiscordianDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<DiscordianDate>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<DiscordianDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<DiscordianDate>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "DiscordianDate", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "DiscordianDate", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Discordian local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Discordian local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Discordian", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/DiscordianChronology.java#L348-L352
157,990
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/DiscordianChronology.java
DiscordianChronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<DiscordianDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<DiscordianDate>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<DiscordianDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<DiscordianDate>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "DiscordianDate", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "DiscordianDate", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a Discordian zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the Discordian zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "Discordian", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/DiscordianChronology.java#L361-L365
157,991
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java
InternationalFixedChronology.date
@Override public InternationalFixedDate date(int prolepticYear, int month, int dayOfMonth) { return InternationalFixedDate.of(prolepticYear, month, dayOfMonth); }
java
@Override public InternationalFixedDate date(int prolepticYear, int month, int dayOfMonth) { return InternationalFixedDate.of(prolepticYear, month, dayOfMonth); }
[ "@", "Override", "public", "InternationalFixedDate", "date", "(", "int", "prolepticYear", ",", "int", "month", ",", "int", "dayOfMonth", ")", "{", "return", "InternationalFixedDate", ".", "of", "(", "prolepticYear", ",", "month", ",", "dayOfMonth", ")", ";", "}" ]
Obtains a local date in International Fixed calendar system from the proleptic-year, month-of-year and day-of-month fields. @param prolepticYear the proleptic-year @param month the month-of-year @param dayOfMonth the day-of-month @return the International Fixed local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "International", "Fixed", "calendar", "system", "from", "the", "proleptic", "-", "year", "month", "-", "of", "-", "year", "and", "day", "-", "of", "-", "month", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java#L239-L242
157,992
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java
InternationalFixedChronology.dateYearDay
@Override public InternationalFixedDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
java
@Override public InternationalFixedDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); }
[ "@", "Override", "public", "InternationalFixedDate", "dateYearDay", "(", "Era", "era", ",", "int", "yearOfEra", ",", "int", "dayOfYear", ")", "{", "return", "dateYearDay", "(", "prolepticYear", "(", "era", ",", "yearOfEra", ")", ",", "dayOfYear", ")", ";", "}" ]
Obtains a local date in International Fixed calendar system from the era, year-of-era and day-of-year fields. @param era the International Fixed era, not null @param yearOfEra the year-of-era @param dayOfYear the day-of-year @return the International Fixed local date, not null @throws DateTimeException if unable to create the date @throws ClassCastException if the {@code era} is not a {@code InternationalFixedEra}
[ "Obtains", "a", "local", "date", "in", "International", "Fixed", "calendar", "system", "from", "the", "era", "year", "-", "of", "-", "era", "and", "day", "-", "of", "-", "year", "fields", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java#L255-L258
157,993
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java
InternationalFixedChronology.localDateTime
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<InternationalFixedDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<InternationalFixedDate>) super.localDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoLocalDateTime<InternationalFixedDate> localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime<InternationalFixedDate>) super.localDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoLocalDateTime", "<", "InternationalFixedDate", ">", "localDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoLocalDateTime", "<", "InternationalFixedDate", ">", ")", "super", ".", "localDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a International Fixed local date-time from another date-time object. @param temporal the date-time object to convert, not null @return the International Fixed local date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "International", "Fixed", "local", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java#L358-L362
157,994
ThreeTen/threeten-extra
src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java
InternationalFixedChronology.zonedDateTime
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<InternationalFixedDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<InternationalFixedDate>) super.zonedDateTime(temporal); }
java
@Override @SuppressWarnings("unchecked") public ChronoZonedDateTime<InternationalFixedDate> zonedDateTime(TemporalAccessor temporal) { return (ChronoZonedDateTime<InternationalFixedDate>) super.zonedDateTime(temporal); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ChronoZonedDateTime", "<", "InternationalFixedDate", ">", "zonedDateTime", "(", "TemporalAccessor", "temporal", ")", "{", "return", "(", "ChronoZonedDateTime", "<", "InternationalFixedDate", ">", ")", "super", ".", "zonedDateTime", "(", "temporal", ")", ";", "}" ]
Obtains a International Fixed zoned date-time from another date-time object. @param temporal the date-time object to convert, not null @return the International Fixed zoned date-time, not null @throws DateTimeException if unable to create the date-time
[ "Obtains", "a", "International", "Fixed", "zoned", "date", "-", "time", "from", "another", "date", "-", "time", "object", "." ]
e94ecd3592ef70e54d6eea21095239ea9ffbab78
https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java#L371-L375
157,995
rterp/GMapsFX
GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java
GoogleMap.boundsProperty
public final ReadOnlyObjectProperty<LatLongBounds> boundsProperty() { if (bounds == null) { bounds = new ReadOnlyObjectWrapper<>(getBounds()); addStateEventHandler(MapStateEventType.idle, () -> { bounds.set(getBounds()); }); } return bounds.getReadOnlyProperty(); }
java
public final ReadOnlyObjectProperty<LatLongBounds> boundsProperty() { if (bounds == null) { bounds = new ReadOnlyObjectWrapper<>(getBounds()); addStateEventHandler(MapStateEventType.idle, () -> { bounds.set(getBounds()); }); } return bounds.getReadOnlyProperty(); }
[ "public", "final", "ReadOnlyObjectProperty", "<", "LatLongBounds", ">", "boundsProperty", "(", ")", "{", "if", "(", "bounds", "==", "null", ")", "{", "bounds", "=", "new", "ReadOnlyObjectWrapper", "<>", "(", "getBounds", "(", ")", ")", ";", "addStateEventHandler", "(", "MapStateEventType", ".", "idle", ",", "(", ")", "->", "{", "bounds", ".", "set", "(", "getBounds", "(", ")", ")", ";", "}", ")", ";", "}", "return", "bounds", ".", "getReadOnlyProperty", "(", ")", ";", "}" ]
A property tied to the map, updated when the idle state event is fired. @return
[ "A", "property", "tied", "to", "the", "map", "updated", "when", "the", "idle", "state", "event", "is", "fired", "." ]
4623d3f768e8ad78fc50ee32dd204d236e01059f
https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java#L179-L187
157,996
rterp/GMapsFX
GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java
GoogleMap.addMarker
public void addMarker(Marker marker) { if (markers == null) { markers = new HashSet<>(); } markers.add(marker); marker.setMap(this); }
java
public void addMarker(Marker marker) { if (markers == null) { markers = new HashSet<>(); } markers.add(marker); marker.setMap(this); }
[ "public", "void", "addMarker", "(", "Marker", "marker", ")", "{", "if", "(", "markers", "==", "null", ")", "{", "markers", "=", "new", "HashSet", "<>", "(", ")", ";", "}", "markers", ".", "add", "(", "marker", ")", ";", "marker", ".", "setMap", "(", "this", ")", ";", "}" ]
Adds the supplied marker to the map. @param marker
[ "Adds", "the", "supplied", "marker", "to", "the", "map", "." ]
4623d3f768e8ad78fc50ee32dd204d236e01059f
https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java#L202-L208
157,997
rterp/GMapsFX
GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java
GoogleMap.removeMarker
public void removeMarker(Marker marker) { if (markers != null && markers.contains(marker)) { markers.remove(marker); } marker.setMap(null); }
java
public void removeMarker(Marker marker) { if (markers != null && markers.contains(marker)) { markers.remove(marker); } marker.setMap(null); }
[ "public", "void", "removeMarker", "(", "Marker", "marker", ")", "{", "if", "(", "markers", "!=", "null", "&&", "markers", ".", "contains", "(", "marker", ")", ")", "{", "markers", ".", "remove", "(", "marker", ")", ";", "}", "marker", ".", "setMap", "(", "null", ")", ";", "}" ]
Removes the supplied marker from the map. @param marker
[ "Removes", "the", "supplied", "marker", "from", "the", "map", "." ]
4623d3f768e8ad78fc50ee32dd204d236e01059f
https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java#L215-L220
157,998
rterp/GMapsFX
GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java
GoogleMap.clearMarkers
public void clearMarkers() { if (markers != null && !markers.isEmpty()) { markers.forEach((m) -> { m.setMap(null); }); markers.clear(); }
java
public void clearMarkers() { if (markers != null && !markers.isEmpty()) { markers.forEach((m) -> { m.setMap(null); }); markers.clear(); }
[ "public", "void", "clearMarkers", "(", ")", "{", "if", "(", "markers", "!=", "null", "&&", "!", "markers", ".", "isEmpty", "(", ")", ")", "{", "markers", ".", "forEach", "(", "(", "m", ")", "-", ">", "{", "m", ".", "setMap", "(", "null", ")", "", ";", "}", ")", ";", "markers", ".", "clear", "(", ")", ";", "}" ]
Removes all of the markers from the map.
[ "Removes", "all", "of", "the", "markers", "from", "the", "map", "." ]
4623d3f768e8ad78fc50ee32dd204d236e01059f
https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java#L226-L232
157,999
rterp/GMapsFX
GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java
JavascriptObject.setProperty
protected void setProperty(String propertyName, JavascriptObject propertyValue) { jsObject.setMember(propertyName, propertyValue.getJSObject()); }
java
protected void setProperty(String propertyName, JavascriptObject propertyValue) { jsObject.setMember(propertyName, propertyValue.getJSObject()); }
[ "protected", "void", "setProperty", "(", "String", "propertyName", ",", "JavascriptObject", "propertyValue", ")", "{", "jsObject", ".", "setMember", "(", "propertyName", ",", "propertyValue", ".", "getJSObject", "(", ")", ")", ";", "}" ]
Sets a property on this Javascript object for which the value is a Javascript object itself. @param propertyName The name of the property. @param propertyValue The value of the property.
[ "Sets", "a", "property", "on", "this", "Javascript", "object", "for", "which", "the", "value", "is", "a", "Javascript", "object", "itself", "." ]
4623d3f768e8ad78fc50ee32dd204d236e01059f
https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java#L156-L158