You need to sign in to do that
Don't have an account?
Frank N.
Implementing custom maps using parameterized types
Hi all,
To optimize our code we would like to be able to create custom maps using parameterized types. For example, I want to be able to define an interface with two undefined types:
global interface SortedMapInterface<V,K> {}
And then down the line be able to instantiate the class and determine the types used for the map:
CustomMap m = new CustomMap<Id, someObject>();
However, I am unsure whether APEX allows you to do so as I would need to add the map somewhere but this is not allowed:
Map<V, K> m = new Map<V,K>();
Hopefully this make sense and someone can point me in the right direction.
Have you checked out the section in the Apex docs regarding parameterized typing and interfaces?
Here's the link -
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_interfaces_parameterized_types.htm
~ Clint
Hi Billy,
I have but it will not allow me to do what I'd like to do. Basically I want to be able to create my own 'parameterized' class for example:
Next, inside my custom class I want to create a new map based on types Id and Map:
This however, does not seem possible unless I create a pre-defined class that contains that map based on those types. If anyone does know a way of extending maps, please let me know.