/*******************************************************************************
 * Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Benedek Izso - initial API and implementation
 *   Gabor Szarnyas - initial API and implementation
 *******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.neo4j.comparators;

import hu.bme.mit.trainbenchmark.constants.ModelConstants;
import org.neo4j.graphdb.Node;

import java.util.Comparator;

public class NodeComparator implements Comparator<Node> {

	@Override
	public int compare(final Node node1, final Node node2) {
		final long id1 = (Long) node1.getProperty(ModelConstants.ID);
		final long id2 = (Long) node2.getProperty(ModelConstants.ID);
		return Long.compare(id1, id2);
	}

}

@@ -949,84 +949,154 @@
 1 = 
-(
+get
 Long
-) 
+Id(
 node1
-.getProperty(ModelConstants.ID);%0A%09%09final long id2 = (Long)
+);%0A%09%09final long id2 = getLongId(node2);%0A%09%09return Long.compare(id1, id2);%0A%09%7D%0A%0A%09private long getLongId(Node node) %7B%0A%09%09Object o =
  node
-2
 .get
@@ -1124,16 +1124,44 @@
 ts.ID);%0A
+%09%09if (o instanceof Long) %7B%0A%09
 %09%09return
@@ -1161,37 +1161,161 @@
 %09return 
+(
 Long
-.compare(id1, id2
+) o;%0A%09%09%7D%0A%09%09if (o instanceof Integer) %7B%0A%09%09%09return Long.valueOf((Integer) o);%0A%09%09%7D%0A%09%09throw new IllegalStateException(%22ID should be int or long%22
 );%0A%09%7D%0A%0A%7D

Work around the usual long/int issues