Skip to content

Commit 58020ff

Browse files
committed
Stop using Java code snippets in Kotlin ones
As a preparation to using a Kotlin 2 baseline, this commit stops using Java code snippets in Kotlin ones in order to avoid redeclaration errors. See spring-projectsgh-33629
1 parent edce302 commit 58020ff

File tree

16 files changed

+304
-23
lines changed

16 files changed

+304
-23
lines changed

framework-docs/framework-docs.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ repositories {
4141
}
4242
}
4343

44+
// To avoid a redeclaration error with Kotlin compiler
45+
sourceSets {
46+
main {
47+
java.exclude("org/springframework/docs/**/*.java")
48+
}
49+
}
50+
4451
dependencies {
4552
api(project(":spring-aspects"))
4653
api(project(":spring-context"))
@@ -68,6 +75,7 @@ dependencies {
6875
api("org.aspectj:aspectjweaver")
6976
api("org.eclipse.jetty.websocket:jetty-websocket-jetty-api")
7077
api("org.jetbrains.kotlin:kotlin-stdlib")
78+
api("jakarta.websocket:jakarta.websocket-api")
7179

7280
implementation(project(":spring-core-test"))
7381
implementation("org.assertj:assertj-core")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.core.beans.dependencies.beansfactorylazyinit
18+
19+
class AnotherBean {
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.core.beans.dependencies.beansfactorylazyinit
18+
19+
class ExpensiveToCreateBean {
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.core.expressions.expressionsbeandef
18+
19+
class CustomerPreferenceDao {
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
package org.springframework.docs.core.expressions.expressionsbeandef
19+
20+
class MovieFinder {
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.dataaccess.jdbc.jdbccomplextypes
18+
19+
import java.util.Date
20+
21+
data class TestItem(val id: Long, val description: String, val expirationDate: Date)

framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/jdbc/jdbccomplextypes/TestItemStoredProcedure.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class TestItemStoredProcedure(dataSource: DataSource) : StoredProcedure(dataSour
3131
cs: CallableStatement, colIndx: Int, _: Int, _: String? ->
3232
val struct = cs.getObject(colIndx) as Struct
3333
val attr = struct.attributes
34-
val item = TestItem()
35-
item.id = (attr[0] as Number).toLong()
36-
item.description = attr[1] as String
37-
item.expirationDate = attr[2] as Date
38-
item
34+
TestItem(
35+
(attr[0] as Number).toLong(),
36+
attr[1] as String,
37+
attr[2] as Date
38+
)
3939
})
4040
// ...
4141
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.dataaccess.jdbc.jdbcjdbctemplateidioms
18+
19+
interface CorporateEventDao {
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.integration.jmx.jmxexporting
18+
19+
interface IJmxTestBean {
20+
21+
var name: String
22+
var age: Int
23+
fun add(x: Int, y: Int): Int
24+
fun dontExposeMe()
25+
}

framework-docs/src/main/kotlin/org/springframework/docs/integration/jmx/jmxexporting/JmxTestBean.kt

+2-18
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,8 @@ package org.springframework.docs.integration.jmx.jmxexporting
1919
// tag::snippet[]
2020
class JmxTestBean : IJmxTestBean {
2121

22-
private lateinit var name: String
23-
private var age = 0
24-
25-
override fun getAge(): Int {
26-
return age
27-
}
28-
29-
override fun setAge(age: Int) {
30-
this.age = age
31-
}
32-
33-
override fun setName(name: String) {
34-
this.name = name
35-
}
36-
37-
override fun getName(): String {
38-
return name
39-
}
22+
override lateinit var name: String
23+
override var age = 0
4024

4125
override fun add(x: Int, y: Int): Int {
4226
return x + y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.integration.mailusagesimple
18+
19+
data class Customer(
20+
val emailAddress: String,
21+
val firstName: String,
22+
val lastName: String
23+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.integration.mailusagesimple
18+
19+
data class Order(
20+
val customer: Customer,
21+
val orderNumber: String
22+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.testing.mockmvc.assertj.mockmvctestersetup
18+
19+
import org.springframework.web.bind.annotation.RestController
20+
21+
@RestController
22+
class AccountController {
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.testing.mockmvc.assertj.mockmvctestersetup
18+
19+
import org.springframework.context.annotation.Configuration
20+
import org.springframework.web.servlet.config.annotation.EnableWebMvc
21+
22+
@Configuration(proxyBeanMethods = false)
23+
@EnableWebMvc
24+
class ApplicationWebConfiguration {
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.web.webmvc.mvcconfig.mvcconfigvalidation
18+
19+
import org.springframework.validation.Errors
20+
import org.springframework.validation.Validator
21+
22+
class FooValidator : Validator {
23+
override fun supports(clazz: Class<*>) = false
24+
25+
override fun validate(target: Any, errors: Errors) {
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.web.websocket.websocketserverruntimeconfiguration
18+
19+
import org.springframework.web.socket.handler.AbstractWebSocketHandler
20+
21+
class MyEchoHandler : AbstractWebSocketHandler() {
22+
}

0 commit comments

Comments
 (0)