This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.sourcelabs.kafka.producer | |
import org.slf4j.LoggerFactory | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.boot.CommandLineRunner | |
import org.springframework.boot.SpringApplication | |
import org.springframework.boot.autoconfigure.SpringBootApplication | |
import org.springframework.kafka.core.KafkaTemplate | |
@SpringBootApplication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import brave.Tracer | |
import org.aspectj.lang.ProceedingJoinPoint | |
import org.aspectj.lang.annotation.Around | |
import org.aspectj.lang.annotation.Aspect | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.stereotype.Component | |
@Aspect | |
@Component | |
class TracingAspect { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person { | |
private final String name; | |
private final int age; | |
public Person(String name, int age) { | |
this.name = name; | |
this.age = age; | |
} | |
public String getName() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CallFoo { | |
public static void main(String[] args) { | |
Utils.foo(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Calculator { | |
public int sum(int a, int b, int c) { | |
return a + b + c; | |
} | |
public static void main(String[] args) { | |
Calculator f = new Calculator(); | |
System.out.println(f.sum(0, 1, 2)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val name = "Kotlin" | |
name = "John Doe" | |
println("Hello, $name!") | |
var answer = 21 | |
answer = "42" | |
println("The answer to everything: $answer!") | |
val groceries = listOf("Bread", "Butter", "Milk") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IfWhen { | |
public static boolean yesNoToBoolean(String s) { | |
if ("yes".equals(s)) return true; | |
else if ("no".equals(s)) return false; | |
else throw new RuntimeException("Unsupported value: " + s); | |
} | |
public static void main(String[] args) { | |
System.out.println(yesNoToBoolean("yes")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
public class Loops { | |
public static void main(String[] args) { | |
List<String> list = List.of("a", "b"); | |
for (String s : list) { | |
System.out.println(s); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val houseNumber = "121" | |
val nextHouseNumber = houseNumber + 1 | |
println(nextHouseNumber) // should print 122 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun printLength(str: String?) { | |
val length: Int = str.length | |
print("$str length is $length") | |
} |