commit 04/07/2025

This commit is contained in:
2025-07-04 16:01:27 +07:00
parent abed46d228
commit 84c4ad9c6e
4 changed files with 19 additions and 14 deletions

View File

@@ -1,13 +1,14 @@
package web;
import additional.Somecodes;
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 (Somecodes.ValidString(contact)){
if (ValidString(contact)){
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
if (matcher.find()) {
try {

View File

@@ -1,13 +1,15 @@
package web;
import additional.Somecodes;
import static additional.Somecodes.ValidEmail;
import static additional.Somecodes.ValidString;
public record SetContactEmailargs(String contact, String email) {
public int getContactID() {
// contact is string like c1, c2, c3, etc.
// regex it to extract the number
if (Somecodes.ValidString(contact)) {
if (ValidString(contact)) {
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
if (matcher.find()) {
try {
@@ -22,6 +24,6 @@ public record SetContactEmailargs(String contact, String email) {
public boolean getEnabled() {
// check if email is in valid format, then enabled.
// otherwise disabled.
return Somecodes.ValidEmail(email);
return ValidEmail(email);
}
}

View File

@@ -1,13 +1,14 @@
package web;
import additional.Somecodes;
import static additional.Somecodes.ValidString;
public record SetContactMqttargs(String contact, String mqtt) {
public int getContactID() {
// contact is string like c1, c2, c3, etc.
// regex it to extract the number
if (Somecodes.ValidString(contact)) {
if (ValidString(contact)) {
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
if (matcher.find()) {
try {

View File

@@ -1,13 +1,14 @@
package web;
import additional.Somecodes;
import static additional.Somecodes.*;
public record SetContactVX3Kargs(String contact, String value) {
public int getContactID() {
// contact is string like c1, c2, c3, etc.
// regex it to extract the number
if (Somecodes.ValidString(contact)) {
if (ValidString(contact)) {
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
if (matcher.find()) {
try {
@@ -25,14 +26,14 @@ public record SetContactVX3Kargs(String contact, String value) {
// with FrameID is between Somecodes.MinVX3kFrameID and Somecodes.MaxVX3kFrameID
// and RelayID is between Somecodes.MinVX3kRelayID and Somecodes.MaxVX3kRelayID
// otherwise return false
if (Somecodes.ValidString(value)) {
if (ValidString(value)) {
var parts = value.split(":");
if (parts.length == 2) {
try {
int frameID = Integer.parseInt(parts[0]);
int relayID = Integer.parseInt(parts[1]);
return frameID >= Somecodes.MinVX3kFrameID && frameID <= Somecodes.MaxVX3kFrameID &&
relayID >= Somecodes.MinVX3kRelayID && relayID <= Somecodes.MaxVX3kRelayID;
return frameID >= MinVX3kFrameID && frameID <= MaxVX3kFrameID &&
relayID >= MinVX3kRelayID && relayID <= MaxVX3kRelayID;
} catch (NumberFormatException ignored) {
// Ignore and return false
}
@@ -43,7 +44,7 @@ public record SetContactVX3Kargs(String contact, String value) {
public int getFrameID(){
// from value with format "FrameID:RelayID" get the FrameID
if (Somecodes.ValidString(value)) {
if (ValidString(value)) {
var parts = value.split(":");
if (parts.length > 0) {
try {
@@ -58,7 +59,7 @@ public record SetContactVX3Kargs(String contact, String value) {
public int getRelayID(){
// from value with format "FrameID:RelayID" get the RelayID
if (Somecodes.ValidString(value)) {
if (ValidString(value)) {
var parts = value.split(":");
if (parts.length > 1) {
try {