[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [e4-dev] I'd like to add static utility methods to UIEvents
|
Out of general style considerations, I prefer the instance method. Static hinders polymorphism.
Regards, Dimitar
On 17 February 2012 17:01, Dean Roberts
<Dean_Roberts@xxxxxxxxxx> wrote:
Hi folks,
I was writing a some more event handler code today and thought that UIEvents could use some simple utility methods. I'd like to add them if nobody has any objections.
It is typical for an event handler to want to know the type of the event. ADD, REMOVE, SET etc. Currently code that cares writes
if (UIEvents.EventTypes.ADD.equals(event.getProperty(UIEvents.EventTypes.ADD)) {
// foo
} else if ((UIEvents.EventTypes.SET.equals(UIEvents.event.getProperty(EventTypes.SET) {
// bar
}
or I suppose this would be good enough too
if (event.containsProperty(UIEvents.EventTypes.ADD)) {
// foo
} else if ((event.containsProperty(UIEvents.EventTypes.SET)) {
// bar
}
If we define utility methods on UIEvents like
public static boolean isAdd(Event event);
public static boolean isSet(Event event);
Then the above code could look like
if (UIEvents.isAdd(event)) {
// foo
} else if (UIEvents.isSet(event) {
// bar
}
Admitedly the containsProperty() implementation may be good enough ... I only thought of that one while writing this email.
Does anybody have strong feelings one way or the other? I think I still like the utility method implementation.
Dean_Roberts@xxxxxxxxxx
_______________________________________________
e4-dev mailing list
e4-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/e4-dev