26 lines
660 B
Java
26 lines
660 B
Java
package web;
|
|
|
|
|
|
import static additional.Somecodes.ValidString;
|
|
|
|
public record SetContactDescriptionargs(String contact, String description) {
|
|
|
|
public int getContactID(){
|
|
// contact is string like c1, c2, c3, etc.
|
|
// regex it to extract the number
|
|
if (ValidString(contact)){
|
|
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
|
if (matcher.find()) {
|
|
try {
|
|
return Integer.parseInt(matcher.group(1));
|
|
} catch (NumberFormatException ignored) {
|
|
|
|
}
|
|
}
|
|
}
|
|
return -1; // Invalid contact ID
|
|
|
|
|
|
}
|
|
}
|