In Java 8 you can use Math.toIntExact. If you want to handle null values, use:
Integer intVal = longVal == null ? null : Math.toIntExact(longVal);
Good thing about this method is that it throws an ArithmeticException if the argument (long) overflows an int.