Esempio n. 1
0
 <F> Field buildField(SearchMetadata<T, K> metadata, String field, Object value) {
   com.google.appengine.api.search.Field.Builder fieldBuilder =
       Field.newBuilder().setName(metadata.getEncodedFieldName(field));
   IndexType indexType = metadata.getIndexType(field);
   FieldMediator<F> fieldMediator = fieldMediators.get(indexType);
   F normalised = fieldMediator.normalise(transformerManager, value);
   fieldMediator.setValue(fieldBuilder, normalised);
   return fieldBuilder.build();
 }
Esempio n. 2
0
 private <V> String convertSingleValueToString(
     String field, Object value, SearchMetadata<T, ?> metadata, FieldMediator<V> fieldMediator) {
   try {
     V normalised = fieldMediator.normalise(transformerManager, value);
     return fieldMediator.stringify(normalised);
   } catch (Exception e) {
     throw new SearchException(
         "Cannot query the field %s %s - cannot convert the query value %s %s to a %s. You can register extra conversions using the %s",
         metadata.getFieldType(field).getSimpleName(),
         field,
         value.getClass().getSimpleName(),
         value,
         fieldMediator.getTargetType().getSimpleName(),
         TransformerManager.class.getSimpleName());
   }
 }