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

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

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

import com.aggrepoint.utils.TypeCast;

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

	private DefaultAddMerger() {

	}

	public static DefaultAddMerger getInstance() {
		return INSTANCE;
	}

	public  T merge(T a, T b) {
		if (a == null)
			return b;
		if (b == null)
			return a;

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

			double vb = 0.0d;
			if (b != null)
				vb = TypeCast.cast(b);
			return TypeCast.cast(new Double(va + vb));
		} else if (a instanceof Integer) {
			int va = 0;
			if (a != null)
				va = TypeCast.cast(a);

			int vb = 0;
			if (b != null)
				vb = TypeCast.cast(b);
			return TypeCast.cast(new Double(va + vb));
		}

		return null;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy