Reputation: 3885
a class A
has 3 boolean
fields, and there is a set of objects of this class. i need to execute different processing for each object, in terms of the combination of its 3 fields. what pattern should I adopt?
public class A {
boolean a, b, c;
}
thank you.
daniel
Upvotes: 1
Views: 58
Reputation: 28752
Look up registry
pattern. Essentially you define an interface AHandler
and implement it for each combination you want to process.
Then, create a Map<A, AHandler>
and statically initialize it with the handlers. Look up this map to find the handler to process each combination.
Upvotes: 1