```
class Expression{
   private final String expression; //can be 00* or 01* or 0101*

   public int hashCode(){
       //what should I put here
       //tried to use String hashCode but not useful
   }

   public boolean equals(Object obj){
       //Logic for testing of equality
       //Check if the obj is String check if expression matches
   }
}

//This is how map is initialized
map.put("00*",someObject);
map,put("0101*", someOtherObject);

```

**Why the String hashCode implementation was not useful?**

Because the `String` in the `Expression` class is `00*` and the `String` that I am trying to lookup will be `00112233`. So the `hashCode()` won't be same for those Strings.

Client code tries to lookup from the `HashMap` using `String` key

```
map.get("0011"); //should get someObject as `0011` matches expression `00*`

```

Is there any way to do this?

I know that `hashCode()` should contain values that are immutable and about the `hashCode()` and `equals()` contract.

But I am doubtful if there is any way to achieve this.