Skip to content

Commit 69c2956

Browse files
committed
add @field:NotNull annotation
1 parent 841be82 commit 69c2956

File tree

2 files changed

+70
-65
lines changed
  • kotlin-insight-client/kotlin-insight-client-api
    • src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model

2 files changed

+70
-65
lines changed

kotlin-insight-client/kotlin-insight-client-api/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@
2222
<artifactId>swagger-annotations</artifactId>
2323
<version>2.2.8</version>
2424
</dependency>
25+
<dependency>
26+
<groupId>javax.validation</groupId>
27+
<artifactId>validation-api</artifactId>
28+
<version>2.0.1.Final</version>
29+
</dependency>
2530
</dependencies>
2631
</project>

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model/Model.kt

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,37 @@ import java.util.Collections.emptyList
2828
// region ID wrapper
2929

3030
@JvmInline
31-
value class InsightObjectId(val raw: Int) {
31+
value class InsightObjectId(@field:NotNull val raw: Int) {
3232
companion object {
3333
val notPersistedObjectId = InsightObjectId(-1)
3434
}
3535
}
3636

3737
@JvmInline
38-
value class InsightObjectTypeId(val raw: Int)
38+
value class InsightObjectTypeId(@field:NotNull val raw: Int)
3939

4040
@JvmInline
41-
value class AttachmentId(val raw: Int)
41+
value class AttachmentId(@field:NotNull val raw: Int)
4242

4343
@JvmInline
44-
value class InsightSchemaId(val raw: Int)
44+
value class InsightSchemaId(@field:NotNull val raw: Int)
4545

4646
@JvmInline
47-
value class InsightAttributeId(val raw: Int)
47+
value class InsightAttributeId(@field:NotNull val raw: Int)
4848

4949
// endregion ID wrapper
5050

5151
data class InsightObjectPage<T>(
52-
val totalFilterCount: Int = -1,
53-
val objects: List<T> = emptyList(),
52+
@field:NotNull val totalFilterCount: Int = -1,
53+
@field:NotNull val objects: List<T> = emptyList(),
5454
)
5555

5656
data class Page<T> (
57-
val items: List<T>,
58-
val totalItems: Int,
59-
val totalPages: Int,
60-
val currentPageIndex: Int,
61-
val pageSize: Int
57+
@field:NotNull val items: List<T>,
58+
@field:NotNull val totalItems: Int,
59+
@field:NotNull val totalPages: Int,
60+
@field:NotNull val currentPageIndex: Int,
61+
@field:NotNull val pageSize: Int
6262
)
6363

6464
fun <T> InsightObjectPage<T>.plus(insightObjectPage: InsightObjectPage<T>): InsightObjectPage<T> =
@@ -69,25 +69,25 @@ fun <T> InsightObjectPage<T>.plus(insightObjectPage: InsightObjectPage<T>): Insi
6969

7070
data class InsightObject(
7171
@get:JvmName("getObjectTypeId")
72-
val objectTypeId: InsightObjectTypeId,
72+
@field:NotNull val objectTypeId: InsightObjectTypeId,
7373
@get:JvmName("getId")
74-
val id: InsightObjectId,
75-
val objectTypeName: String,
76-
val objectKey: String,
77-
val label: String,
78-
var attributes: List<InsightAttribute>,
79-
val attachmentsExist: Boolean,
80-
val objectSelf: String
74+
@field:NotNull val id: InsightObjectId,
75+
@field:NotNull val objectTypeName: String,
76+
@field:NotNull val objectKey: String,
77+
@field:NotNull val label: String,
78+
@field:NotNull var attributes: List<InsightAttribute>,
79+
@field:NotNull val attachmentsExist: Boolean,
80+
@field:NotNull val objectSelf: String
8181
)
8282

8383
data class InsightReference(
8484
@get:JvmName("getObjectTypeId")
85-
val objectTypeId: InsightObjectTypeId,
86-
val objectTypeName: String,
85+
@field:NotNull val objectTypeId: InsightObjectTypeId,
86+
@field:NotNull val objectTypeName: String,
8787
@get:JvmName("getObjectId")
88-
val objectId: InsightObjectId,
89-
val objectKey: String,
90-
val objectName: String
88+
@field:NotNull val objectId: InsightObjectId,
89+
@field:NotNull val objectKey: String,
90+
@field:NotNull val objectName: String
9191
)
9292

9393
/**
@@ -119,7 +119,7 @@ data class InsightReference(
119119
)
120120
sealed class InsightAttribute(
121121
@get:JvmName("getAttributeId")
122-
val attributeId: InsightAttributeId,
122+
@field:NotNull val attributeId: InsightAttributeId,
123123
val schema: ObjectTypeSchemaAttribute?
124124
) {
125125
fun isValueAttribute(): Boolean = when(this){
@@ -167,8 +167,8 @@ sealed class InsightAttribute(
167167
class Select(attributeId: InsightAttributeId,val values: List<String>, schema: ObjectTypeSchemaAttribute?) : InsightAttribute(attributeId, schema)
168168

169169
// non default types
170-
class Reference(attributeId: InsightAttributeId,val referencedObjects: List<ReferencedObject>, schema: ObjectTypeSchemaAttribute?) : InsightAttribute(attributeId, schema)
171-
class User(attributeId: InsightAttributeId,val users: List<InsightUser>, schema: ObjectTypeSchemaAttribute?) : InsightAttribute(attributeId, schema)
170+
class Reference(attributeId: InsightAttributeId,@field:NotNull val referencedObjects: List<ReferencedObject>, schema: ObjectTypeSchemaAttribute?) : InsightAttribute(attributeId, schema)
171+
class User(attributeId: InsightAttributeId,@field:NotNull val users: List<InsightUser>, schema: ObjectTypeSchemaAttribute?) : InsightAttribute(attributeId, schema)
172172
class Confluence(attributeId: InsightAttributeId, schema: ObjectTypeSchemaAttribute?) : InsightAttribute(attributeId, schema) // A value that describes a page in Confluence
173173
class Group(attributeId: InsightAttributeId, schema: ObjectTypeSchemaAttribute?) : InsightAttribute(attributeId, schema) // The Insight Group type
174174
class Version(attributeId: InsightAttributeId, schema: ObjectTypeSchemaAttribute?) : InsightAttribute(attributeId, schema) // Value describing a version in Jira
@@ -262,9 +262,9 @@ sealed class InsightAttribute(
262262
// region InsightObjectTypeOperator
263263
data class ObjectTypeSchema(
264264
@get:JvmName("getId")
265-
val id: InsightObjectTypeId,
266-
val name: String,
267-
val attributes: List<ObjectTypeSchemaAttribute>,
265+
@field:NotNull val id: InsightObjectTypeId,
266+
@field:NotNull val name: String,
267+
@field:NotNull val attributes: List<ObjectTypeSchemaAttribute>,
268268
@get:JvmName("getParentObjectTypeId")
269269
val parentObjectTypeId: InsightObjectTypeId?
270270
)
@@ -295,11 +295,11 @@ data class ObjectTypeSchema(
295295
)
296296
sealed class ObjectTypeSchemaAttribute(
297297
@get:JvmName("getId")
298-
val id: InsightAttributeId,
299-
val name: String, // attributeName
300-
val minimumCardinality: Int,
301-
val maximumCardinality: Int,
302-
val includeChildObjectTypes: Boolean
298+
@field:NotNull val id: InsightAttributeId,
299+
@field:NotNull val name: String, // attributeName
300+
@field:NotNull val minimumCardinality: Int,
301+
@field:NotNull val maximumCardinality: Int,
302+
@field:NotNull val includeChildObjectTypes: Boolean
303303
) {
304304

305305
fun isValueAttribute(): Boolean = when(this){
@@ -334,7 +334,7 @@ sealed class ObjectTypeSchemaAttribute(
334334
minimumCardinality: Int,
335335
maximumCardinality: Int,
336336
includeChildObjectTypes: Boolean,
337-
val options: List<String>,
337+
@field:NotNull val options: List<String>,
338338
) : ObjectTypeSchemaAttribute(id, name, minimumCardinality, maximumCardinality, includeChildObjectTypes)
339339

340340
class ReferenceSchema(
@@ -344,8 +344,8 @@ sealed class ObjectTypeSchemaAttribute(
344344
maximumCardinality: Int,
345345
includeChildObjectTypes: Boolean,
346346
@get:JvmName("getReferenceObjectTypeId")
347-
val referenceObjectTypeId: InsightObjectTypeId, // objectTypeId of the referenced object
348-
val referenceKind: ReferenceKind
347+
@field:NotNull val referenceObjectTypeId: InsightObjectTypeId, // objectTypeId of the referenced object
348+
@field:NotNull val referenceKind: ReferenceKind
349349
) : ObjectTypeSchemaAttribute(id, name, minimumCardinality, maximumCardinality, includeChildObjectTypes)
350350

351351
class UnknownSchema(
@@ -354,7 +354,7 @@ sealed class ObjectTypeSchemaAttribute(
354354
minimumCardinality: Int,
355355
maximumCardinality: Int,
356356
includeChildObjectTypes: Boolean,
357-
val debugDescription: String
357+
@field:NotNull val debugDescription: String
358358
) : ObjectTypeSchemaAttribute(id, name, minimumCardinality, maximumCardinality, includeChildObjectTypes)
359359

360360
// region types having just the superclass attributes
@@ -504,18 +504,18 @@ enum class ReferenceKind(var referenceKindId: Int) {
504504
// region InsightSchemaOperator
505505
data class InsightSchema(
506506
@get:JvmName("getId")
507-
val id: InsightSchemaId,
508-
val name: String,
509-
val objectCount: Int,
510-
val objectTypeCount: Int
507+
@field:NotNull val id: InsightSchemaId,
508+
@field:NotNull val name: String,
509+
@field:NotNull val objectCount: Int,
510+
@field:NotNull val objectTypeCount: Int
511511
)
512512
// endregion InsightSchemaOperator
513513

514514
data class InsightUser(
515-
val displayName: String,
516-
val name: String,
517-
val emailAddress: String,
518-
val key: String
515+
@field:NotNull val displayName: String,
516+
@field:NotNull val name: String,
517+
@field:NotNull val emailAddress: String,
518+
@field:NotNull val key: String
519519
)
520520

521521
data class ReferencedObject(
@@ -527,26 +527,26 @@ data class ReferencedObject(
527527

528528
data class ReferencedObjectType(
529529
@get:JvmName("getId")
530-
val id: InsightObjectTypeId,
531-
val name: String
530+
@field:NotNull val id: InsightObjectTypeId,
531+
@field:NotNull val name: String
532532
)
533533

534534
// region InsightHistoryOperator
535535
data class InsightHistory(
536536
@get:JvmName("getObjectId")
537-
val objectId: InsightObjectId,
538-
val historyItems: List<InsightHistoryItem>
537+
@field:NotNull val objectId: InsightObjectId,
538+
@field:NotNull val historyItems: List<InsightHistoryItem>
539539
)
540540

541541
data class InsightHistoryItem(
542-
val id: Int,
542+
@field:NotNull val id: Int,
543543
val affectedAttribute: String?,
544544
val oldValue: String?,
545545
val newValue: String?,
546-
val actor: Actor,
547-
val type: Int,
548-
val created: String, // updated is neither available through sdk nor ktor
549-
val objectId: InsightObjectId
546+
@field:NotNull val actor: Actor,
547+
@field:NotNull val type: Int,
548+
@field:NotNull val created: String, // updated is neither available through sdk nor ktor
549+
@field:NotNull val objectId: InsightObjectId
550550
)
551551

552552
data class Actor(
@@ -557,13 +557,13 @@ data class Actor(
557557
// region InsightAttachmentOperator
558558
data class InsightAttachment(
559559
@get:JvmName("getId")
560-
val id: AttachmentId,
561-
val author: String,
562-
val mimeType: String,
563-
val filename: String,
564-
val filesize: String, // for human display e.g. 10.1 kB
565-
val created: String, // ISO 8601 String
566-
val comment: String, // we are only able to download them but can not create attachments with comments
567-
val url: String
560+
@field:NotNull val id: AttachmentId,
561+
@field:NotNull val author: String,
562+
@field:NotNull val mimeType: String,
563+
@field:NotNull val filename: String,
564+
@field:NotNull val filesize: String, // for human display e.g. 10.1 kB
565+
@field:NotNull val created: String, // ISO 8601 String
566+
@field:NotNull val comment: String, // we are only able to download them but can not create attachments with comments
567+
@field:NotNull val url: String
568568
)
569569
// endregion InsightAttachmentOperator

0 commit comments

Comments
 (0)