Allon Mureinik has posted comments on this change.
Change subject: core: Introducing Business Entity comparators
......................................................................
Patch Set 1: (2 inline comments)
....................................................
File
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntityComparator.java
Line 5:
Line 6: /**
Line 7: * Generic for implementing a business entity comparator based on ID
comparison
Line 8: */
Line 9: public class BusinessEntityComparator<T extends BusinessEntity<ID>, ID
extends Serializable & Comparable<? super ID>> implements Comparator<T> {
All collections are serializable, including the sorted ones (e.g., TreeSet).
However, if you create them with a non-serializable comperator, they loose this
property.
And since it's just a marker interface anyway, it costs virtually nothing to
do, so it's considered a good practice (as in - do now, avoid hard-to-find bugs
later).
Line 10:
Line 11: @Override
Line 12: public int compare(T o1, T o2) {
Line 13: return o1.getId().compareTo(o2.getId());
Line 13: return o1.getId().compareTo(o2.getId());
Line 14: }
Line 15:
Line 16: public static <T extends BusinessEntity<ID>, ID extends
Serializable & Comparable<? super ID>> BusinessEntityComparator<T, ID>
newInstance() {
Line 17: return new BusinessEntityComparator<T, ID>();
nachs, my bad.
I'd make this function protected then, and have a static cached instance
created in inheriting classes (using this function)
Line 18: }
--
To view, visit http://gerrit.ovirt.org/8290
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I979cb7d2273c2eaaa2866dcb4a5f760e9266e11a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches