package com.eactive.eai.rms.onl.adapter.socket;

import java.util.Comparator;
import java.util.HashMap;

public class MapComparator implements Comparator<HashMap<String, Object>>{
	
	private final String[] key ;
	
	public MapComparator(String[] key){
		this.key = key;
	}

	@Override
	public int compare(HashMap<String, Object> first, HashMap<String, Object> second){
		int result = 0;
		for(int i=0; i< key.length;i++){
			if(first.get(key[i]) == null || second.get(key[i]) == null) {
				continue;
			}
			result = ((String) first.get(key[i])).compareTo((String) second.get(key[i]));
			if(result != 0) break;
		}
				
		return result;
	}
}
