Skip to content

Commit a514b26

Browse files
committed
modernize SourceType enum and Origin.hashCode
1 parent f197500 commit a514b26

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

hibernate-core/src/main/java/org/hibernate/boot/jaxb/Origin.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public boolean equals(Object o) {
5959

6060
@Override
6161
public int hashCode() {
62-
int result = type != null ? type.hashCode() : 0;
63-
result = 31 * result + ( name != null ? name.hashCode() : 0 );
64-
return result;
62+
return Objects.hash( type, name );
6563
}
6664

6765
@Override

hibernate-core/src/main/java/org/hibernate/boot/jaxb/SourceType.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@
1010
* @author Steve Ebersole
1111
*/
1212
public enum SourceType {
13-
RESOURCE( "resource" ),
14-
FILE( "file" ),
15-
INPUT_STREAM( "input stream" ),
16-
URL( "URL" ),
17-
STRING( "string" ),
18-
DOM( "xml" ),
19-
JAR( "jar" ),
20-
ANNOTATION( "annotation" ),
21-
OTHER( "other" );
22-
23-
private final String legacyTypeText;
24-
25-
SourceType(String legacyTypeText) {
26-
this.legacyTypeText = legacyTypeText;
27-
}
13+
RESOURCE,
14+
FILE,
15+
INPUT_STREAM,
16+
URL,
17+
STRING,
18+
DOM,
19+
JAR,
20+
ANNOTATION,
21+
OTHER;
2822

2923
public String getLegacyTypeText() {
30-
return legacyTypeText;
24+
return switch ( this ) {
25+
case RESOURCE -> "resource";
26+
case FILE -> "file";
27+
case INPUT_STREAM -> "input stream";
28+
case URL -> "URL";
29+
case STRING -> "string";
30+
case DOM -> "xml";
31+
case JAR -> "jar";
32+
case ANNOTATION -> "annotation";
33+
case OTHER -> "other";
34+
};
3135
}
3236
}

0 commit comments

Comments
 (0)