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

com.aggrepoint.utils.linkedtable.DefaultMinusMerger Maven / Gradle / Ivy

The newest version!
package com.aggrepoint.utils.linkedtable;

import com.aggrepoint.utils.TypeCast;

public class DefaultMinusMerger implements INodeMerger {
	private static final DefaultMinusMerger INSTANCE = new DefaultMinusMerger();

	private DefaultMinusMerger() {

	}

	public static DefaultMinusMerger getInstance() {
		return INSTANCE;
	}

	public  T merge(T from, T to) {
		if (from == null)
			return to;
		if (to == null)
			return from;

		if (from instanceof Double) {
			double vfrom = 0.0d;
			if (from != null)
				vfrom = TypeCast.cast(from);

			double vto = 0.0d;
			if (to != null)
				vto = TypeCast.cast(to);
			return TypeCast.cast(new Double(vto - vfrom));
		} else if (from instanceof Integer) {
			int vfrom = 0;
			if (from != null)
				vfrom = TypeCast.cast(from);

			int vto = 0;
			if (to != null)
				vto = TypeCast.cast(to);
			return TypeCast.cast(new Double(vto - vfrom));
		}

		return null;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy