std::lexical_cast – is there such a thing?

Only partially. C++11 <string> has std::to_string for the built-in types: [n3290: 21.5/7]: string to_string(int val); string to_string(unsigned val); string to_string(long val); string to_string(unsigned long val); string to_string(long long val); string to_string(unsigned long long val); string to_string(float val); string to_string(double val); string to_string(long double val); Returns: Each function returns a string object holding the character representation … Read more

Java casting in interfaces

When you cast o1 and o3 with (I2), you tell the compiler that the class of the object is actually a subclass of its declared type, and that this subclass implements I2. The Integer class is final, so o3 cannot be an instance of a subclass of Integer: the compiler knows that you’re lying. C1 … Read more

MySQL: Typecasting NULL to 0

Use IFNULL(column, 0) to convert the column value to zero. Alternatively, the COALESCE function will do the same thing: COALESCE(column, 0), except COALESCE is ANSI-compliant, IFNULL is not COALESCE takes an arbitrary number of columns/values and will return the first non-null value passed to it.

Casting LinkedHashMap to Complex Object

You can use ObjectMapper.convertValue(), either value by value or even for the whole list. But you need to know the type to convert to: POJO pojo = mapper.convertValue(singleObject, POJO.class); // or: List<POJO> pojos = mapper.convertValue(listOfObjects, new TypeReference<List<POJO>>() { }); this is functionally same as if you did: byte[] json = mapper.writeValueAsBytes(singleObject); POJO pojo = mapper.readValue(json, … Read more

C# : ‘is’ keyword and checking for Not

if(!(child is IContainer)) is the only operator to go (there’s no IsNot operator). You can build an extension method that does it: public static bool IsA<T>(this object obj) { return obj is T; } and then use it to: if (!child.IsA<IContainer>()) And you could follow on your theme: public static bool IsNotAFreaking<T>(this object obj) { … Read more