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

Alachisoft.NCache.Common.Extensibility.Client.RPC.Impl.AddedValueConsolidator Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
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
    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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy