Skip to content

Commit

Permalink
Remove deprecated from method in EnumParameterSpec (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
theEvilReaper authored Oct 28, 2024
1 parent 737626c commit 236318c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,6 @@ class EnumParameterSpec internal constructor(
variableRef,
nullable = true
)

/**
* Creates a new [EnumParameterSpec] instance with the given [format] and [args].
* @param format the format string
* @param args the arguments for the format string
* @return the created instance
*/
@JvmStatic
@Deprecated("Use positional instead")
fun from(format: String, vararg args: Any): EnumParameterSpec = EnumParameterSpec(
CodeBlock.of(format, *args),
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class EnumClassTest {
ClassSpec.enumClass("TestEnum")
.enumProperties(
EnumEntrySpec.builder("test")
.parameter(EnumParameterSpec.from("%C", "Test"))
.parameter(EnumParameterSpec.from("%L", "10"))
.parameter(EnumParameterSpec.positional("%C", "Test"))
.parameter(EnumParameterSpec.positional("%L", "10"))
.build()
)
.property(PropertySpec.builder("name", String::class).build())
Expand Down Expand Up @@ -94,18 +94,18 @@ class EnumClassTest {
.enumProperties(
EnumEntrySpec.builder("dashboard")
.parameter {
EnumParameterSpec.from("%C", "Dashboard")
EnumParameterSpec.positional("%C", "Dashboard")
}
.parameter {
EnumParameterSpec.from("%C", "/dashboard")
EnumParameterSpec.positional("%C", "/dashboard")
}
.build(),
EnumEntrySpec.builder("build")
.parameter {
EnumParameterSpec.from("%C", "Build")
EnumParameterSpec.positional("%C", "Build")
}
.parameter {
EnumParameterSpec.from("%C", "/build")
EnumParameterSpec.positional("%C", "/build")
}
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ class EnumEntrySpecTest {
Arguments.of(
EnumEntrySpec.builder("test")
.parameter(
EnumParameterSpec.from("%C", "/dash")
EnumParameterSpec.positional("%C", "/dash")
)
.build(),
"test('/dash')"
),
Arguments.of(
EnumEntrySpec.builder("test")
.parameter(
EnumParameterSpec.from("%L", "10")
EnumParameterSpec.positional("%L", "10")
)
.build(),
"test(10)"
),
Arguments.of(
EnumEntrySpec.builder("dashboard")
.parameter(EnumParameterSpec.from("%C", "Dashboard"))
.parameter(EnumParameterSpec.from("%C", "/dashboard"))
.parameter(EnumParameterSpec.from("%L", "false"))
.parameter(EnumParameterSpec.positional("%C", "Dashboard"))
.parameter(EnumParameterSpec.positional("%C", "/dashboard"))
.parameter(EnumParameterSpec.positional("%L", "false"))
.build(),
"dashboard('Dashboard', '/dashboard', false)"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import java.util.stream.Stream
class PropertyWriterTest {

companion object {

@JvmStatic
private fun simpleProperties(): Stream<Arguments> = Stream.of(
Arguments.of(PropertySpec.builder("id", Int::class).build(), "int id;"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class EnumEntrySpecTest {
Arguments.of(EnumEntrySpec.builder("test").generic(String::class).build(), "test<String>"),
Arguments.of(
EnumEntrySpec.builder("navigation")
.parameter(EnumParameterSpec.from("%C", "/dashboard"))
.parameter(EnumParameterSpec.positional("%C", "/dashboard"))
.build(),
"navigation('/dashboard')"
)
Expand Down Expand Up @@ -56,7 +56,7 @@ class EnumEntrySpecTest {
val propertySpec = EnumEntrySpec
.builder("test")
.generic(String::class)
.parameter(EnumParameterSpec.from("%C", "/dashboard"))
.parameter(EnumParameterSpec.positional("%C", "/dashboard"))
.build()
val specAsBuilder = propertySpec.toBuilder()
assertNotNull(specAsBuilder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EnumParameterSpecTest {
@Test
fun `test enum parameter creation with empty code block`() {
assertThrows<IllegalStateException>("The data block can't be empty") {
EnumParameterSpec.from(EMPTY_STRING, EMPTY_STRING, false)
EnumParameterSpec.positional(EMPTY_STRING, EMPTY_STRING, false)
}
}

Expand All @@ -31,7 +31,7 @@ class EnumParameterSpecTest {

@Test
fun `test enum parameter creation`() {
val parameter = EnumParameterSpec.from("%C", "test")
val parameter = EnumParameterSpec.positional("%C", "test")
assertNotNull(parameter)
assertNotNull(parameter.dataBlock)
assertEquals(1, parameter.dataBlock.args.size)
Expand Down

0 comments on commit 236318c

Please sign in to comment.