I have an assignment that is requiring me to use the factory pattern for implementing an immutable data structure, but the problem is that the abstract class is generic, and having static methods make references to generic types is giving me problems. My assignment is requiring me to use static methods so I'm starting to panic. Any help/suggestions? EDIT added some sample code, and here is the specification for one of the methods the professor gave us Signature:
ExampleClass.method1 : ExampleClass, T -> ExampleClass
ExampleClass.method2 : ExampleClass - > T
public abstract class ExampleClass<T>{
//static method creates a new subclass of Example ("Push" method)
public static Class method1(T x, ExampleClass c){
return new method1(x, f);
}
//Supposed to return an object type T ("pop" method)
public static T method2(ExampleClass c){
return c.method2Dynamic();
}
both of the methods I have like these are giving me problems in eclipse.