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

no.tornado.inject.DefaultCacheKeyGenerator Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package no.tornado.inject;

import java.lang.reflect.Method;

public class DefaultCacheKeyGenerator implements CacheKeyGenerator {

    public String generate(String bean, Method method, Object[] args) {
        return bean + "." + method.getName() + "(" + argsSignature(args) + ")";
    }

    private String argsSignature(Object[] args) {
        if (args == null || args.length == 0)
            return "";
        
        StringBuilder s = new StringBuilder();
        for (Object arg : args) {
            if (s.length() > 0)
                s.append(",");
            s.append(arg == null ? "null" : arg.hashCode());
        }
        return s.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy