Tag: Generics
Posts of Tag: Generics
Posts of Tag: Generics
problem with a HashSet's Iterator
I'm trying to see if HashSet would be the solution for my next project so i'm doing some very easy test to check functionalities. I have a simple class Klant: public class Klant { private int klantNummer; ...Learn MoreJavaGenericsiteratorhashsetdowncastingHow to set a struct value T from Type
I'm using the extension from Joel's string-to-nullable-type answer here: public static Nullable<T> ToNullable<T>(this string s) where T: struct { Nullable<T> result...Learn MoreC#GenericsWhy should I replace CollectionBase with Generics?
I'm not looking for how, I'm looking for why? I couldn't find a straight forward answer to this. ...Learn MoreC#.NETGenericsCollectionsScala: Handy implicit
Whenever I get a chance to work in Scala, I always love its simplicity like Python, handiness like Perl, and running like Java. Scala’s implicit ways are another way of writing syntactical sugary flavors of wr...Learn MoreNewsScalaGenericsResultsetScala ImplicitsCamel CaseJava generics, how do you say it when reading code out loud?
Just wondering, how would you read out loud the following items using generic types? 1) class Box<T> 2) Box<Integer> integerBox 3) class Box<T,U> ...Learn MoreJavaGenericsGenerifying with "super"
I would like to write an Interator like this: class Plant { } class Tree extends Plant { } class Maple extends Tree { } // Iterator class: compiler error on the word "super". class MyIterator<T super Ma...Learn MoreJavaGenericsConfiguring Checkstyle to ignore generic warnings
I'm working on a project and using checkstyle to validate the javadocs for the project. I do not want any checkstyle javadoc warnings. However checkstyle is giving me the following unwanted warning to do with ...Learn MoreJavaGenericsjavadocsuppress-warningscheckstyleImplementation of Lazy<T> for .NET 3.5
.NET 4.0 has a nice utility class called System.Lazy that does lazy object initialization. I would like to use this class for a 3.5 project. One time I saw an implementation somewhere in a stackoverflow answer ...Learn MoreC#Genericslazy-loadingJava: How to pass a class to a function for instantiation
Please forgive my ignorance, but I wasn't able to find an answer elsewhere. I have the following code: int value = 5; Strategy s = new Strategy(convert(value)); mainClass.setStuff(s, value); The Strategy is in...Learn MoreJavaGenericsTemplatesHow to write the constraints for a generic class
There is a generic class XXValue like this, where the Type T can be value type or reference type, e.g int, string, struct object public class XXValue<T> { public T DefaultValue; } And there i...Learn MoreC#GenericsWhy does ICollection<T> implement both IEnumerable<T> and IEnumerable
Why does ICollection<T> implement both IEnumerable<T> and IEnumerable? What is the purpose of this? How does IEnumerable benefit ICollection<T>? ...Learn MoreC#GenericsCollectionsdesign-patternsienumerableSpring MVC: How to return different type in ResponseEntity body
In my request handler I want to do some validation and based on the outcome of validation check I will return different response (success/error). So I create a abstract class for the response object and make 2 ...Learn MoreJavaSpringGenericsspring-mvc