Returns the value for the given key if the value is present and not null. Otherwise, returns the result of the defaultValue function.