I am wondering if there's an elegant solution for doing this in Java (besides the obvious one - of declaring a different/explicit function. Here is the code:

```
private static HashMap<String, Integer> nameStringIndexMap 
        = new HashMap<String, Integer>();
private static HashMap<Buffer, Integer> nameBufferIndexMap 
        = new HashMap<Buffer, Integer>();

// and a function
private static String newName(Object object, 
        HashMap<Object, Integer> nameIndexMap){
    ....
}

```

The problem is that I cannot pass *nameStringIndexMap* or *nameBufferIndexMap* parameters to the function. I don't have an idea about a more elegant solution beside doing another function which explicitly wants a *HashMap<String, Integer>* or *HashMap<Buffer, Integer>* parameter.

My question is:
Can this be made in a more elegant solution/using generics or something similar?

Thank you,

Iulian