<commit_before>package fr.openwide.core.hibernate.more.search.bridge;

import org.apache.lucene.document.Document;
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.LuceneOptions;

import fr.openwide.core.hibernate.more.business.generic.model.GenericListItem;

public class GenericListItemIdFieldBridge implements FieldBridge {
	
	private static final String ID_SUFFIX = "_id";
	
	@Override
	public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
		if (!(value instanceof GenericListItem)) {
			throw new IllegalArgumentException("This FieldBridge only supports GenericListItem properties.");
		}
		GenericListItem<?> listitem = (GenericListItem<?>) value;
		
		luceneOptions.addFieldToDocument(getFieldName(name), listitem.getId().toString(), document);
	}
	
	public static String getFieldName(String name) {
		return name + ID_SUFFIX;
	}

}<commit_msg>il faut également implémenter StringBridge pour que les bridges fonctionnent quand on construit les requêtes de recherche<commit_after>package fr.openwide.core.hibernate.more.search.bridge;

import org.apache.lucene.document.Document;
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.LuceneOptions;
import org.hibernate.search.bridge.StringBridge;

import fr.openwide.core.hibernate.more.business.generic.model.GenericListItem;

public class GenericListItemIdFieldBridge implements FieldBridge, StringBridge {
	
	@Override
	public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
		if (!(value instanceof GenericListItem)) {
			throw new IllegalArgumentException("This FieldBridge only supports GenericListItem properties.");
		}
		GenericListItem<?> listItem = (GenericListItem<?>) value;
		
		luceneOptions.addFieldToDocument(name, listItem.getId().toString(), document);
	}
	
	@Override
	public String objectToString(Object object) {
		if (!(object instanceof GenericListItem)) {
			throw new IllegalArgumentException("This FieldBridge only supports GenericListItem properties.");
		}
		GenericListItem<?> listItem = (GenericListItem<?>) object;
		return listItem.getId().toString();
	}
	
}
{'fraction_non_alphanumeric': 0.09639104613978985, 'fraction_numerical': 0.0, 'mean_word_length': 6.133550488599348, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5113030', 'n_tokens_mistral': 647, 'n_tokens_neox': 580, 'n_words': 146}