Skip to content

Commit 722737b

Browse files
committed
Convert Name to an interface
1 parent 69a9d06 commit 722737b

File tree

6 files changed

+81
-24
lines changed

6 files changed

+81
-24
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2024-2025 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.techsenger.patternfx.core;
18+
19+
/**
20+
*
21+
* @author Pavel Castornii
22+
*/
23+
public abstract class AbstractName implements Name {
24+
25+
private final String text;
26+
27+
public AbstractName(String text) {
28+
this.text = text;
29+
}
30+
31+
/**
32+
* Returns the human-readable name.
33+
*
34+
* @return the component name text
35+
*/
36+
public String getText() {
37+
return text;
38+
}
39+
40+
@Override
41+
public String toString() {
42+
return this.text;
43+
}
44+
}

patternfx-core/src/main/java/com/techsenger/patternfx/core/ComponentGroupName.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Pavel Castornii
2222
*/
23-
public class ComponentGroupName extends ComponentName {
23+
public class ComponentGroupName extends AbstractName {
2424

2525
public ComponentGroupName(String text) {
2626
super(text);

patternfx-core/src/main/java/com/techsenger/patternfx/core/ComponentName.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
*
2929
* @author Pavel Castornii
3030
*/
31-
public class ComponentName extends Name {
31+
public interface ComponentName extends Name {
3232

33-
public ComponentName(String text) {
34-
super(text);
35-
}
3633
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2024-2025 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.techsenger.patternfx.core;
18+
19+
/**
20+
*
21+
* @author Pavel Castornii
22+
*/
23+
public class DefaultComponentName extends AbstractName implements ComponentName {
24+
25+
public DefaultComponentName(String text) {
26+
super(text);
27+
}
28+
}

patternfx-core/src/main/java/com/techsenger/patternfx/core/Name.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,12 @@
2020
*
2121
* @author Pavel Castornii
2222
*/
23-
public class Name {
23+
public interface Name {
2424

25-
private final String text;
26-
27-
public Name(String text) {
28-
this.text = text;
29-
}
30-
31-
/**
25+
/**
3226
* Returns the human-readable name.
3327
*
3428
* @return the component name text
3529
*/
36-
public String getText() {
37-
return text;
38-
}
39-
40-
@Override
41-
public String toString() {
42-
return this.text;
43-
}
30+
String getText();
4431
}

patternfx-demo/src/main/java/com/techsenger/patternfx/demo/DemoNames.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
package com.techsenger.patternfx.demo;
1818

1919
import com.techsenger.patternfx.core.ComponentName;
20+
import com.techsenger.patternfx.core.DefaultComponentName;
2021

2122
/**
2223
*
2324
* @author Pavel Castornii
2425
*/
2526
public final class DemoNames {
2627

27-
public static final ComponentName PERSON_REGISTRY = new ComponentName("PersonRegistry");
28+
public static final ComponentName PERSON_REGISTRY = new DefaultComponentName("PersonRegistry");
2829

29-
public static final ComponentName PERSON_DIALOG = new ComponentName("PersonDialog");
30+
public static final ComponentName PERSON_DIALOG = new DefaultComponentName("PersonDialog");
3031

31-
public static final ComponentName PERSON_REPORT = new ComponentName("PersonReport");
32+
public static final ComponentName PERSON_REPORT = new DefaultComponentName("PersonReport");
3233

3334
private DemoNames() {
3435
//empty

0 commit comments

Comments
 (0)