Skip to content

Commit

Permalink
Using records
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarg committed Dec 23, 2024
1 parent 998ccbe commit fcf0795
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions src/main/java/com/beust/jcommander/StringKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

import com.beust.jcommander.FuzzyMap.IKey;

public class StringKey implements IKey {

private String name;

public StringKey(String name) {
this.name = name;
}
public record StringKey(String name) implements IKey {

@Override
public String getName() {
Expand All @@ -20,29 +14,4 @@ public String toString() {
return name;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
StringKey other = (StringKey) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}

}

0 comments on commit fcf0795

Please sign in to comment.