コード例 #1
0
 private void removeSubdocumentValue(
     Object document, String key, AtomicReference<Integer> matchPos) throws MongoServerException {
   int dotPos = key.indexOf('.');
   if (dotPos > 0) {
     String mainKey = key.substring(0, dotPos);
     String subKey = getSubkey(key, dotPos, matchPos);
     Object subObject = Utils.getListSafe(document, mainKey);
     if (subObject instanceof BSONObject || subObject instanceof List<?>) {
       removeSubdocumentValue(subObject, subKey, matchPos);
     } else {
       throw new MongoServerException("failed to remove subdocument");
     }
   } else {
     Utils.removeListSafe(document, key);
   }
 }