class CompositeKeyGenerator implements KeyGenerator {

    @Override
    public Object generate(Object target, Method method, Object... params) {
        if (params == null) return CompositeKey.EMPTY;

        switch (params.length) {
            case 0:
                // in case of no parameter, use the same instance of empty key
                return CompositeKey.EMPTY;
            case 1:
                // if there is just one param and it is not array (problem with equals), use just this
                Object param = params[0];
                if (param != null && !param.getClass().isArray()) {
                    return param;
                }
                return new CompositeKey(params);
            default:
                return new CompositeKey(params);
        }
    }

}