Skip to content

Commit bc540f0

Browse files
Identity Field Pattern
1 parent 98237cd commit bc540f0

File tree

5 files changed

+43
-22
lines changed

5 files changed

+43
-22
lines changed

Identity_Field/src/main/java/com.iluwater.fieild/Book.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
33
*
44
* The MIT License
@@ -21,18 +21,11 @@
2121
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
24-
*/
24+
*/
2525

2626
package com.iluwater.fieild;
2727
import lombok.Getter;
2828
import lombok.Setter;
29-
/*
30-
* The Book class represents a book entity in the application.
31-
*
32-
* <p>This class extends DomainObject and inherits its unique identifier.
33-
* It includes additional fields and methods specific to a book's attributes,
34-
* such as title and author.</p>
35-
*/
3629
@Setter
3730
@Getter
3831
public class Book extends DomainObject {

Identity_Field/src/main/java/com.iluwater.fieild/Client.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
33
*
44
* The MIT License
@@ -21,21 +21,25 @@
2121
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
24-
*/
24+
*/
2525
package com.iluwater.fieild;
26-
26+
import java.util.regex.Pattern;
2727
import lombok.Getter;
2828
import lombok.Setter;
2929

3030
@Setter
3131
@Getter
32-
public class Client extends DomainObject{
32+
public class Client extends DomainObject {
33+
private static final String EMAIL_REGEX = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
3334
private String name;
3435
private String Email;
3536

36-
public Client(String name,String Email) {
37+
public Client(String name, String Email) {
38+
Pattern pattern = Pattern.compile(EMAIL_REGEX);
3739
this.name = name;
38-
this.Email = Email;
40+
if (pattern.matcher(Email).matches()) {
41+
this.Email = Email;
42+
}
3943
}
4044

4145
}

Identity_Field/src/main/java/com.iluwater.fieild/DomainObject.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
33
*
44
* The MIT License
@@ -21,22 +21,21 @@
2121
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
24-
*/
25-
24+
*/
2625
package com.iluwater.fieild;
2726
import javax.persistence.GeneratedValue;
2827
import javax.persistence.GenerationType;
2928
import javax.persistence.Id;
3029
import javax.persistence.MappedSuperclass;
3130
import lombok.Getter;
3231
import lombok.Setter;
33-
/*
32+
/*
3433
* The DomainObject class provides a base for domain entities
3534
* that require unique identification within the application.
3635
*
3736
* <p>All child classes inherit the unique identifier field
3837
* and associated functionality.</p>
39-
*/
38+
*/
4039
@Getter
4140
@Setter
4241
@MappedSuperclass

Identity_Field/src/test/java/com/iluwater/fieild/BookTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
126
package com.iluwater.fieild;
227

328
import org.junit.jupiter.api.Test;

Identity_Field/src/test/java/com/iluwater/fieild/ClientTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
33
*
44
* The MIT License
@@ -21,7 +21,7 @@
2121
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
24-
*/
24+
*/
2525
package com.iluwater.fieild;
2626

2727
import static org.junit.jupiter.api.Assertions.*;

0 commit comments

Comments
 (0)