Skip to content

Commit

Permalink
Rename Builder.flags() to Builder.build()
Browse files Browse the repository at this point in the history
  • Loading branch information
lukellmann committed Aug 7, 2023
1 parent 4255f57 commit b6851f8
Show file tree
Hide file tree
Showing 18 changed files with 151 additions and 36 deletions.
8 changes: 8 additions & 0 deletions common/api/common.api
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public final class dev/kord/common/entity/ActivityFlags$Builder {
public fun <init> ()V
public fun <init> (I)V
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/common/entity/ActivityFlags;
public final fun flags ()Ldev/kord/common/entity/ActivityFlags;
public final fun unaryMinus (Ldev/kord/common/entity/ActivityFlag;)V
public final fun unaryMinus (Ldev/kord/common/entity/ActivityFlags;)V
Expand Down Expand Up @@ -734,6 +735,7 @@ public final class dev/kord/common/entity/ApplicationFlags$Builder {
public fun <init> ()V
public fun <init> (I)V
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/common/entity/ApplicationFlags;
public final fun flags ()Ldev/kord/common/entity/ApplicationFlags;
public final fun unaryMinus (Ldev/kord/common/entity/ApplicationFlag;)V
public final fun unaryMinus (Ldev/kord/common/entity/ApplicationFlags;)V
Expand Down Expand Up @@ -1682,6 +1684,7 @@ public final class dev/kord/common/entity/ChannelFlags$Builder {
public fun <init> ()V
public fun <init> (I)V
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/common/entity/ChannelFlags;
public final fun flags ()Ldev/kord/common/entity/ChannelFlags;
public final fun unaryMinus (Ldev/kord/common/entity/ChannelFlag;)V
public final fun unaryMinus (Ldev/kord/common/entity/ChannelFlags;)V
Expand Down Expand Up @@ -6860,6 +6863,7 @@ public final class dev/kord/common/entity/GuildMemberFlags$Builder {
public fun <init> ()V
public fun <init> (I)V
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/common/entity/GuildMemberFlags;
public final fun flags ()Ldev/kord/common/entity/GuildMemberFlags;
public final fun unaryMinus (Ldev/kord/common/entity/GuildMemberFlag;)V
public final fun unaryMinus (Ldev/kord/common/entity/GuildMemberFlags;)V
Expand Down Expand Up @@ -7462,6 +7466,7 @@ public final class dev/kord/common/entity/MessageFlags$Builder {
public fun <init> ()V
public fun <init> (I)V
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/common/entity/MessageFlags;
public final fun flags ()Ldev/kord/common/entity/MessageFlags;
public final fun unaryMinus (Ldev/kord/common/entity/MessageFlag;)V
public final fun unaryMinus (Ldev/kord/common/entity/MessageFlags;)V
Expand Down Expand Up @@ -8109,6 +8114,7 @@ public final class dev/kord/common/entity/Permissions$Builder {
public fun <init> ()V
public fun <init> (Ldev/kord/common/DiscordBitSet;)V
public synthetic fun <init> (Ldev/kord/common/DiscordBitSet;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/common/entity/Permissions;
public final fun flags ()Ldev/kord/common/entity/Permissions;
public final fun unaryMinus (Ldev/kord/common/entity/Permission;)V
public final fun unaryMinus (Ldev/kord/common/entity/Permissions;)V
Expand Down Expand Up @@ -8544,6 +8550,7 @@ public final class dev/kord/common/entity/SystemChannelFlags$Builder {
public fun <init> ()V
public fun <init> (I)V
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/common/entity/SystemChannelFlags;
public final fun flags ()Ldev/kord/common/entity/SystemChannelFlags;
public final fun unaryMinus (Ldev/kord/common/entity/SystemChannelFlag;)V
public final fun unaryMinus (Ldev/kord/common/entity/SystemChannelFlags;)V
Expand Down Expand Up @@ -8750,6 +8757,7 @@ public final class dev/kord/common/entity/UserFlags$Builder {
public fun <init> ()V
public fun <init> (I)V
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/common/entity/UserFlags;
public final fun flags ()Ldev/kord/common/entity/UserFlags;
public final fun unaryMinus (Ldev/kord/common/entity/UserFlag;)V
public final fun unaryMinus (Ldev/kord/common/entity/UserFlags;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public class ActivityFlags(

public inline fun copy(block: Builder.() -> Unit): ActivityFlags {
contract { callsInPlace(block, EXACTLY_ONCE) }
return Builder(value).apply(block).flags()
return Builder(value).apply(block).build()
}

override fun equals(other: Any?): Boolean = this === other ||
Expand Down Expand Up @@ -141,7 +141,16 @@ public class ActivityFlags(
this@Builder.value = this@Builder.value and this.value.inv()
}

public fun flags(): ActivityFlags = ActivityFlags(value)
public fun build(): ActivityFlags = ActivityFlags(value)

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'build'",
replaceWith = ReplaceWith(expression = "this.build()", imports = arrayOf()),
)
public fun flags(): ActivityFlags = build()
}

internal object Serializer : KSerializer<ActivityFlags> {
Expand All @@ -161,7 +170,7 @@ public class ActivityFlags(

public inline fun ActivityFlags(builder: ActivityFlags.Builder.() -> Unit): ActivityFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
return ActivityFlags.Builder().apply(builder).flags()
return ActivityFlags.Builder().apply(builder).build()
}

public fun ActivityFlags(vararg flags: ActivityFlag): ActivityFlags = ActivityFlags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public class ApplicationFlags(

public inline fun copy(block: Builder.() -> Unit): ApplicationFlags {
contract { callsInPlace(block, EXACTLY_ONCE) }
return Builder(code).apply(block).flags()
return Builder(code).apply(block).build()
}

override fun equals(other: Any?): Boolean = this === other ||
Expand Down Expand Up @@ -162,7 +162,16 @@ public class ApplicationFlags(
this@Builder.code = this@Builder.code and this.code.inv()
}

public fun flags(): ApplicationFlags = ApplicationFlags(code)
public fun build(): ApplicationFlags = ApplicationFlags(code)

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'build'",
replaceWith = ReplaceWith(expression = "this.build()", imports = arrayOf()),
)
public fun flags(): ApplicationFlags = build()
}

internal object Serializer : KSerializer<ApplicationFlags> {
Expand All @@ -183,7 +192,7 @@ public class ApplicationFlags(

public inline fun ApplicationFlags(builder: ApplicationFlags.Builder.() -> Unit): ApplicationFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
return ApplicationFlags.Builder().apply(builder).flags()
return ApplicationFlags.Builder().apply(builder).build()
}

public fun ApplicationFlags(vararg flags: ApplicationFlag): ApplicationFlags = ApplicationFlags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class ChannelFlags(

public inline fun copy(block: Builder.() -> Unit): ChannelFlags {
contract { callsInPlace(block, EXACTLY_ONCE) }
return Builder(code).apply(block).flags()
return Builder(code).apply(block).build()
}

override fun equals(other: Any?): Boolean = this === other ||
Expand Down Expand Up @@ -156,7 +156,16 @@ public class ChannelFlags(
this@Builder.code = this@Builder.code and this.code.inv()
}

public fun flags(): ChannelFlags = ChannelFlags(code)
public fun build(): ChannelFlags = ChannelFlags(code)

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'build'",
replaceWith = ReplaceWith(expression = "this.build()", imports = arrayOf()),
)
public fun flags(): ChannelFlags = build()
}

internal object Serializer : KSerializer<ChannelFlags> {
Expand All @@ -176,7 +185,7 @@ public class ChannelFlags(

public inline fun ChannelFlags(builder: ChannelFlags.Builder.() -> Unit): ChannelFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
return ChannelFlags.Builder().apply(builder).flags()
return ChannelFlags.Builder().apply(builder).build()
}

public fun ChannelFlags(vararg flags: ChannelFlag): ChannelFlags = ChannelFlags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class GuildMemberFlags(

public inline fun copy(block: Builder.() -> Unit): GuildMemberFlags {
contract { callsInPlace(block, EXACTLY_ONCE) }
return Builder(code).apply(block).flags()
return Builder(code).apply(block).build()
}

override fun equals(other: Any?): Boolean = this === other ||
Expand Down Expand Up @@ -154,7 +154,16 @@ public class GuildMemberFlags(
this@Builder.code = this@Builder.code and this.code.inv()
}

public fun flags(): GuildMemberFlags = GuildMemberFlags(code)
public fun build(): GuildMemberFlags = GuildMemberFlags(code)

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'build'",
replaceWith = ReplaceWith(expression = "this.build()", imports = arrayOf()),
)
public fun flags(): GuildMemberFlags = build()
}

internal object Serializer : KSerializer<GuildMemberFlags> {
Expand All @@ -175,7 +184,7 @@ public class GuildMemberFlags(

public inline fun GuildMemberFlags(builder: GuildMemberFlags.Builder.() -> Unit): GuildMemberFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
return GuildMemberFlags.Builder().apply(builder).flags()
return GuildMemberFlags.Builder().apply(builder).build()
}

public fun GuildMemberFlags(vararg flags: GuildMemberFlag): GuildMemberFlags = GuildMemberFlags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class MessageFlags(

public inline fun copy(block: Builder.() -> Unit): MessageFlags {
contract { callsInPlace(block, EXACTLY_ONCE) }
return Builder(code).apply(block).flags()
return Builder(code).apply(block).build()
}

override fun equals(other: Any?): Boolean = this === other ||
Expand Down Expand Up @@ -156,7 +156,16 @@ public class MessageFlags(
this@Builder.code = this@Builder.code and this.code.inv()
}

public fun flags(): MessageFlags = MessageFlags(code)
public fun build(): MessageFlags = MessageFlags(code)

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'build'",
replaceWith = ReplaceWith(expression = "this.build()", imports = arrayOf()),
)
public fun flags(): MessageFlags = build()
}

internal object Serializer : KSerializer<MessageFlags> {
Expand All @@ -176,7 +185,7 @@ public class MessageFlags(

public inline fun MessageFlags(builder: MessageFlags.Builder.() -> Unit): MessageFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
return MessageFlags.Builder().apply(builder).flags()
return MessageFlags.Builder().apply(builder).build()
}

public fun MessageFlags(vararg flags: MessageFlag): MessageFlags = MessageFlags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class Permissions(

public inline fun copy(block: Builder.() -> Unit): Permissions {
contract { callsInPlace(block, EXACTLY_ONCE) }
return Builder(code).apply(block).flags()
return Builder(code).apply(block).build()
}

override fun equals(other: Any?): Boolean = this === other ||
Expand Down Expand Up @@ -141,7 +141,16 @@ public class Permissions(
this@Builder.code.remove(this.code)
}

public fun flags(): Permissions = Permissions(code)
public fun build(): Permissions = Permissions(code)

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'build'",
replaceWith = ReplaceWith(expression = "this.build()", imports = arrayOf()),
)
public fun flags(): Permissions = build()
}

internal object Serializer : KSerializer<Permissions> {
Expand All @@ -162,7 +171,7 @@ public class Permissions(

public inline fun Permissions(builder: Permissions.Builder.() -> Unit): Permissions {
contract { callsInPlace(builder, EXACTLY_ONCE) }
return Permissions.Builder().apply(builder).flags()
return Permissions.Builder().apply(builder).build()
}

public fun Permissions(vararg flags: Permission): Permissions = Permissions { flags.forEach { +it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class SystemChannelFlags(

public inline fun copy(block: Builder.() -> Unit): SystemChannelFlags {
contract { callsInPlace(block, EXACTLY_ONCE) }
return Builder(code).apply(block).flags()
return Builder(code).apply(block).build()
}

override fun equals(other: Any?): Boolean = this === other ||
Expand Down Expand Up @@ -155,7 +155,16 @@ public class SystemChannelFlags(
this@Builder.code = this@Builder.code and this.code.inv()
}

public fun flags(): SystemChannelFlags = SystemChannelFlags(code)
public fun build(): SystemChannelFlags = SystemChannelFlags(code)

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'build'",
replaceWith = ReplaceWith(expression = "this.build()", imports = arrayOf()),
)
public fun flags(): SystemChannelFlags = build()
}

internal object Serializer : KSerializer<SystemChannelFlags> {
Expand All @@ -177,7 +186,7 @@ public class SystemChannelFlags(
public inline fun SystemChannelFlags(builder: SystemChannelFlags.Builder.() -> Unit):
SystemChannelFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
return SystemChannelFlags.Builder().apply(builder).flags()
return SystemChannelFlags.Builder().apply(builder).build()
}

public fun SystemChannelFlags(vararg flags: SystemChannelFlag): SystemChannelFlags =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class UserFlags(

public inline fun copy(block: Builder.() -> Unit): UserFlags {
contract { callsInPlace(block, EXACTLY_ONCE) }
return Builder(code).apply(block).flags()
return Builder(code).apply(block).build()
}

override fun equals(other: Any?): Boolean = this === other ||
Expand Down Expand Up @@ -152,7 +152,16 @@ public class UserFlags(
this@Builder.code = this@Builder.code and this.code.inv()
}

public fun flags(): UserFlags = UserFlags(code)
public fun build(): UserFlags = UserFlags(code)

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'build'",
replaceWith = ReplaceWith(expression = "this.build()", imports = arrayOf()),
)
public fun flags(): UserFlags = build()
}

internal object Serializer : KSerializer<UserFlags> {
Expand All @@ -172,7 +181,7 @@ public class UserFlags(

public inline fun UserFlags(builder: UserFlags.Builder.() -> Unit): UserFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
return UserFlags.Builder().apply(builder).flags()
return UserFlags.Builder().apply(builder).build()
}

public fun UserFlags(vararg flags: UserFlag): UserFlags = UserFlags { flags.forEach { +it } }
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/entity/DiscordApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public data class DiscordPartialApplication(
@JvmName("ApplicationFlags")
public inline fun applicationFlags(builder: ApplicationFlags.Builder.() -> Unit): ApplicationFlags {
contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) }
return ApplicationFlags.Builder().apply(builder).flags()
return ApplicationFlags.Builder().apply(builder).build()
}

@Deprecated("Binary compatibility. Keep for some releases.", level = DeprecationLevel.HIDDEN)
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/entity/DiscordChannel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public data class DiscordChannel(
@JvmName("ChannelFlags")
public inline fun channelFlags(builder: ChannelFlags.Builder.() -> Unit): ChannelFlags {
contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) }
return ChannelFlags.Builder().apply(builder).flags()
return ChannelFlags.Builder().apply(builder).build()
}

@Deprecated("Binary compatibility. Keep for some releases.", level = DeprecationLevel.HIDDEN)
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/entity/DiscordMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public data class DiscordMentionedChannel(
@JvmName("MessageFlags")
public inline fun messageFlags(builder: MessageFlags.Builder.() -> Unit): MessageFlags {
contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) }
return MessageFlags.Builder().apply(builder).flags()
return MessageFlags.Builder().apply(builder).build()
}

@Deprecated("Binary compatibility. Keep for some releases.", level = DeprecationLevel.HIDDEN)
Expand Down
1 change: 1 addition & 0 deletions gateway/api/gateway.api
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,7 @@ public final class dev/kord/gateway/Intents$Builder {
public fun <init> ()V
public fun <init> (Ldev/kord/common/DiscordBitSet;)V
public synthetic fun <init> (Ldev/kord/common/DiscordBitSet;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun build ()Ldev/kord/gateway/Intents;
public final fun flags ()Ldev/kord/gateway/Intents;
public final fun unaryMinus (Ldev/kord/gateway/Intent;)V
public final fun unaryMinus (Ldev/kord/gateway/Intents;)V
Expand Down
Loading

0 comments on commit b6851f8

Please sign in to comment.