Skip to content

Commit a4bce48

Browse files
Remove deprecated PropertyUtil.writeProperty method (#125)
* refactor: Remove deprecated PropertyUtil.writeProperty method (#123) - Removed deprecated writeProperty() method from PropertyUtil - Updated all test usages to use setProperty() instead - Cleaned up unused imports and formatting from pre-commit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Prepare release --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e95daa8 commit a4bce48

5 files changed

Lines changed: 15 additions & 33 deletions

File tree

.github/project.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ name: cui-java-tools
22
pages-reference: cui-java-tools
33
sonar-project-key: cuioss_cui-java-tools
44
release:
5-
current-version: 2.5.1
6-
next-version: 2.5-SNAPSHOT
5+
current-version: 2.6.0
6+
next-version: 2.6-SNAPSHOT

src/main/java/de/cuioss/tools/logging/LogLevel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import de.cuioss.tools.reflect.MoreReflection;
2020
import lombok.AccessLevel;
2121
import lombok.Getter;
22-
import lombok.NonNull;
2322
import lombok.RequiredArgsConstructor;
2423
import org.jspecify.annotations.Nullable;
2524

src/main/java/de/cuioss/tools/logging/LogRecordModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected String getParsedMessageTemplate() {
172172
@Override
173173
public String format(Object... parameter) {
174174
return resolveIdentifierString() + AFTER_PREFIX +
175-
lenientFormat(getParsedMessageTemplate(), parameter);
175+
lenientFormat(getParsedMessageTemplate(), parameter);
176176
}
177177

178178
@Override

src/main/java/de/cuioss/tools/property/PropertyUtil.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,6 @@ public static void setProperty(Object bean, String propertyName, Object property
146146
writePropertyWithChaining(bean, propertyName, propertyValue);
147147
}
148148

149-
/**
150-
* Writes a value to a property of a bean using reflection and returns the bean for method chaining.
151-
* This method violates Command-Query Separation by both modifying state and returning a value.
152-
* Consider using {@link #setProperty(Object, String, Object)} for pure command operations.
153-
*
154-
* @param bean the bean to write to, must not be null
155-
* @param propertyName the name of the property to write, must not be null or empty
156-
* @param propertyValue the value to write to the property
157-
* @return the bean instance (for method chaining)
158-
* @throws IllegalArgumentException if the property cannot be written or does not exist
159-
* @since 2.0
160-
* @deprecated Use {@link #setProperty(Object, String, Object)} for pure command operations
161-
*/
162-
@Deprecated(since = "2.4.1", forRemoval = true)
163-
public static Object writeProperty(Object bean, String propertyName, Object propertyValue) {
164-
return writePropertyWithChaining(bean, propertyName, propertyValue);
165-
}
166149

167150
/**
168151
* Internal method for property writing with return value support.

src/test/java/de/cuioss/tools/property/PropertyUtilTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ void shouldReadWriteHappyCase() {
4242
assertNotNull(readProperty(underTest, ATTRIBUTE_DEFAULT_VALUE));
4343

4444
Integer number = 4;
45-
assertNotNull(writeProperty(underTest, ATTRIBUTE_READ_WRITE, number));
45+
setProperty(underTest, ATTRIBUTE_READ_WRITE, number);
4646
assertEquals(number, readProperty(underTest, ATTRIBUTE_READ_WRITE));
4747

4848
assertNull(readProperty(underTest, ATTRIBUTE_READ_WRITE_WITH_BUILDER));
49-
assertNotNull(writeProperty(underTest, ATTRIBUTE_READ_WRITE_WITH_BUILDER, number));
49+
setProperty(underTest, ATTRIBUTE_READ_WRITE_WITH_BUILDER, number);
5050
assertEquals(number, readProperty(underTest, ATTRIBUTE_READ_WRITE));
5151

52-
assertNotNull(writeProperty(underTest, ATTRIBUTE_READ_WRITE, null));
52+
setProperty(underTest, ATTRIBUTE_READ_WRITE, null);
5353
assertNull(readProperty(underTest, ATTRIBUTE_READ_WRITE));
5454
}
5555

@@ -60,15 +60,15 @@ void shouldHandleOverloadedMethods() {
6060
assertNull(readProperty(underTest, PROPERTY_NAME));
6161

6262
Integer number = 4;
63-
assertNotNull(writeProperty(underTest, PROPERTY_NAME, number));
63+
setProperty(underTest, PROPERTY_NAME, number);
6464
assertEquals(number, readProperty(underTest, PROPERTY_NAME));
6565

66-
assertNotNull(writeProperty(underTest, PROPERTY_NAME, "5"));
66+
setProperty(underTest, PROPERTY_NAME, "5");
6767
assertEquals(5, readProperty(underTest, PROPERTY_NAME));
6868

6969
var propertyValue = new ArrayList<>();
7070
assertThrows(IllegalArgumentException.class, () ->
71-
writeProperty(underTest, PROPERTY_NAME, propertyValue));
71+
setProperty(underTest, PROPERTY_NAME, propertyValue));
7272
}
7373

7474
@Test
@@ -79,8 +79,8 @@ void shouldHandleMethodsWithPrimitives() {
7979
assertEquals(0, readProperty(underTest, PROPERTY_PRIMITIVE_NAME));
8080

8181
Integer number = 4;
82-
assertNotNull(writeProperty(underTest, PROPERTY_NAME, number));
83-
assertNotNull(writeProperty(underTest, PROPERTY_PRIMITIVE_NAME, number));
82+
setProperty(underTest, PROPERTY_NAME, number);
83+
setProperty(underTest, PROPERTY_PRIMITIVE_NAME, number);
8484
assertEquals(4, readProperty(underTest, PROPERTY_PRIMITIVE_NAME));
8585

8686
}
@@ -93,9 +93,9 @@ void shouldFailOnInvalidProperty() {
9393
assertThrows(IllegalArgumentException.class, () ->
9494
readProperty(underTest, ATTRIBUTE_WRITE_ONLY));
9595
assertThrows(IllegalArgumentException.class, () ->
96-
writeProperty(underTest, ATTRIBUTE_NOT_ACCESSIBLE, ""));
96+
setProperty(underTest, ATTRIBUTE_NOT_ACCESSIBLE, ""));
9797
assertThrows(IllegalArgumentException.class, () ->
98-
writeProperty(underTest, ATTRIBUTE_READ_ONLY, ""));
98+
setProperty(underTest, ATTRIBUTE_READ_ONLY, ""));
9999
}
100100

101101
@Test
@@ -106,7 +106,7 @@ void shouldFailOnOnRuntimeExceptionProperty() {
106106
assertThrows(IllegalStateException.class, () ->
107107
readProperty(underTest, PROPERTY_NAME));
108108
assertThrows(IllegalStateException.class, () ->
109-
writeProperty(underTest, PROPERTY_NAME, ""));
109+
setProperty(underTest, PROPERTY_NAME, ""));
110110
}
111111

112112
@Test
@@ -117,7 +117,7 @@ void shouldBeFlexibleRegardingCaseSensitivity() {
117117
assertNull(readProperty(underTest, name));
118118

119119
var value = Generators.nonEmptyStrings().next();
120-
writeProperty(underTest, name, value);
120+
setProperty(underTest, name, value);
121121
assertEquals(value, readProperty(underTest, name));
122122
}
123123

0 commit comments

Comments
 (0)