Skip to content

Commit 5ea8a1c

Browse files
committed
tiny simplification to SoftDeleteType
1 parent cdb88bf commit 5ea8a1c

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

hibernate-core/src/main/java/org/hibernate/annotations/SoftDelete.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
Class<? extends AttributeConverter<Boolean,?>> converter() default UnspecifiedConversion.class;
117117

118118
/**
119-
* Used as the default for {@linkplain SoftDelete#converter()}, indicating that
119+
* Used as the default for {@linkplain SoftDelete#converter}, indicating that
120120
* {@linkplain Dialect#getPreferredSqlTypeCodeForBoolean() dialect} and
121121
* {@linkplain org.hibernate.cfg.MappingSettings#PREFERRED_BOOLEAN_JDBC_TYPE settings}
122122
* resolution should be used.

hibernate-core/src/main/java/org/hibernate/annotations/SoftDeleteType.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*/
55
package org.hibernate.annotations;
66

7-
import java.util.Locale;
8-
97
/**
108
* Enumeration of defines styles of soft-delete
119
*
@@ -42,19 +40,16 @@ public enum SoftDeleteType {
4240
* <dd>indicates that the row is deleted, at the given timestamp</dd>
4341
* </dl>
4442
*/
45-
TIMESTAMP( "deleted" );
46-
47-
private final String defaultColumnName;
48-
49-
SoftDeleteType() {
50-
this.defaultColumnName = name().toLowerCase( Locale.ROOT );
51-
}
52-
53-
SoftDeleteType(String defaultColumnName) {
54-
this.defaultColumnName = defaultColumnName;
55-
}
43+
TIMESTAMP;
5644

45+
/**
46+
* The default column name used with this strategy.
47+
* @see SoftDelete#columnName
48+
*/
5749
public String getDefaultColumnName() {
58-
return defaultColumnName;
50+
return switch ( this ) {
51+
case ACTIVE -> "active";
52+
case DELETED, TIMESTAMP -> "deleted";
53+
};
5954
}
6055
}

0 commit comments

Comments
 (0)