01: /*******************************************************************************
02: * Copyright (c) 2007 MyGWT.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Darrell Meyer <darrell@mygwt.net> - initial API and implementation
10: *******************************************************************************/package net.mygwt.ui.client.viewer;
11:
12: import net.mygwt.ui.client.data.Model;
13: import net.mygwt.ui.client.util.DefaultComparator;
14:
15: /**
16: * A <code>Comparator</code> for <code>Model</code> instances.
17: */
18: public class ModelComparator extends DefaultComparator {
19:
20: public String compareProperty = "name";
21:
22: public ModelComparator() {
23:
24: }
25:
26: public ModelComparator(String compareProperty) {
27: this .compareProperty = compareProperty;
28: }
29:
30: public int compare(Object o1, Object o2) {
31: Model m1 = (Model) o1;
32: Model m2 = (Model) o2;
33:
34: o1 = m1.get(compareProperty);
35: o2 = m2.get(compareProperty);
36:
37: return super.compare(o1, o2);
38: }
39:
40: }
|