Hi,
I have 2 different (custom) entity types called A and B. Both request resource units of the same resourcePool. Type A
entities get priority over type B ones, so I created a priority field for both types with A.priority = 2 and B.priority
= 1.
What code (in the 'Request priority' box of the resourcePool) would enable a resource unit to correctly choose a type A
entity over a type B entity in the event of simultaneous resource requests?
Thanks,
Ricus
Pavel — 06.07.10
Hi Ricus,
Please try the following Java expression: entity instanceof A ? ((A)entity).priority : ((B)entity).priority
Michael R. Gibbs — 23.07.10
Or
you can define a inteface like:
public interface Priority{
public int getPriority();
}
and have both classes implement the interface
then priority box simple becomes
((Priority)entity).getPriority()
and if you later add a class C (with implemetation for the Priority interface), you will not need to to remember to
update the priority box to handel the new class