I know this question will probably provoke more discussion than concrete answers (which I know isn't preferable). But with the recent acquisition by Oracle, I was wondering if there's been any word that Java might (someday) get reified generics? I've heard that Oracle wants to give Java a bit of a boost, and I can think of no better wa...
HI,
I have a generic function as shown below. It can be used to show a form by calling
showForm(ch);
IT works for the second function (new without parameter) ,But if I want to show form but with parameter in the constructor as in the third function (new with parameter) ,then I could not do it .Any one has an idea how to do it?
...
I'm having to grab API-provided JSON for a project of mine, and that means deserialising JSON using a class, and I've chosen to go with DataContract classes. In any case, different URLs correspond to different JSON outputs for the API.
So what am I asking? It's to see if there's any better way to have URLs corresponding to the DataContr...
Is there any way to do code such this:
class GenericClass<T>
{
void functionA()
{
T.A();
}
}
Or, how to call a function of type parameter (type is some my custom class).
...
I have a helper class that does a simple but repetitive process on a List of entities. For simplicity, it's like this...
public static List<MyType> DoSomethingSimple(List<MyType> myTypes) {
return myTypes.Where(myType => myType.SomeProperty.Equals(2)).ToList();
}
I now need to add support for another type, but everything is identi...
I have a base DLL which defines some basic structure and operation for a key concept within our business. This dll is then included in specific web services for each vendor that implement the specific business rules for interacting with that vendor. (While the basic concepts are the same the implementations are very different and can cha...
Possible Duplicate:
Why do I get error: must be a reference type in my C# generic method?
I have 2 Repository methods that are almost identical:
public IList<Fund> GetFundsByName(int pageSize, string searchExpression)
{
return _session.CreateCriteria<Fund>()
.AddNameSearchCriteria<Fund>(searchExpression)
...
Hi guys
I have an abstract class that looks as follows.
public abstract class Entity<PK extends Serializable> implements Serializable {
private PK id;
//getters and setters generated here....
}
public class User extends Entity<Long> {
//all attributes, getters and setters are done here...
}
My Service looks like this
...
I have created a generic method that enables clients to specify both the concrete type of the returned instance and the actual returned type (e.g. an interface) as independent type parameters. Naturally, the concrete returned instance type parameter is constrained to inherit from the actual returned type.
The idea is that you may return...
Hello SO:
I have a subroutine that changes its operation slightly to include either one list or the other then perform the same operation. Since it is just counting the number of items in the list, I figure there is probably an easy way to get the item count regardless of the list type.
Thanks in advance!
EDIT:
private List<Message> ...
Hi All,
I have this program in my eclipse. And if I compile this with JDK 1.5(build path -> configure build path ->java compilern ->JDK compliance -> compiler compliance level = 1.5), I get the type erasure error for method m1
I have an option of choosing compiler compliance level as 5 in the driop down (build path -> configure build pa...
How does Guice's TypeLiteral overcome the Java generic types erasure procedure?
It works wonders but how is this accomplished?
...
I have a number of data classes, which share an abstract base class so i can work with them generically (sort of). They each have a static method called Lerp, which i use frequently along with a couple of other lines. I wanted to refactor this out into a method because of DRY,but it seems there's no way to do so. How do i get around this...
I've created my own custom pseudo enumerations within my domain model to allow me to have some more verbose values. For example, my class is as follows:
public abstract class Enumeration<X, Y> : IComparable where X : IComparable
{
public Enumeration(X value, Y displayName) { }
public Y DisplayName { get { return _displayName; ...
Hello,
In my application, I've created the TList type list, intended to store Integers or Doubles:
TKList<T> = class
private
FItems: TList<T>;
function GetItem(Index: Integer): T;
procedure SetItem(Index: Integer; const Value: T);
function GetMaxValue(): T;
function GetMinValue(): T;
public
constructor Creat...
How can I pass a generic type to a method, when I don't know the type?
public static class ExecContext<E> {
public void doSomething(E e) {
System.out.println(e);
}
}
public static void exec(ExecContext<?> ctx) {
String s = new String("saoj");
ctx.doSomething(s); // <============== COMPILE ERROR
}
...
Hello again stackoverflowians,
I thought it was about time that I learnt how to use a DI framework. I've heard a lot of good things about Castle Windsor so I decided to go with that. Now there are PLENTY of tutorials out there on how to use it, however, I cannot find much useful information about what to do when Generics get involved....
I may well be missing something obvious here; but if I have the following:
public interface IRequest<out T>
where T : class
{
T Request
{
get;
}
}
And:
public interface IResponse<out T>
where T : class
{
T Response
{
get;
}
}
And then a third interface which uses these interfaces as...
Hi all,
I've done a pretty basic class in C++/CLI using generics.
How can I check if the generic array^ equals nullptr?
generic<class T> where T: IGenericContainable
public ref class FIBEXGenericContainer abstract : AbstractFIBEXNode
{
public:
property array<T>^ Children;
public:
property T default[String^]
{
T ...
Is it possible to have a generic method that requires a delegate(?) for a method or just a code block to be passed in as a parameter?
Say I have AddJob() and AddJob2(). I want these passed into a Generic method that runs some skeleton code but then executes the AddJob or AddJob2.
Thanks!
Edit:
I'm on .net 2.0.
...