コード例 #1
0
 public SmartNameObjectMapper smartNameObjectMapper(String smartName, @Nullable String[] types) {
   if (types == null || types.length == 0) {
     return smartNameObjectMapper(smartName);
   }
   if (types.length == 1 && types[0].equals("_all")) {
     return smartNameObjectMapper(smartName);
   }
   for (String type : types) {
     DocumentMapper possibleDocMapper = mappers.get(type);
     if (possibleDocMapper != null) {
       ObjectMapper mapper = possibleDocMapper.objectMappers().get(smartName);
       if (mapper != null) {
         return new SmartNameObjectMapper(mapper, possibleDocMapper);
       }
     }
   }
   // did not find one, see if its prefixed by type
   int dotIndex = smartName.indexOf('.');
   if (dotIndex != -1) {
     String possibleType = smartName.substring(0, dotIndex);
     DocumentMapper possibleDocMapper = mappers.get(possibleType);
     if (possibleDocMapper != null) {
       String possiblePath = smartName.substring(dotIndex + 1);
       ObjectMapper mapper = possibleDocMapper.objectMappers().get(possiblePath);
       if (mapper != null) {
         return new SmartNameObjectMapper(mapper, possibleDocMapper);
       }
     }
   }
   // did not explicitly find one under the types provided, or prefixed by type...
   return null;
 }
コード例 #2
0
 public SmartNameObjectMapper smartNameObjectMapper(String smartName) {
   int dotIndex = smartName.indexOf('.');
   if (dotIndex != -1) {
     String possibleType = smartName.substring(0, dotIndex);
     DocumentMapper possibleDocMapper = mappers.get(possibleType);
     if (possibleDocMapper != null) {
       String possiblePath = smartName.substring(dotIndex + 1);
       ObjectMapper mapper = possibleDocMapper.objectMappers().get(possiblePath);
       if (mapper != null) {
         return new SmartNameObjectMapper(mapper, possibleDocMapper);
       }
     }
   }
   ObjectMappers mappers = objectMapper(smartName);
   if (mappers != null) {
     return new SmartNameObjectMapper(mappers.mapper(), null);
   }
   return null;
 }
コード例 #3
0
  private void removeObjectAndFieldMappers(DocumentMapper docMapper) {
    synchronized (mappersMutex) {
      fieldMappers.removeMappers(docMapper.mappers());

      ImmutableOpenMap.Builder<String, ObjectMappers> fullPathObjectMappers =
          ImmutableOpenMap.builder(this.fullPathObjectMappers);
      for (ObjectMapper mapper : docMapper.objectMappers().values()) {
        ObjectMappers mappers = fullPathObjectMappers.get(mapper.fullPath());
        if (mappers != null) {
          mappers = mappers.remove(mapper);
          if (mappers.isEmpty()) {
            fullPathObjectMappers.remove(mapper.fullPath());
          } else {
            fullPathObjectMappers.put(mapper.fullPath(), mappers);
          }
        }
      }

      this.fullPathObjectMappers = fullPathObjectMappers.build();
    }
  }