1
+ package io .kurrent .dbclient .v2 ;
2
+
3
+ import java .time .OffsetDateTime ;
4
+ import java .util .Objects ;
5
+
6
+ /**
7
+ * Represents a registered schema with its metadata.
8
+ */
9
+ public class RegisteredSchema {
10
+ /**
11
+ * Represents an empty or unspecified registered schema.
12
+ */
13
+ public static final RegisteredSchema NONE = new RegisteredSchema ();
14
+
15
+ private final String schemaName ;
16
+ private final SchemaDataFormat dataFormat ;
17
+ private final String schemaVersionId ;
18
+ private final String definition ;
19
+ private final int versionNumber ;
20
+ private final OffsetDateTime createdAt ;
21
+
22
+ /**
23
+ * Creates a default instance with null or default values.
24
+ */
25
+ private RegisteredSchema () {
26
+ this .schemaName = null ;
27
+ this .dataFormat = SchemaDataFormat .UNSPECIFIED ;
28
+ this .schemaVersionId = null ;
29
+ this .definition = null ;
30
+ this .versionNumber = 0 ;
31
+ this .createdAt = OffsetDateTime .now ();
32
+ }
33
+
34
+ /**
35
+ * Creates a new instance of RegisteredSchema with the specified values.
36
+ *
37
+ * @param schemaName The name of the schema.
38
+ * @param dataFormat The data format of the schema.
39
+ * @param schemaVersionId The version ID of the schema.
40
+ * @param definition The definition of the schema.
41
+ * @param versionNumber The version number of the schema.
42
+ * @param createdAt The creation timestamp of the schema.
43
+ */
44
+ public RegisteredSchema (
45
+ String schemaName ,
46
+ SchemaDataFormat dataFormat ,
47
+ String schemaVersionId ,
48
+ String definition ,
49
+ int versionNumber ,
50
+ OffsetDateTime createdAt ) {
51
+ this .schemaName = schemaName ;
52
+ this .dataFormat = dataFormat ;
53
+ this .schemaVersionId = schemaVersionId ;
54
+ this .definition = definition ;
55
+ this .versionNumber = versionNumber ;
56
+ this .createdAt = createdAt ;
57
+ }
58
+
59
+ /**
60
+ * Gets the schema name.
61
+ *
62
+ * @return The schema name.
63
+ */
64
+ public String getSchemaName () {
65
+ return schemaName ;
66
+ }
67
+
68
+ /**
69
+ * Gets the data format.
70
+ *
71
+ * @return The data format.
72
+ */
73
+ public SchemaDataFormat getDataFormat () {
74
+ return dataFormat ;
75
+ }
76
+
77
+ /**
78
+ * Gets the schema version ID.
79
+ *
80
+ * @return The schema version ID.
81
+ */
82
+ public String getSchemaVersionId () {
83
+ return schemaVersionId ;
84
+ }
85
+
86
+ /**
87
+ * Gets the schema definition.
88
+ *
89
+ * @return The schema definition.
90
+ */
91
+ public String getDefinition () {
92
+ return definition ;
93
+ }
94
+
95
+ /**
96
+ * Gets the version number.
97
+ *
98
+ * @return The version number.
99
+ */
100
+ public int getVersionNumber () {
101
+ return versionNumber ;
102
+ }
103
+
104
+ /**
105
+ * Gets the creation timestamp.
106
+ *
107
+ * @return The creation timestamp.
108
+ */
109
+ public OffsetDateTime getCreatedAt () {
110
+ return createdAt ;
111
+ }
112
+
113
+ /**
114
+ * Converts this registered schema to a SchemaInfo object.
115
+ *
116
+ * @return A new SchemaInfo instance.
117
+ */
118
+ public SchemaInfo toSchemaInfo () {
119
+ return new SchemaInfo (schemaName , dataFormat );
120
+ }
121
+
122
+ @ Override
123
+ public boolean equals (Object o ) {
124
+ if (this == o ) return true ;
125
+ if (o == null || getClass () != o .getClass ()) return false ;
126
+ RegisteredSchema that = (RegisteredSchema ) o ;
127
+ return versionNumber == that .versionNumber &&
128
+ Objects .equals (schemaName , that .schemaName ) &&
129
+ dataFormat == that .dataFormat &&
130
+ Objects .equals (schemaVersionId , that .schemaVersionId ) &&
131
+ Objects .equals (definition , that .definition ) &&
132
+ Objects .equals (createdAt , that .createdAt );
133
+ }
134
+
135
+ @ Override
136
+ public int hashCode () {
137
+ return Objects .hash (schemaName , dataFormat , schemaVersionId , definition , versionNumber , createdAt );
138
+ }
139
+
140
+ @ Override
141
+ public String toString () {
142
+ return "RegisteredSchema{" +
143
+ "schemaName='" + schemaName + '\'' +
144
+ ", dataFormat=" + dataFormat +
145
+ ", schemaVersionId='" + schemaVersionId + '\'' +
146
+ ", definition='" + definition + '\'' +
147
+ ", versionNumber=" + versionNumber +
148
+ ", createdAt=" + createdAt +
149
+ '}' ;
150
+ }
151
+ }
0 commit comments