Questions tagged [non-nullable]

232 questions
3
votes
2 answers

Marking optional member variable as NonNull

One of the String member variables of my class is Optional. Does it makes sense to mark it with Lombok annotation @NonNull ? I would like to ask the same question in case that member variable is Map instead of String. Will the answer change ?
Andy897
  • 6,915
  • 11
  • 51
  • 86
3
votes
0 answers

NonNull annotation - Illegal redefinition of parameter (Eclipse)

I am trying to use the Eclipse NonNull annotation, however I cannot understand the behaviour described below. I don't understand what Eclipse is complaining about.... Compiles/ Eclipse does not complain about anything: import…
Ueli Hofstetter
  • 2,409
  • 4
  • 29
  • 52
3
votes
1 answer

Nullable "scalar navigation properties" in EF 4.0: Mapping a non-nullable column from a separate database table to a nullable scalar entity property?

Using Entity Framework version 4.0 (or any other version that is compatible with .NET 4.0), I want to map this existing relational database schema: to this logical object model: which I have tried setting up as follows: (I hope the German captions…
3
votes
1 answer

Ensure a class in notnull in Scala?

Since the NotNull trait is being deprecated, what is the new best way to declare my classes not nullable? There is still the compiler option (does not prevent someone from misusing my libraries in other projects). Along with the handful of…
user833970
  • 2,729
  • 3
  • 26
  • 41
3
votes
0 answers

Emit Mapper "Nullable object must have a value"

I am using Emit Mapper to copy fields from InternalClass to ExternalClass. public class InternalClass { public int? Id { get; set; } public DateTime? RecordDate {get; set;} } public class ExternalClass { public int Id { get; set; } …
Adam
  • 4,590
  • 10
  • 51
  • 84
2
votes
1 answer

Automatic conversion of wrapper in C#

I've build wrapper-class intended to prevent reference types of being null, as a pre-condition code contract. public sealed class NotNullable where T : class { private T t; public static implicit operator NotNullable(T otherT) …
philipshield
  • 303
  • 2
  • 8
2
votes
1 answer

How to deal with warning 'unsafe null type convertion' when using java.lang.Optional

I would like to offer some accessors to a value-container (that is a java.lang.Map under the hood). When implementing accessors like this public Optional getSomeValueThatMayBeNullOrAnInteger() { Integer nullable =…
Sammy
  • 1,178
  • 1
  • 14
  • 27
2
votes
3 answers

The argument type 'Products Function(BuildContext, dynamic, dynamic)' can't be assigned to the parameter type 'Products Function(BuildContext)'

I am a new learner following a Flutter tutorial that is written in previous version and I get the following errors with this code: main.ts: void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget…
user11874694
2
votes
2 answers

Flutter error : "A value of type 'Null' can't be assigned to a variable of type 'Product'."

I have a code that is written for previous version of the Flutter and has some errors when I try to run in the new version. The following is one of the errors I don't know how to resolve? Future deleteProduct(String id) async { final url…
user11874694
2
votes
3 answers

Non-nullable instance field ['controller'] must be initialized in flutter

Good day! I am a new to Flutter to would like to start my Startup but I was trapped in this problem to make Tabbar example... I have almost been frustrated all day because of this problems.... Dart Analysis keeps saying this below.... Non-nullable…
2
votes
3 answers

Declaring a variable without initializing it flutter

I want to declare a static variable and initialize it in the following function, but get the error: "The non-nullable variable 'screenWidth' must be initialized." Code: import 'package:flutter/material.dart'; class SizeConfig { static…
2
votes
2 answers

How to make typescript throw runtime error on failed non-null assertion?

Is there a setting to make typescript compile non-null assertions into javascript that throws an error? By default the non-null assertion is discarded (playground): // Typescript: function foo(o: {[k: string]: string}) { return "x is " +…
Luke Miles
  • 941
  • 9
  • 19
2
votes
1 answer

What does Nullable Annotation exactly mean?

In Visual Studio 2019 I can set the Nullable Option in the Build-Properties to Annotation. When I read in the docs for this settings: Variables of a reference type, string for example, are non-nullable. All nullability warnings are disabled. Now I…
BennoDual
  • 5,865
  • 15
  • 67
  • 153
2
votes
3 answers

In Dart, given the nullable type `T?`, how do I get the non-nullable one `T`

Given some nullable type T?, how do I get the corresponding non-nullable one T ? For example: T? x(T? value) => value; Type g(T Function(T) t) => T; Type type = g(x); print(type); // Prints "int?" Now I want to get the…
Marcelo Glasberg
  • 29,013
  • 23
  • 109
  • 133
2
votes
1 answer

I want Json.NET to fail deserializing a missing or undefined value type

In the code below, I want both DeserializeObject calls to throw an exception. public class MyObj { public int MyInt { get; set; } } static void Main(string[] args) { var jsonString = "{ }"; var obj =…
Lee
  • 1,591
  • 1
  • 14
  • 28