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) | 		Object id = entityOperations.forEntity(entity, elasticsearchConverter.getConversionService(), routingResolver) | ||||||
| 				.getId(); | 				.getId(); | ||||||
| 
 | 
 | ||||||
| 		if (id != null) { | 		return convertId(id); | ||||||
| 			return stringIdRepresentation(id); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		return null; |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Nullable | 	@Nullable | ||||||
|  | |||||||
| @ -80,13 +80,28 @@ public interface ElasticsearchOperations extends DocumentOperations, SearchOpera | |||||||
| 	 * gets the String representation for an id. | 	 * gets the String representation for an id. | ||||||
| 	 * | 	 * | ||||||
| 	 * @param id | 	 * @param id | ||||||
| 	 * @return | 	 * @return String representation | ||||||
| 	 * @since 4.0 | 	 * @since 4.0 | ||||||
|  | 	 * @deprecated since 5.0, use {@link ElasticsearchOperations#convertId(Object)}. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	@Nullable | 	@Nullable | ||||||
| 	default String stringIdRepresentation(@Nullable Object id) { | 	default String stringIdRepresentation(@Nullable Object id) { | ||||||
| 		return Objects.toString(id, null); | 		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 | 	// endregion | ||||||
| 
 | 
 | ||||||
| 	// region routing | 	// region routing | ||||||
|  | |||||||
| @ -313,7 +313,7 @@ public class SimpleElasticsearchRepository<T, ID> implements ElasticsearchReposi | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	protected @Nullable String stringIdRepresentation(@Nullable ID id) { | 	protected @Nullable String stringIdRepresentation(@Nullable ID id) { | ||||||
| 		return operations.stringIdRepresentation(id); | 		return operations.convertId(id); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private IndexCoordinates getIndexCoordinates() { | 	private IndexCoordinates getIndexCoordinates() { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user