Alachisoft.NCache.Common.Extensibility.Client.RPC.Impl.AddedValueConsolidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
package Alachisoft.NCache.Common.Extensibility.Client.RPC.Impl;
import com.google.common.reflect.TypeToken;
import java.lang.reflect.Type;
public class AddedValueConsolidator extends MultiPartitionResponseConsolidator {
private final TypeToken typeToken = new TypeToken(getClass()) {
};
private final Type type = typeToken.getType(); // or getRawType() to return Class super T>
private TValue finalResponse = null;
private Object value = null;
public Type getType() {
return type;
}
@Override
public Object GetFinalResponse() {
if (_responses.size() > 0) {
for (Object response : _responses.values()) {
switch (getType().getTypeName()) {
case "java.lang.Integer":
value = (Integer) finalResponse + (Integer) response;
finalResponse = (TValue) value;
break;
case "java.lang.Long":
value = (Long) finalResponse + (Long) response;
finalResponse = (TValue) value;
break;
case "java.lang.Double":
value = (Double) finalResponse + (Double) response;
finalResponse = (TValue) value;
break;
}
}
}
return finalResponse;
}
}