mirror of
				https://github.com/spring-projects/spring-data-elasticsearch.git
				synced 2025-10-30 22:28:47 +00:00 
			
		
		
		
	Internal refactoring stringRepresentation/convertId.
Original Pull Request #2312 Closes #2228
This commit is contained in:
		
							parent
							
								
									8a1d8deb67
								
							
						
					
					
						commit
						05c6444b71
					
				| @ -531,11 +531,7 @@ public abstract class AbstractElasticsearchTemplate implements ElasticsearchOper | ||||
| 		Object id = entityOperations.forEntity(entity, elasticsearchConverter.getConversionService(), routingResolver) | ||||
| 				.getId(); | ||||
| 
 | ||||
| 		if (id != null) { | ||||
| 			return stringIdRepresentation(id); | ||||
| 		} | ||||
| 
 | ||||
| 		return null; | ||||
| 		return convertId(id); | ||||
| 	} | ||||
| 
 | ||||
| 	@Nullable | ||||
|  | ||||
| @ -80,13 +80,28 @@ public interface ElasticsearchOperations extends DocumentOperations, SearchOpera | ||||
| 	 * gets the String representation for an id. | ||||
| 	 * | ||||
| 	 * @param id | ||||
| 	 * @return | ||||
| 	 * @return String representation | ||||
| 	 * @since 4.0 | ||||
| 	 * @deprecated since 5.0, use {@link ElasticsearchOperations#convertId(Object)}. | ||||
| 	 */ | ||||
| 	@Deprecated | ||||
| 	@Nullable | ||||
| 	default String stringIdRepresentation(@Nullable Object id) { | ||||
| 		return Objects.toString(id, null); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Converts an idValue to a String representation. The default implementation calls | ||||
| 	 * {@link ElasticsearchConverter#convertId(Object)} | ||||
| 	 * | ||||
| 	 * @param idValue the value to convert | ||||
| 	 * @return the converted value or {@literal null} if idValue is null | ||||
| 	 * @since 5.0 | ||||
| 	 */ | ||||
| 	@Nullable | ||||
| 	default String convertId(@Nullable Object idValue) { | ||||
| 		return idValue != null ? getElasticsearchConverter().convertId(idValue) : null; | ||||
| 	} | ||||
| 	// endregion | ||||
| 
 | ||||
| 	// region routing | ||||
|  | ||||
| @ -313,7 +313,7 @@ public class SimpleElasticsearchRepository<T, ID> implements ElasticsearchReposi | ||||
| 	} | ||||
| 
 | ||||
| 	protected @Nullable String stringIdRepresentation(@Nullable ID id) { | ||||
| 		return operations.stringIdRepresentation(id); | ||||
| 		return operations.convertId(id); | ||||
| 	} | ||||
| 
 | ||||
| 	private IndexCoordinates getIndexCoordinates() { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user