Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for ktlint 1.0.0 (ktlint-maven-plugin 3.0.0). #102

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[*.{kt,kts}]
max_line_length = 120

# Comma-separated list of rules to disable (Since 0.34.0)
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
# by the ruleset identifier.
ktlint_code_style = intellij_idea

# I find trailing commas annoying
ktlint_standard_trailing-comma-on-call-site = disabled
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<plugin>
<groupId>com.github.gantsign.maven</groupId>
<artifactId>ktlint-maven-plugin</artifactId>
<version>1.13.1</version>
<version>3.0.0</version>
<configuration>
<sourceRoots>
<sourceRoot>${project.basedir}/src/main/kotlin</sourceRoot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ object Colibri2JSONDeserializer {
private fun deserializeMedia(media: JSONObject): Media {
return Media.getBuilder().apply {
media[Media.TYPE_ATTR_NAME]?.let {
if (it is String) { setType(MediaType.parseString(it)) }
if (it is String) {
setType(MediaType.parseString(it))
}
}

media[Colibri2JSONSerializer.PAYLOAD_TYPES]?.let { payloadTypes ->
Expand All @@ -58,51 +60,69 @@ object Colibri2JSONDeserializer {
}

media[ExtmapAllowMixedPacketExtension.ELEMENT]?.let {
if (it is Boolean) { setExtmapAllowMixed(ExtmapAllowMixedPacketExtension()) }
if (it is Boolean) {
setExtmapAllowMixed(ExtmapAllowMixedPacketExtension())
}
}
}.build()
}

private fun deserializeSctp(sctp: JSONObject): Sctp {
return Sctp.Builder().apply {
sctp[Sctp.ROLE_ATTR_NAME]?.let {
if (it is String) { setRole(Sctp.Role.parseString(it)) }
if (it is String) {
setRole(Sctp.Role.parseString(it))
}
}

sctp[Sctp.PORT_ATTR_NAME]?.let {
if (it is Number) { setPort(it.toInt()) }
if (it is Number) {
setPort(it.toInt())
}
}
}.build()
}

private fun deserializeTransport(transport: JSONObject): Transport {
return Transport.getBuilder().apply {
transport[Transport.ICE_CONTROLLING_ATTR_NAME]?.let {
if (it is Boolean) { setIceControlling(it) }
if (it is Boolean) {
setIceControlling(it)
}
}

transport[Transport.USE_UNIQUE_PORT_ATTR_NAME]?.let {
if (it is Boolean) { setUseUniquePort(it) }
if (it is Boolean) {
setUseUniquePort(it)
}
}

transport[IceUdpTransportPacketExtension.ELEMENT]?.let {
if (it is JSONObject) { setIceUdpExtension(JSONDeserializer.deserializeTransport(it)) }
if (it is JSONObject) {
setIceUdpExtension(JSONDeserializer.deserializeTransport(it))
}
}

transport[Sctp.ELEMENT]?.let {
if (it is JSONObject) { setSctp(deserializeSctp(it)) }
if (it is JSONObject) {
setSctp(deserializeSctp(it))
}
}
}.build()
}

private fun deserializeMediaSource(mediaSource: JSONObject): MediaSource {
return MediaSource.getBuilder().apply {
mediaSource[MediaSource.TYPE_ATTR_NAME]?.let {
if (it is String) { setType(MediaType.parseString(it)) }
if (it is String) {
setType(MediaType.parseString(it))
}
}

mediaSource[MediaSource.ID_NAME]?.let {
if (it is String) { setId(it) }
if (it is String) {
setId(it)
}
}

mediaSource[Colibri2JSONSerializer.SOURCES]?.let { sources ->
Expand All @@ -122,7 +142,9 @@ object Colibri2JSONDeserializer {
private fun deserializeMedias(medias: JSONArray): Collection<Media> {
return ArrayList<Media>().apply {
medias.forEach {
if (it is JSONObject) { add(deserializeMedia(it)) }
if (it is JSONObject) {
add(deserializeMedia(it))
}
}
}
}
Expand All @@ -142,15 +164,21 @@ object Colibri2JSONDeserializer {
builder: AbstractConferenceEntity.Builder
) {
entity[AbstractConferenceEntity.ID_ATTR_NAME]?.let {
if (it is String) { builder.setId(it) }
if (it is String) {
builder.setId(it)
}
}

entity[AbstractConferenceEntity.CREATE_ATTR_NAME]?.let {
if (it is Boolean) { builder.setCreate(it) }
if (it is Boolean) {
builder.setCreate(it)
}
}

entity[AbstractConferenceEntity.EXPIRE_ATTR_NAME]?.let {
if (it is Boolean) { builder.setExpire(it) }
if (it is Boolean) {
builder.setExpire(it)
}
}

entity[Colibri2JSONSerializer.MEDIA_LIST]?.let { medias ->
Expand All @@ -160,11 +188,15 @@ object Colibri2JSONDeserializer {
}

entity[Transport.ELEMENT]?.let {
if (it is JSONObject) { builder.setTransport(deserializeTransport(it)) }
if (it is JSONObject) {
builder.setTransport(deserializeTransport(it))
}
}

entity[Sources.ELEMENT]?.let {
if (it is JSONArray) { builder.setSources(deserializeSources(it)) }
if (it is JSONArray) {
builder.setSources(deserializeSources(it))
}
}
}

Expand All @@ -178,8 +210,16 @@ object Colibri2JSONDeserializer {
val video = forceMute[ForceMute.VIDEO_ATTR_NAME]

return ForceMute(
if (audio is Boolean) { audio } else { ForceMute.AUDIO_DEFAULT },
if (video is Boolean) { video } else { ForceMute.VIDEO_DEFAULT }
if (audio is Boolean) {
audio
} else {
ForceMute.AUDIO_DEFAULT
},
if (video is Boolean) {
video
} else {
ForceMute.VIDEO_DEFAULT
}
)
}

Expand All @@ -188,15 +228,21 @@ object Colibri2JSONDeserializer {
deserializeAbstractConferenceEntityToBuilder(endpoint, this)

endpoint[Colibri2Endpoint.STATS_ID_ATTR_NAME]?.let {
if (it is String) { setStatsId(it) }
if (it is String) {
setStatsId(it)
}
}

endpoint[Colibri2Endpoint.MUC_ROLE_ATTR_NAME]?.let {
if (it is String) { setMucRole(MUCRole.fromString(it)) }
if (it is String) {
setMucRole(MUCRole.fromString(it))
}
}

endpoint[ForceMute.ELEMENT]?.let {
if (it is JSONObject) { setForceMute(deserializeForceMute(it)) }
if (it is JSONObject) {
setForceMute(deserializeForceMute(it))
}
}

endpoint[InitialLastN.ELEMENT]?.let {
Expand All @@ -207,7 +253,11 @@ object Colibri2JSONDeserializer {

endpoint[Colibri2JSONSerializer.CAPABILITIES_LIST]?.let { capabilities ->
if (capabilities is JSONArray) {
capabilities.forEach { if (it is String) { addCapability(it) } }
capabilities.forEach {
if (it is String) {
addCapability(it)
}
}
}
}
}.build()
Expand All @@ -218,7 +268,9 @@ object Colibri2JSONDeserializer {
deserializeAbstractConferenceEntityToBuilder(relay, this)

relay[Colibri2Relay.MESH_ID_ATTR_NAME]?.let {
if (it is String) { setMeshId(it) }
if (it is String) {
setMeshId(it)
}
}

relay[Colibri2JSONSerializer.ENDPOINTS]?.let { endpoints ->
Expand All @@ -236,15 +288,19 @@ object Colibri2JSONDeserializer {
private fun deserializeEndpoints(endpoints: JSONArray): Collection<Colibri2Endpoint> {
return ArrayList<Colibri2Endpoint>().apply {
endpoints.forEach {
if (it is JSONObject) { add(deserializeEndpoint(it)) }
if (it is JSONObject) {
add(deserializeEndpoint(it))
}
}
}
}

private fun deserializeRelays(relays: JSONArray): Collection<Colibri2Relay> {
return ArrayList<Colibri2Relay>().apply {
relays.forEach {
if (it is JSONObject) { add(deserializeRelay(it)) }
if (it is JSONObject) {
add(deserializeRelay(it))
}
}
}
}
Expand Down Expand Up @@ -272,23 +328,33 @@ object Colibri2JSONDeserializer {
deserializeAbstractConferenceModificationToBuilder(conferenceModify, this)

conferenceModify[ConferenceModifyIQ.MEETING_ID_ATTR_NAME]?.let {
if (it is String) { setMeetingId(it) }
if (it is String) {
setMeetingId(it)
}
}

conferenceModify[ConferenceModifyIQ.NAME_ATTR_NAME]?.let {
if (it is String) { setConferenceName(it) }
if (it is String) {
setConferenceName(it)
}
}

conferenceModify[ConferenceModifyIQ.CREATE_ATTR_NAME]?.let {
if (it is Boolean) { setCreate(it) }
if (it is Boolean) {
setCreate(it)
}
}

conferenceModify[ConferenceModifyIQ.EXPIRE_ATTR_NAME]?.let {
if (it is Boolean) { setExpire(it) }
if (it is Boolean) {
setExpire(it)
}
}

conferenceModify[ConferenceModifyIQ.RTCSTATS_ENABLED_ATTR_NAME]?.let {
if (it is Boolean) { setRtcstatsEnabled(it) }
if (it is Boolean) {
setRtcstatsEnabled(it)
}
}
}
}
Expand All @@ -298,7 +364,9 @@ object Colibri2JSONDeserializer {
return ConferenceModifiedIQ.builder("id").apply {
deserializeAbstractConferenceModificationToBuilder(conferenceModified, this)
conferenceModified[Sources.ELEMENT]?.let {
if (it is JSONArray) { setSources(deserializeSources(it)) }
if (it is JSONArray) {
setSources(deserializeSources(it))
}
}
}
}
Expand Down