If/else produce code duplication
Keep it like that. It is perfectly readable, easy to understand, everything is fine.
Naturally you could do some lambda trickery along the lines of:
public static String extractFromMessageOrQuery(
       Update update,
       Function&lt;Update, String&gt; messageExtractor,
       Function&lt;Update, String&gt; queryExtractor,
       String defaultValue) {
   if (updateHasMessage)
       return messageExtractor.apply(update);
   else if (updateHashCallbackQuery(update))
       return queryExtractor.apply(update);
   return defaultValue;
}

public static String getInputUserData(Update update) {
    return extractFromMessageOrQuery(
        upd -&gt; upd.getMessage().getText(),
        upd -&gt; upd.getCallbackQuery().getData(),
        null
    );
}

But: would that make the code

easier to understand? No
easier to extend? No
easier to maintain? No

Thus: take note that these possibilities exist, and keep the code as-is.