Skip to content

Commit 1150593

Browse files
authored
KTLN-507 source code (#871)
* KTLN-507 source code * KTLN-507 Core review fixes
1 parent 13d56ac commit 1150593

File tree

2 files changed

+39
-0
lines changed
  • core-kotlin-modules/core-kotlin-10/src/main

2 files changed

+39
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.baeldung;
2+
3+
public class StringWrapper {
4+
private final String source;
5+
6+
public StringWrapper(String source) {
7+
this.source = source;
8+
}
9+
10+
public boolean containsIgnoreCase(String other) {
11+
if (source == null) {
12+
return false;
13+
}
14+
15+
return source.toLowerCase().contains(other.toLowerCase());
16+
}
17+
18+
public String getSource() {
19+
return source;
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.baeldung.access_private_members_from_extension_func
2+
3+
class Main {
4+
fun String?.containsIgnoreCase(target: String) : Boolean {
5+
if (this == null) {
6+
return false
7+
}
8+
9+
val loadedClass = String::class
10+
val valueField = loadedClass.java.getDeclaredField("value")
11+
valueField?.isAccessible = true
12+
val actualValue = valueField?.get(this) as? ByteArray
13+
14+
println(actualValue?.contentToString())
15+
16+
return this.lowercase().contains(target.lowercase())
17+
}
18+
}

0 commit comments

Comments
 (0)