commit 04/07/2025
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
package web;
|
package web;
|
||||||
|
|
||||||
import additional.Somecodes;
|
|
||||||
|
import static additional.Somecodes.ValidString;
|
||||||
|
|
||||||
public record SetContactDescriptionargs(String contact, String description) {
|
public record SetContactDescriptionargs(String contact, String description) {
|
||||||
|
|
||||||
public int getContactID(){
|
public int getContactID(){
|
||||||
// contact is string like c1, c2, c3, etc.
|
// contact is string like c1, c2, c3, etc.
|
||||||
// regex it to extract the number
|
// regex it to extract the number
|
||||||
if (Somecodes.ValidString(contact)){
|
if (ValidString(contact)){
|
||||||
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
package web;
|
package web;
|
||||||
|
|
||||||
import additional.Somecodes;
|
|
||||||
|
import static additional.Somecodes.ValidEmail;
|
||||||
|
import static additional.Somecodes.ValidString;
|
||||||
|
|
||||||
public record SetContactEmailargs(String contact, String email) {
|
public record SetContactEmailargs(String contact, String email) {
|
||||||
|
|
||||||
public int getContactID() {
|
public int getContactID() {
|
||||||
// contact is string like c1, c2, c3, etc.
|
// contact is string like c1, c2, c3, etc.
|
||||||
// regex it to extract the number
|
// regex it to extract the number
|
||||||
if (Somecodes.ValidString(contact)) {
|
if (ValidString(contact)) {
|
||||||
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
try {
|
try {
|
||||||
@@ -22,6 +24,6 @@ public record SetContactEmailargs(String contact, String email) {
|
|||||||
public boolean getEnabled() {
|
public boolean getEnabled() {
|
||||||
// check if email is in valid format, then enabled.
|
// check if email is in valid format, then enabled.
|
||||||
// otherwise disabled.
|
// otherwise disabled.
|
||||||
return Somecodes.ValidEmail(email);
|
return ValidEmail(email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package web;
|
package web;
|
||||||
|
|
||||||
import additional.Somecodes;
|
|
||||||
|
import static additional.Somecodes.ValidString;
|
||||||
|
|
||||||
public record SetContactMqttargs(String contact, String mqtt) {
|
public record SetContactMqttargs(String contact, String mqtt) {
|
||||||
|
|
||||||
public int getContactID() {
|
public int getContactID() {
|
||||||
// contact is string like c1, c2, c3, etc.
|
// contact is string like c1, c2, c3, etc.
|
||||||
// regex it to extract the number
|
// regex it to extract the number
|
||||||
if (Somecodes.ValidString(contact)) {
|
if (ValidString(contact)) {
|
||||||
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package web;
|
package web;
|
||||||
|
|
||||||
import additional.Somecodes;
|
|
||||||
|
import static additional.Somecodes.*;
|
||||||
|
|
||||||
public record SetContactVX3Kargs(String contact, String value) {
|
public record SetContactVX3Kargs(String contact, String value) {
|
||||||
|
|
||||||
public int getContactID() {
|
public int getContactID() {
|
||||||
// contact is string like c1, c2, c3, etc.
|
// contact is string like c1, c2, c3, etc.
|
||||||
// regex it to extract the number
|
// regex it to extract the number
|
||||||
if (Somecodes.ValidString(contact)) {
|
if (ValidString(contact)) {
|
||||||
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
var matcher = java.util.regex.Pattern.compile("c(\\d+)").matcher(contact);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
try {
|
try {
|
||||||
@@ -25,14 +26,14 @@ public record SetContactVX3Kargs(String contact, String value) {
|
|||||||
// with FrameID is between Somecodes.MinVX3kFrameID and Somecodes.MaxVX3kFrameID
|
// with FrameID is between Somecodes.MinVX3kFrameID and Somecodes.MaxVX3kFrameID
|
||||||
// and RelayID is between Somecodes.MinVX3kRelayID and Somecodes.MaxVX3kRelayID
|
// and RelayID is between Somecodes.MinVX3kRelayID and Somecodes.MaxVX3kRelayID
|
||||||
// otherwise return false
|
// otherwise return false
|
||||||
if (Somecodes.ValidString(value)) {
|
if (ValidString(value)) {
|
||||||
var parts = value.split(":");
|
var parts = value.split(":");
|
||||||
if (parts.length == 2) {
|
if (parts.length == 2) {
|
||||||
try {
|
try {
|
||||||
int frameID = Integer.parseInt(parts[0]);
|
int frameID = Integer.parseInt(parts[0]);
|
||||||
int relayID = Integer.parseInt(parts[1]);
|
int relayID = Integer.parseInt(parts[1]);
|
||||||
return frameID >= Somecodes.MinVX3kFrameID && frameID <= Somecodes.MaxVX3kFrameID &&
|
return frameID >= MinVX3kFrameID && frameID <= MaxVX3kFrameID &&
|
||||||
relayID >= Somecodes.MinVX3kRelayID && relayID <= Somecodes.MaxVX3kRelayID;
|
relayID >= MinVX3kRelayID && relayID <= MaxVX3kRelayID;
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
// Ignore and return false
|
// Ignore and return false
|
||||||
}
|
}
|
||||||
@@ -43,7 +44,7 @@ public record SetContactVX3Kargs(String contact, String value) {
|
|||||||
|
|
||||||
public int getFrameID(){
|
public int getFrameID(){
|
||||||
// from value with format "FrameID:RelayID" get the FrameID
|
// from value with format "FrameID:RelayID" get the FrameID
|
||||||
if (Somecodes.ValidString(value)) {
|
if (ValidString(value)) {
|
||||||
var parts = value.split(":");
|
var parts = value.split(":");
|
||||||
if (parts.length > 0) {
|
if (parts.length > 0) {
|
||||||
try {
|
try {
|
||||||
@@ -58,7 +59,7 @@ public record SetContactVX3Kargs(String contact, String value) {
|
|||||||
|
|
||||||
public int getRelayID(){
|
public int getRelayID(){
|
||||||
// from value with format "FrameID:RelayID" get the RelayID
|
// from value with format "FrameID:RelayID" get the RelayID
|
||||||
if (Somecodes.ValidString(value)) {
|
if (ValidString(value)) {
|
||||||
var parts = value.split(":");
|
var parts = value.split(":");
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user