All Downloads are FREE. Search and download functionalities are using the official Maven repository.

holmos.reflect.reflectCheck.difference.HolmosCollectionIgnoreOrderDifference Maven / Gradle / Ivy

package holmos.reflect.reflectCheck.difference;

import holmos.reflect.reflectCheck.HolmosDifferenceVisitor;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**存储无序集合或者数组变量比较的不同的结果的类
 * @author 吴银龙(15857164387)
 * */
public class HolmosCollectionIgnoreOrderDifference extends HolmosDifference{

	public HolmosCollectionIgnoreOrderDifference(Object leftValue,
			Object rightValue, ListleftList,ListrightList,String message) {
		super(leftValue, rightValue, message);
		this.leftList=leftList;
		this.rightList=rightList;
	}
	/**记录左值的每个元素和右值的每一个元素的不同的地方*/
	private Map> elementDifference=new HashMap>();
	public Map> getElementDifference() {
		return elementDifference;
	}
	/**记录最佳匹配的左右组合*/
	private MapbestMatchIndexes=new HashMap();
	/**最佳匹配的得分,是一种评判机制*/
	private int bestMatchScore=Integer.MAX_VALUE;
	public int getBestMatchScore() {
		return bestMatchScore;
	}
	public Map getBestMatchIndexes() {
		return bestMatchIndexes;
	}
	public void setBestMatchScore(int bestMatchScore) {
		this.bestMatchScore = bestMatchScore;
	}
	/**左值的list形式*/
	private ListleftList;
	public List getLeftList() {
		return leftList;
	}
	public List getRightList() {
		return rightList;
	}
	/**右值的list形式*/
	private ListrightList;
	
	/**增加左值和右值的各自一个元素的不同信息
* @param leftIndex 左值索引 * @param rightIndex 右值索引 * @param difference 在此索引处的不同信息 * */ public void addElementDifference(int leftIndex,int rightIndex,HolmosDifference difference){ MaprightDifferrenceToLeft=elementDifference.get(leftIndex); if(rightDifferrenceToLeft==null){ rightDifferrenceToLeft=new HashMap(); elementDifference.put(leftIndex, rightDifferrenceToLeft); }rightDifferrenceToLeft.put(rightIndex, difference); } /**通过左值和右值的索引,获得在此两个的索引处的不同信息
* @param leftIndex 左索引 * @param rightIndex 右索引 * @return 这两个索引处的差异值*/ public HolmosDifference getElementDifference(int leftIndex,int rightIndex){ MaprightDifferrenceToLeft=elementDifference.get(leftIndex); if(rightDifferrenceToLeft==null) return null; return rightDifferrenceToLeft.get(rightIndex); } /**设置最佳匹配搭配
* @param leftIndex 最佳搭配左索引 * @param rightIndex 最佳搭配右索引 * */ public void setBestMatch(int leftIndex,int rightIndex){ bestMatchIndexes.put(leftIndex, rightIndex); } @Override public T accept(HolmosDifferenceVisitor visitor, A argument) { return visitor.visit(this, argument); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy