public boolean tryGetIdFromInstance(Object entity, Reference<String> idHolder) {
        if (entity == null) {
            throw new IllegalArgumentException("Entity cannot be null");
        }
        try {
            Field identityProperty = getIdentityProperty(entity.getClass());
            if (identityProperty != null) {
                Object value = FieldUtils.readField(identityProperty, entity, true);
                if (value instanceof String) {
                    idHolder.value = (String)value;
                    return true;
                }
            }
            idHolder.value = null;
            return false;
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        }
    }
public boolean tryGetIdFromInstance ( Object entity , Reference < String > idHolder ) { if ( entity == null ) { throw new IllegalArgumentException ( "Entity cannot be null" ) ; } try { Field identityProperty = getIdentityProperty ( entity . getClass ( ) ) ; if ( identityProperty != null ) { Object value = FieldUtils . readField ( identityProperty , entity , true ) ; if ( value instanceof String ) { idHolder . value = ( String ) value ; return true ; } } idHolder . value = null ; return false ; } catch ( IllegalAccessException e ) { throw new IllegalStateException ( e ) ; } }
Attempts to get the document key from an instance
@param entity Entity to get id from
@param idHolder output parameter which holds document id
@return true if id was read from entity