This file contains hidden or 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 com.example.demo; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.TimeUnit; | |
import org.apache.kafka.clients.consumer.ConsumerRecord; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.CommandLineRunner; |
This file contains hidden or 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 com.example.demo; | |
import static org.junit.Assert.assertTrue; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.TimeUnit; | |
import org.apache.kafka.clients.consumer.ConsumerConfig; |
This file contains hidden or 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 com.example.demo; | |
import static org.junit.Assert.assertTrue; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.TimeUnit; | |
import org.apache.kafka.clients.consumer.ConsumerConfig; |
This file contains hidden or 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 com.example.demo; | |
import java.util.Arrays; | |
import java.util.Properties; | |
import java.util.concurrent.ExecutionException; | |
import java.util.stream.IntStream; | |
import org.apache.kafka.clients.consumer.ConsumerConfig; | |
import org.apache.kafka.clients.consumer.ConsumerRecords; | |
import org.apache.kafka.clients.consumer.KafkaConsumer; |
This file contains hidden or 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
KStreamBuilder builder = new KStreamBuilder(); | |
KStream<String, String> source = builder.stream("streams-file-input"); | |
KTable<String, Long> counts = source | |
.flatMapValues(value -> Arrays.asList(value.toLowerCase(Locale.getDefault()).split(" "))) | |
.map((key, value) -> new KeyValue<>(value, value)) | |
.countByKey("Counts"); | |
counts.to(Serdes.String(), Serdes.Long(), "streams-wordcount-output"); | |
KafkaStreams streams = new KafkaStreams(builder, props()); |
This file contains hidden or 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 com.example; | |
import static org.hamcrest.CoreMatchers.is; | |
import static org.hamcrest.MatcherAssert.assertThat; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.LinkedHashSet; | |
import java.util.Set; |
This file contains hidden or 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 org.glassfish.jersey.internal.util.collection.Ref; | |
import org.junit.Test; | |
import javax.servlet.http.HttpServletRequest; | |
import java.lang.reflect.ParameterizedType; | |
import java.lang.reflect.Type; | |
import static org.hamcrest.CoreMatchers.*; | |
import static org.junit.Assert.*; |
This file contains hidden or 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 stream; | |
import org.hamcrest.CoreMatchers; | |
import org.junit.Assert; | |
import org.junit.Test; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.function.BinaryOperator; |
This file contains hidden or 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 Result execute(Input in) { | |
checkNotNull(in, "In is null."); | |
try { | |
Integer productId = in.getSelected(); | |
checkProductId(productId); | |
List<Integer> inputCoins = in.getCoins(); | |
checkInputCoins(inputCoins); | |
Product product = dao.findById(productId); |
This file contains hidden or 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 janken; | |
import java.util.EnumMap; | |
public class じゃんけん { | |
public enum Result { | |
あいこ, 負け, 勝ち | |
} |