diff --git a/algorithms-genetic/pom.xml b/algorithms-genetic/pom.xml index 1c9224aff2..00c9b88dfe 100644 --- a/algorithms-genetic/pom.xml +++ b/algorithms-genetic/pom.xml @@ -50,4 +50,4 @@ 1.11 - + \ No newline at end of file diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/RouteFinder.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/RouteFinder.java index 35458093c5..f8b66fec88 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/RouteFinder.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/RouteFinder.java @@ -8,6 +8,9 @@ import java.util.PriorityQueue; import java.util.Queue; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class RouteFinder { private final Graph graph; private final Scorer nextNodeScorer; @@ -28,11 +31,11 @@ public class RouteFinder { openSet.add(start); while (!openSet.isEmpty()) { - System.out.println("Open Set contains: " + openSet.stream().map(RouteNode::getCurrent).collect(Collectors.toSet())); + log.debug("Open Set contains: " + openSet.stream().map(RouteNode::getCurrent).collect(Collectors.toSet())); RouteNode next = openSet.poll(); - System.out.println("Looking at node: " + next); + log.debug("Looking at node: " + next); if (next.getCurrent().equals(to)) { - System.out.println("Found our destination!"); + log.debug("Found our destination!"); List route = new ArrayList<>(); RouteNode current = next; @@ -41,7 +44,7 @@ public class RouteFinder { current = allNodes.get(current.getPrevious()); } while (current != null); - System.out.println("Route: " + route); + log.debug("Route: " + route); return route; } @@ -55,7 +58,7 @@ public class RouteFinder { nextNode.setRouteScore(newScore); nextNode.setEstimatedScore(newScore + targetScorer.computeCost(connection, to)); openSet.add(nextNode); - System.out.println("Found a better route to node: " + nextNode); + log.debug("Found a better route to node: " + nextNode); } }); } diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/underground/RouteFinderIntegrationTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/underground/RouteFinderIntegrationTest.java index 1e4ad56d94..aba7f149da 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/underground/RouteFinderIntegrationTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/underground/RouteFinderIntegrationTest.java @@ -1,5 +1,7 @@ package com.baeldung.algorithms.astar.underground; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -10,9 +12,13 @@ import java.util.stream.Stream; import com.baeldung.algorithms.astar.Graph; import com.baeldung.algorithms.astar.RouteFinder; + +import lombok.extern.slf4j.Slf4j; + import org.junit.Before; import org.junit.Test; +@Slf4j public class RouteFinderIntegrationTest { private Graph underground; @@ -637,7 +643,8 @@ public class RouteFinderIntegrationTest { @Test public void findRoute() { List route = routeFinder.findRoute(underground.getNode("74"), underground.getNode("7")); + assertThat(route).size().isPositive(); - System.out.println(route.stream().map(Station::getName).collect(Collectors.toList())); + route.stream().map(Station::getName).collect(Collectors.toList()).forEach(station -> log.debug(station)); } } diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/prim/PrimUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/prim/PrimUnitTest.java index 41e53fc9f2..fac3b3a81f 100644 --- a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/prim/PrimUnitTest.java +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/prim/PrimUnitTest.java @@ -1,10 +1,10 @@ package com.baeldung.algorithms.prim; +import org.junit.Test; + import java.util.ArrayList; import java.util.List; -import org.junit.Test; - public class PrimUnitTest { @Test diff --git a/algorithms-searching/src/main/java/com/baeldung/algorithms/dfs/Graph.java b/algorithms-searching/src/main/java/com/baeldung/algorithms/dfs/Graph.java index d2cc723cf9..4623dbb7a4 100644 --- a/algorithms-searching/src/main/java/com/baeldung/algorithms/dfs/Graph.java +++ b/algorithms-searching/src/main/java/com/baeldung/algorithms/dfs/Graph.java @@ -29,11 +29,13 @@ public class Graph { stack.push(start); while (!stack.isEmpty()) { int current = stack.pop(); - isVisited[current] = true; - visit(current); - for (int dest : adjVertices.get(current)) { - if (!isVisited[dest]) - stack.push(dest); + if(!isVisited[current]){ + isVisited[current] = true; + visit(current); + for (int dest : adjVertices.get(current)) { + if (!isVisited[dest]) + stack.push(dest); + } } } } diff --git a/algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java b/algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java index eb58c2bfab..b6b29ede78 100644 --- a/algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java +++ b/algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java @@ -8,7 +8,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SuffixTree { + private static final Logger LOGGER = LoggerFactory.getLogger(SuffixTree.class); + private static final String WORD_TERMINATION = "$"; private static final int POSITION_UNDEFINED = -1; private Node root; @@ -23,7 +25,7 @@ public class SuffixTree { } public List searchText(String pattern) { - LOGGER.info("Searching for pattern \"{}\"", pattern); + LOGGER.debug("Searching for pattern \"{}\"", pattern); List result = new ArrayList<>(); List nodes = getAllNodesInTraversePath(pattern, root, false); @@ -41,11 +43,11 @@ public class SuffixTree { } private void addSuffix(String suffix, int position) { - LOGGER.info(">>>>>>>>>>>> Adding new suffix {}", suffix); + LOGGER.debug(">>>>>>>>>>>> Adding new suffix {}", suffix); List nodes = getAllNodesInTraversePath(suffix, root, true); if (nodes.size() == 0) { addChildNode(root, suffix, position); - LOGGER.info("{}", printTree()); + LOGGER.debug("{}", printTree()); } else { Node lastNode = nodes.remove(nodes.size() - 1); String newText = suffix; @@ -58,7 +60,7 @@ public class SuffixTree { newText = newText.substring(existingSuffixUptoLastNode.length()); } extendNode(lastNode, newText, position); - LOGGER.info("{}", printTree()); + LOGGER.debug("{}", printTree()); } } diff --git a/algorithms-searching/src/test/java/com/baeldung/algorithms/dfs/GraphUnitTest.java b/algorithms-searching/src/test/java/com/baeldung/algorithms/dfs/GraphUnitTest.java index 715bb55fcb..7af25a85ca 100644 --- a/algorithms-searching/src/test/java/com/baeldung/algorithms/dfs/GraphUnitTest.java +++ b/algorithms-searching/src/test/java/com/baeldung/algorithms/dfs/GraphUnitTest.java @@ -2,7 +2,6 @@ package com.baeldung.algorithms.dfs; import java.util.List; -import com.baeldung.algorithms.dfs.Graph; import org.junit.Test; public class GraphUnitTest { diff --git a/algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java b/algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java index 0b58ae9f14..faf06ced31 100644 --- a/algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java +++ b/algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java @@ -10,7 +10,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class QuadTreeSearchUnitTest { - + private static final Logger LOGGER = LoggerFactory.getLogger(QuadTreeSearchUnitTest.class); private static QuadTree quadTree; @@ -20,41 +20,41 @@ public class QuadTreeSearchUnitTest { Region area = new Region(0, 0, 400, 400); quadTree = new QuadTree(area); - float[][] points = new float[][] { { 21, 25 }, { 55, 53 }, { 70, 318 }, { 98, 302 }, + float[][] points = new float[][] { { 21, 25 }, { 55, 53 }, { 70, 318 }, { 98, 302 }, { 49, 229 }, { 135, 229 }, { 224, 292 }, { 206, 321 }, { 197, 258 }, { 245, 238 } }; for (int i = 0; i < points.length; i++) { Point point = new Point(points[i][0], points[i][1]); quadTree.addPoint(point); } - LOGGER.info("\n" + quadTree.printTree("")); - LOGGER.info("=============================================="); + LOGGER.debug("\n" + quadTree.printTree("")); + LOGGER.debug("=============================================="); } @Test public void givenQuadTree_whenSearchingForRange_thenReturn1MatchingItem() { Region searchArea = new Region(200, 200, 250, 250); List result = quadTree.search(searchArea, null, ""); - LOGGER.info(result.toString()); - LOGGER.info(quadTree.printSearchTraversePath()); - + LOGGER.debug(result.toString()); + LOGGER.debug(quadTree.printSearchTraversePath()); + Assert.assertEquals(1, result.size()); - Assert.assertArrayEquals(new float[] { 245, 238 }, + Assert.assertArrayEquals(new float[] { 245, 238 }, new float[]{result.get(0).getX(), result.get(0).getY() }, 0); } - + @Test public void givenQuadTree_whenSearchingForRange_thenReturn2MatchingItems() { Region searchArea = new Region(0, 0, 100, 100); List result = quadTree.search(searchArea, null, ""); - LOGGER.info(result.toString()); - LOGGER.info(quadTree.printSearchTraversePath()); - + LOGGER.debug(result.toString()); + LOGGER.debug(quadTree.printSearchTraversePath()); + Assert.assertEquals(2, result.size()); - Assert.assertArrayEquals(new float[] { 21, 25 }, + Assert.assertArrayEquals(new float[] { 21, 25 }, new float[]{result.get(0).getX(), result.get(0).getY() }, 0); - Assert.assertArrayEquals(new float[] { 55, 53 }, + Assert.assertArrayEquals(new float[] { 55, 53 }, new float[]{result.get(1).getX(), result.get(1).getY() }, 0); - + } } diff --git a/apache-kafka/README.md b/apache-kafka/README.md index 5e724f95b6..8a1d748482 100644 --- a/apache-kafka/README.md +++ b/apache-kafka/README.md @@ -3,7 +3,7 @@ This module contains articles about Apache Kafka. ### Relevant articles -- [Kafka Streams vs Kafka Consumer](https://www.baeldung.com/java-kafka-streams-vs-kafka-consumer) +- [Kafka Streams vs. Kafka Consumer](https://www.baeldung.com/java-kafka-streams-vs-kafka-consumer) - [Kafka Topic Creation Using Java](https://www.baeldung.com/kafka-topic-creation) - [Using Kafka MockConsumer](https://www.baeldung.com/kafka-mockconsumer) - [Using Kafka MockProducer](https://www.baeldung.com/kafka-mockproducer) @@ -12,7 +12,8 @@ This module contains articles about Apache Kafka. - [Kafka Connect Example with MQTT and MongoDB](https://www.baeldung.com/kafka-connect-mqtt-mongodb) - [Building a Data Pipeline with Flink and Kafka](https://www.baeldung.com/kafka-flink-data-pipeline) - [Exactly Once Processing in Kafka with Java](https://www.baeldung.com/kafka-exactly-once) +- [Custom Serializers in Apache Kafka](https://www.baeldung.com/kafka-custom-serializer) ##### Building the project -You can build the project from the command line using: *mvn clean install*, or in an IDE. \ No newline at end of file +You can build the project from the command line using: *mvn clean install*, or in an IDE. diff --git a/apache-kafka/pom.xml b/apache-kafka/pom.xml index cda91ed92f..8003743f95 100644 --- a/apache-kafka/pom.xml +++ b/apache-kafka/pom.xml @@ -161,6 +161,12 @@ spark-cassandra-connector-java_2.11 ${com.datastax.spark.spark-cassandra-connector-java.version} + + org.projectlombok + lombok + ${lombok.version} + provided + @@ -175,6 +181,7 @@ 0.8.1-spark3.0-s_2.12 2.5.2 1.6.0-M1 + 1.18.20 \ No newline at end of file diff --git a/apache-kafka/src/main/java/com/baeldung/kafka/dto/MessageDto.java b/apache-kafka/src/main/java/com/baeldung/kafka/dto/MessageDto.java new file mode 100644 index 0000000000..7f9e206358 --- /dev/null +++ b/apache-kafka/src/main/java/com/baeldung/kafka/dto/MessageDto.java @@ -0,0 +1,15 @@ +package com.baeldung.kafka.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class MessageDto { + private String message; + private String version; +} diff --git a/apache-kafka/src/main/java/com/baeldung/kafka/serdes/CustomDeserializer.java b/apache-kafka/src/main/java/com/baeldung/kafka/serdes/CustomDeserializer.java new file mode 100644 index 0000000000..ee6e79dcd1 --- /dev/null +++ b/apache-kafka/src/main/java/com/baeldung/kafka/serdes/CustomDeserializer.java @@ -0,0 +1,35 @@ +package com.baeldung.kafka.serdes; + +import com.baeldung.kafka.dto.MessageDto; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.kafka.common.errors.SerializationException; +import org.apache.kafka.common.serialization.Deserializer; + +import java.util.Map; + +public class CustomDeserializer implements Deserializer { + + private ObjectMapper objectMapper = new ObjectMapper(); + + @Override + public void configure(Map configs, boolean isKey) { + } + + @Override + public MessageDto deserialize(String topic, byte[] data) { + try { + if (data == null){ + System.out.println("Null received at deserializing"); + return null; + } + System.out.println("Deserializing..."); + return objectMapper.readValue(new String(data, "UTF-8"), MessageDto.class); + } catch (Exception e) { + throw new SerializationException("Error when deserializing byte[] to MessageDto"); + } + } + + @Override + public void close() { + } +} diff --git a/apache-kafka/src/main/java/com/baeldung/kafka/serdes/CustomSerializer.java b/apache-kafka/src/main/java/com/baeldung/kafka/serdes/CustomSerializer.java new file mode 100644 index 0000000000..a414ad8e23 --- /dev/null +++ b/apache-kafka/src/main/java/com/baeldung/kafka/serdes/CustomSerializer.java @@ -0,0 +1,34 @@ +package com.baeldung.kafka.serdes; + +import com.baeldung.kafka.dto.MessageDto; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.kafka.common.errors.SerializationException; +import org.apache.kafka.common.serialization.Serializer; + +import java.util.Map; + +public class CustomSerializer implements Serializer { + private final ObjectMapper objectMapper = new ObjectMapper(); + + @Override + public void configure(Map configs, boolean isKey) { + } + + @Override + public byte[] serialize(String topic, MessageDto data) { + try { + if (data == null){ + System.out.println("Null received at serializing"); + return null; + } + System.out.println("Serializing..."); + return objectMapper.writeValueAsBytes(data); + } catch (Exception e) { + throw new SerializationException("Error when serializing MessageDto to byte[]"); + } + } + + @Override + public void close() { + } +} diff --git a/apache-kafka/src/test/java/com/baeldung/kafka/serdes/KafkaSerDesLiveTest.java b/apache-kafka/src/test/java/com/baeldung/kafka/serdes/KafkaSerDesLiveTest.java new file mode 100644 index 0000000000..67fff12f5e --- /dev/null +++ b/apache-kafka/src/test/java/com/baeldung/kafka/serdes/KafkaSerDesLiveTest.java @@ -0,0 +1,92 @@ +package com.baeldung.kafka.serdes; + +import com.baeldung.kafka.dto.MessageDto; +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.utility.DockerImageName; + +import java.time.Duration; +import java.util.Arrays; +import java.util.Properties; +import java.util.concurrent.atomic.AtomicReference; + +import static org.junit.Assert.assertEquals; + +public class KafkaSerDesLiveTest { + private static final String CONSUMER_APP_ID = "consumer_id"; + private static final String CONSUMER_GROUP_ID = "group_id"; + + @ClassRule + public static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:5.4.3")); + private final String TOPIC = "mytopic"; + + private static KafkaConsumer createKafkaConsumer() { + + Properties props = new Properties(); + props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); + props.put(ConsumerConfig.CLIENT_ID_CONFIG, CONSUMER_APP_ID); + props.put(ConsumerConfig.GROUP_ID_CONFIG, CONSUMER_GROUP_ID); + props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); + props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); + props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "com.baeldung.kafka.serdes.CustomDeserializer"); + + return new KafkaConsumer<>(props); + + } + + private static KafkaProducer createKafkaProducer() { + + Properties props = new Properties(); + props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); + props.put(ProducerConfig.CLIENT_ID_CONFIG, CONSUMER_APP_ID); + props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); + props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "com.baeldung.kafka.serdes.CustomSerializer"); + + return new KafkaProducer(props); + + } + + @Before + public void setUp() { + } + + @Test + public void givenKafkaClientShouldSerializeAndDeserialize() throws InterruptedException { + + MessageDto msgProd = MessageDto.builder().message("test").version("1.0").build(); + + KafkaProducer producer = createKafkaProducer(); + producer.send(new ProducerRecord(TOPIC, "1", msgProd)); + System.out.println("Message sent " + msgProd); + producer.close(); + + Thread.sleep(2000); + + AtomicReference msgCons = new AtomicReference<>(); + + KafkaConsumer consumer = createKafkaConsumer(); + consumer.subscribe(Arrays.asList(TOPIC)); + + ConsumerRecords records = consumer.poll(Duration.ofSeconds(1)); + records.forEach(record -> { + msgCons.set(record.value()); + System.out.println("Message received " + record.value()); + }); + + consumer.close(); + + assertEquals(msgProd, msgCons.get()); + + } + +} + + diff --git a/apache-libraries/pom.xml b/apache-libraries/pom.xml index ded10b939f..b4cf11b07d 100644 --- a/apache-libraries/pom.xml +++ b/apache-libraries/pom.xml @@ -133,6 +133,11 @@ jackson-databind ${jackson.version} + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + com.jayway.awaitility awaitility @@ -196,7 +201,6 @@ 1.8 1.8 1.8.2 - 1.7.25 2.19.0 3.9.0 1.1.2 diff --git a/apache-libraries/src/main/resources/log4j2.xml b/apache-libraries/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..d1ea5173fa --- /dev/null +++ b/apache-libraries/src/main/resources/log4j2.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apache-libraries/src/main/resources/models/en-lemmatizer.dict b/apache-libraries/src/main/resources/models/en-lemmatizer.dict new file mode 100644 index 0000000000..7f17fe829f --- /dev/null +++ b/apache-libraries/src/main/resources/models/en-lemmatizer.dict @@ -0,0 +1,3181 @@ +a DT a +a-horizon NN a-horizon +a-okay JJ a-okay +a-one JJ a-one +a-year JJ a-year +a.k.a. RB a.k.a. +contents NNS content +contents VBZ content +hairnets NNS hairnet +hairpiece NN hairpiece +hairpieces NNS hairpiece +hairpin NN hairpin +hairpins NNS hairpin +hairs NNS hair +hairsbreadth NN hairsbreadth +hairsbreadths NNS hairsbreadth +hairsplitter NN hairsplitter +hairsplitters NNS hairsplitter +hairsplitting JJ hairsplitting +hairsplitting NN hairsplitting +hairsplittings NNS hairsplitting +hairspray NN hairspray +hairsprays NNS hairspray +hairspring NN hairspring +hairsprings NNS hairspring +hairstreak NN hairstreak +hairstreaks NNS hairstreak +hairstyle NN hairstyle +hairstyles NNS hairstyle +hairstyling NN hairstyling +hairstylings NNS hairstyling +hairstylist NN hairstylist +hairstylists NNS hairstylist +hairtail NN hairtail +hairtonic NN hairtonic +hairtrigger NNS hair-trigger +hairweaver NN hairweaver +hairweavers NNS hairweaver +hairweaving NN hairweaving +hairweavings NNS hairweaving +hairwork NN hairwork +hairworks NNS hairwork +hairworm NN hairworm +hairworms NNS hairworm +hairy JJ hairy +hairy-faced JJ hairy-faced +haith NN haith +haiths NNS haith +haj NN haj +hajes NNS haj +hajes NNS hajis +haji NN haji +hajis NN hajis +hajis NNS haji +hajj NN hajj +hajjes NNS hajj +hajjes NNS hajjis +hajji NN hajji +hajjis NN hajjis +hajjis NNS hajji +haka NN haka +hakam NN hakam +hakams NNS hakam +hakas NNS haka +hake NN hake +hake NNS hake +hakea NN hakea +hakeem NN hakeem +hakeems NNS hakeem +hakes NNS hake +hakim NN hakim +hakims NNS hakim +hakka NN hakka +haku NN haku +hakus NNS haku +halacha NN halacha +halachas NNS halacha +halachic JJ halachic +halachist NN halachist +halachists NNS halachist +halakah NN halakah +halakahs NNS halakah +halakha NN halakha +halakhah NN halakhah +halakhahs NNS halakhah +halakhas NNS halakha +halakhist NN halakhist +halakhists NNS halakhist +halakist NN halakist +halakists NNS halakist +halal JJ halal +halal NN halal +halala NN halala +halalah NN halalah +halalahs NNS halalah +halalas NNS halala +halalling NN halalling +halalling NNS halalling +halals NNS halal +halation NNN halation +halations NNS halation +halavah NN halavah +halavahs NNS halavah +halazone NN halazone +halazones NNS halazone +halberd NN halberd +halberdier NN halberdier +halberdiers NNS halberdier +halberds NNS halberd +halbert NN halbert +halberts NNS halbert +halchidhoma NN halchidhoma +halcyon JJ halcyon +halcyon NN halcyon +haldea NN haldea +hale JJ hale +hale VB hale +hale VBP hale +haled VBD hale +haled VBN hale +haleness NN haleness +halenesses NNS haleness +halenia NN halenia +haler NN haler +haler JJR hale +halers NNS haler +hales VBZ hale +halesia NN halesia +halest JJS hale +half DT half +half NN half +half PDT half +half-American JJ half-American +half-Americanized JJ half-Americanized +half-Anglicized JJ half-Anglicized +half-Aristotelian JJ half-Aristotelian +half-Asian JJ half-Asian +half-Asiatic JJ half-Asiatic +half-Christian JJ half-Christian +half-Confederate JJ half-Confederate +half-Creole JJ half-Creole +half-Dacron JJ half-Dacron +half-Elizabethan JJ half-Elizabethan +half-English JJ half-English +half-French JJ half-French +half-German JJ half-German +half-Greek JJ half-Greek +half-Hessian JJ half-Hessian +half-Irish JJ half-Irish +half-Italian JJ half-Italian +half-Latinized JJ half-Latinized +half-Mexican JJ half-Mexican +half-Mohammedan JJ half-Mohammedan +half-Moslem JJ half-Moslem +half-Muhammadan JJ half-Muhammadan +half-Muslim JJ half-Muslim +half-Russian JJ half-Russian +half-Scottish JJ half-Scottish +half-Semitic JJ half-Semitic +half-Shakespearean JJ half-Shakespearean +half-Spanish JJ half-Spanish +half-a-crown NN half-a-crown +half-a-dollar NN half-a-dollar +half-abandoned JJ half-abandoned +half-accustomed JJ half-accustomed +half-acquainted JJ half-acquainted +half-acquiescent JJ half-acquiescent +half-acquiescently RB half-acquiescently +half-acre NN half-acre +half-addressed JJ half-addressed +half-admiring JJ half-admiring +half-admiringly RB half-admiringly +half-admitted JJ half-admitted +half-admittedly RB half-admittedly +half-adream JJ half-adream +half-affianced JJ half-affianced +half-afloat JJ half-afloat +half-afraid JJ half-afraid +half-agreed JJ half-agreed +half-alike JJ half-alike +half-alive JJ half-alive +half-altered JJ half-altered +half-and-half JJ half-and-half +half-and-half NN half-and-half +half-angrily RB half-angrily +half-angry JJ half-angry +half-annoyed JJ half-annoyed +half-annoying JJ half-annoying +half-annoyingly RB half-annoyingly +half-armed JJ half-armed +half-ashamed JJ half-ashamed +half-ashamedly RB half-ashamedly +half-asleep JJ half-asleep +half-assed JJ half-assed +half-awake JJ half-awake +harns NNS harn +haroseth NN haroseth +harp NN harp +harp VB harp +harp VBP harp +harped VBD harp +harped VBN harp +harper NN harper +harpers NNS harper +harpia NN harpia +harpies NNS harpy +harpin NN harpin +harping NNN harping +harping VBG harp +harpings NNS harping +harpins NNS harpin +harpist NN harpist +harpists NNS harpist +harpless JJ harpless +harplike JJ harplike +harpoon NN harpoon +harpoon VB harpoon +harpoon VBP harpoon +harpooned VBD harpoon +harpooned VBN harpoon +harpooneer NN harpooneer +harpooneers NNS harpooneer +harpooner NN harpooner +harpooners NNS harpooner +harpooning VBG harpoon +harpoonlike JJ harpoonlike +harpoons NNS harpoon +harpoons VBZ harpoon +harps NNS harp +harps VBZ harp +harpsichord NN harpsichord +harpsichordist NN harpsichordist +harpsichordists NNS harpsichordist +harpsichords NNS harpsichord +harpulla NN harpulla +harpullia NN harpullia +harpwise RB harpwise +harpy NN harpy +harpylike JJ harpylike +harquebus NN harquebus +harquebuses NNS harquebus +harquebusier NN harquebusier +harquebusiers NNS harquebusier +harridan NN harridan +harridans NNS harridan +harried VBD harry +harried VBN harry +harrier NN harrier +harriers NNS harrier +harries VBZ harry +harrisia NN harrisia +harrow NN harrow +harrow VB harrow +harrow VBP harrow +harrowed VBD harrow +harrowed VBN harrow +harrower NN harrower +harrowers NNS harrower +harrowing JJ harrowing +harrowing VBG harrow +harrowingly RB harrowingly +harrowment NN harrowment +harrows NNS harrow +harrows VBZ harrow +harry VB harry +harry VBP harry +harrying VBG harry +harsh JJ harsh +harshen VB harshen +harshen VBP harshen +harshened VBD harshen +harshened VBN harshen +harshening VBG harshen +harshens VBZ harshen +harsher JJR harsh +harshest JJS harsh +harshly RB harshly +harshness NN harshness +harshnesses NNS harshness +harslet NN harslet +harslets NNS harslet +hart NN hart +hart NNS hart +hartal NN hartal +hartals NNS hartal +hartebeest NN hartebeest +hartebeests NNS hartebeest +harts NNS hart +hartshorn NN hartshorn +hartshorns NNS hartshorn +harum-scarumness NN harum-scarumness +haruspex NN haruspex +haruspical JJ haruspical +haruspication NNN haruspication +haruspications NNS haruspication +haruspices NNS haruspex +haruspicies NNS haruspicy +haruspicy NNN haruspicy +harvest NN harvest +harvest VB harvest +harvest VBP harvest +harvest-lice NN harvest-lice +harvestabilities NNS harvestability +harvestability NNN harvestability +harvestable JJ harvestable +harvested VBD harvest +harvested VBN harvest +harvester NN harvester +harvesters NNS harvester +harvestfish NN harvestfish +harvestfish NNS harvestfish +harvesting NNN harvesting +harvesting VBG harvest +harvestless JJ harvestless +harvestman NN harvestman +harvestmen NNS harvestman +harvests NNS harvest +harvests VBZ harvest +harvesttime NN harvesttime +harvesttimes NNS harvesttime +has VBZ have +has-been NN has-been +has-beens NNS has-been +hasenpfeffer NN hasenpfeffer +hasenpfeffers NNS hasenpfeffer +hash NN hash +hash VB hash +hash VBP hash +hash-slinger NN hash-slinger +hashed VBD hash +hashed VBN hash +hasheesh NN hasheesh +hasheeshes NNS hasheesh +hasher NN hasher +hashes NNS hash +hashes VBZ hash +hashhead NN hashhead +hashheads NNS hashhead +hashing NNN hashing +hashing VBG hash +hashish NN hashish +hashishes NNS hashish +hashmark NN hashmark +hask JJ hask +hask NN hask +haslet NN haslet +haslets NNS haslet +haslock NN haslock +hasn MD have +hasn VBZ have +hasp NN hasp +hasps NNS hasp +hassar NN hassar +hassars NNS hassar +hassel NN hassel +hassels NNS hassel +hassenpfeffer NN hassenpfeffer +hassium NN hassium +hassiums NNS hassium +hassle NNN hassle +hassle VB hassle +hassle VBP hassle +hassled VBD hassle +hassled VBN hassle +hasslefree JJ hasslefree +hassles NNS hassle +hassles VBZ hassle +hassling VBG hassle +hassock NN hassock +hassocks NNS hassock +hast VBZ have +hastate JJ hastate +hastately RB hastately +haste NNN haste +haste VB haste +haste VBP haste +hasted VBD haste +hasted VBN haste +hasteful JJ hasteful +hastefully RB hastefully +hasteless JJ hasteless +hastelessness NN hastelessness +hasten VB hasten +hasten VBP hasten +hastened VBD hasten +hastened VBN hasten +hastener NN hastener +hasteners NNS hastener +hastening JJ hastening +hastening VBG hasten +hastens VBZ hasten +hastes NNS haste +hastes VBZ haste +hastier JJR hasty +hastiest JJS hasty +hastily RB hastily +hastiness NN hastiness +hastinesses NNS hastiness +hasting NNN hasting +hasting VBG haste +hastings NNS hasting +hasty JJ hasty +hat NN hat +hat VB hat +hat VBP hat +hatable JJ hatable +hatband NN hatband +hatbands NNS hatband +hatbox NN hatbox +hatboxes NNS hatbox +hatbrush NN hatbrush +hatbrushes NNS hatbrush +hatch NN hatch +hatch VB hatch +hatch VBP hatch +hatchabilities NNS hatchability +hatchability NNN hatchability +hatchable JJ hatchable +hatchback NN hatchback +hatchbacks NNS hatchback +hatcheck JJ hatcheck +hatcheck NN hatcheck +hatchecks NNS hatcheck +hatched JJ hatched +hatched VBD hatch +hatched VBN hatch +hatchel VB hatchel +hatchel VBP hatchel +hatcheled VBD hatchel +hatcheled VBN hatchel +hatcheling VBG hatchel +hatchelled VBD hatchel +hatchelled VBN hatchel +hatchelling NNN hatchelling +hatchelling NNS hatchelling +hatchelling VBG hatchel +hatchels VBZ hatchel +hatcher NN hatcher +hatcheries NNS hatchery +hatchers NNS hatcher +hatchery NN hatchery +hatches NNS hatch +hatches VBZ hatch +hatchet NN hatchet +hatchetfaced JJ hatchetfaced +hatchetfish NN hatchetfish +hatchetlike JJ hatchetlike +hatchetman NN hatchetman +hatchetmen NNS hatchetman +hatchets NNS hatchet +hatchettite NN hatchettite +hatching JJ hatching +hatching NN hatching +hatching VBG hatch +hatchings NNS hatching +hatchling NN hatchling +hatchling NNS hatchling +hatchment NN hatchment +hatchments NNS hatchment +hatchway NN hatchway +hatchways NNS hatchway +hate NN hate +hate VB hate +hate VBP hate +hateable JJ hateable +hated VBD hate +hated VBN hate +hateful JJ hateful +hatefully RB hatefully +hatefulness NN hatefulness +hatefulnesses NNS hatefulness +hateless JJ hateless +hatemonger NN hatemonger +hatemongering NN hatemongering +hatemongers NNS hatemonger +hater NN hater +haters NNS hater +hates NNS hate +hates VBZ hate +hatful NN hatful +hatfuls NNS hatful +hath VBZ have +hathpace NN hathpace +hating VBG hate +hatiora NN hatiora +hatless JJ hatless +hatlessness NN hatlessness +hatlike JJ hatlike +hatmaker NN hatmaker +hatmakers NNS hatmaker +hatpin NN hatpin +hatpins NNS hatpin +hatrack NN hatrack +hatracks NNS hatrack +hatred NNN hatred +hatreds NNS hatred +hats NNS hat +hats VBZ hat +hatstand NN hatstand +hatstands NNS hatstand +hatted VBD hat +hatted VBN hat +hatter NN hatter +hatteria NN hatteria +hatterias NNS hatteria +hatters NNS hatter +hatting NNN hatting +hatting VBG hat +hattings NNS hatting +hattock NN hattock +hattocks NNS hattock +haubergeon NN haubergeon +haubergeons NNS haubergeon +hauberk NN hauberk +hauberks NNS hauberk +haud NN haud +hauds NNS haud +hauerite NN hauerite +haugh NN haugh +haughs NNS haugh +haughtier JJR haughty +haughtiest JJS haughty +haughtily RB haughtily +haughtiness NN haughtiness +haughtinesses NNS haughtiness +haughty JJ haughty +haul NN haul +haul VB haul +haul VBP haul +haulage NN haulage +haulages NNS haulage +haulback NN haulback +hauld NN hauld +haulds NNS hauld +hauled VBD haul +hauled VBN haul +hauler NN hauler +haulers NNS hauler +haulier NN haulier +hauliers NNS haulier +hauling NNN hauling +hauling VBG haul +haulm NN haulm +haulmier JJR haulmy +haulmiest JJS haulmy +haulms NNS haulm +haulmy JJ haulmy +hauls NNS haul +hauls VBZ haul +haulyard NN haulyard +haulyards NNS haulyard +haunch NN haunch +haunched JJ haunched +haunches NNS haunch +haunchless JJ haunchless +haunt NN haunt +haunt VB haunt +haunt VBP haunt +haunted JJ haunted +haunted VBD haunt +haunted VBN haunt +haunter NN haunter +haunters NNS haunter +haunting JJ haunting +haunting NNN haunting +haunting VBG haunt +hauntingly RB hauntingly +hauntings NNS haunting +haunts NNS haunt +haunts VBZ haunt +hauriant JJ hauriant +hausen NN hausen +hausens NNS hausen +hausfrau NN hausfrau +hausfraus NNS hausfrau +hausmannite NN hausmannite +haussa NN haussa +haust NN haust +haustella NNS haustellum +haustellate JJ haustellate +haustellum NN haustellum +haustoria NNS haustorium +haustorial JJ haustorial +haustorium NN haustorium +hautbois NN hautbois +hautboy NN hautboy +hautboyist NN hautboyist +hautboys NNS hautboy +haute-piece NN haute-piece +hauteur NN hauteur +hauteurs NNS hauteur +hav NN hav +havarti NN havarti +havartis NNS havarti +havasupai NN havasupai +havdalah NN havdalah +havdalahs NNS havdalah +have NN have +have VB have +have VBP have +have-not NN have-not +have-nots NNS have-not +havelock NN havelock +havelocks NNS havelock +haven NN haven +haven MD have +haven VBP have +havenless JJ havenless +havens NNS haven +havenward RB havenward +haveour NN haveour +haveours NNS haveour +haverel NN haverel +haverels NNS haverel +havering NN havering +haverings NNS havering +havers UH havers +haversack NN haversack +haversacks NNS haversack +haversine NN haversine +haversines NNS haversine +haves NNS have +havildar NN havildar +havildars NNS havildar +having NNN having +having VBG have +havings NNS having +havior NN havior +haviors NNS havior +haviour NN haviour +haviours NNS haviour +havoc NN havoc +havocker NN havocker +havockers NNS havocker +havocs NNS havoc +haw NN haw +haw UH haw +haw VB haw +haw VBP haw +haw-haw NN haw-haw +haw-haw UH haw-haw +hawala NN hawala +hawbuck NN hawbuck +hawbuck NNS hawbuck +hawbucks NNS hawbuck +hawed VBD haw +hawed VBN haw +hawfinch NN hawfinch +hawfinches NNS hawfinch +hawing VBG haw +hawk NN hawk +hawk VB hawk +hawk VBP hawk +hawk-eyed JJ hawk-eyed +hawkbell NN hawkbell +hawkbells NNS hawkbell +hawkbill NN hawkbill +hawkbills NNS hawkbill +hawkbit NN hawkbit +hawkbits NNS hawkbit +hawked VBD hawk +hawked VBN hawk +hawker NN hawker +hawkers NNS hawker +hawkey NN hawkey +hawkeys NNS hawkey +hawkie NN hawkie +hawkies NNS hawkie +hawkies NNS hawky +hawking NNN hawking +hawking VBG hawk +hawkings NNS hawking +hawkish JJ hawkish +hawkishness NN hawkishness +hawkishnesses NNS hawkishness +hawklike JJ hawklike +hawkmoth NN hawkmoth +illmanneredness NN illmanneredness +illnature NN illnature +illness NNN illness +illnesses NNS illness +lactary JJ lactary +macroscale NN macroscale +mugginess NN mugginess +mugginesses NNS mugginess +mugging NNN mugging +mugging VBG mug +nabe NN nabe +nabes NNS nabe +nabes NNS nabis +nabis NN nabis +nabk NN nabk +nabks NNS nabk +nabla NN nabla +nablas NNS nabla +nabob NN nabob +naboberies NNS nabobery +nabobery NN nabobery +nabobess NN nabobess +nabobesses NNS nabobess +nabobical JJ nabobical +nabobically RB nabobically +nabobish JJ nabobish +nabobishly RB nabobishly +nabobism NNN nabobism +nabobisms NNS nabobism +nabobs NNS nabob +nabobship NN nabobship +naboom NN naboom +nabs NN nabs +nabs VBZ nab +nabses NNS nabs +nabu NN nabu +nabumetone NN nabumetone +nacarat NN nacarat +nacarats NNS nacarat +nacelle NN nacelle +nacelles NNS nacelle +nach NN nach +nache NN nache +naches NNS nache +naches NNS nach +nacho NN nacho +nachos NNS nacho +nacimiento NN nacimiento +nacket NN nacket +nackets NNS nacket +nacre NN nacre +nacred JJ nacred +nacreous JJ nacreous +nacres NNS nacre +nada NN nada +nadas NNS nada +nadir NN nadir +nadiral JJ nadiral +nadirs NNS nadir +nadolol NN nadolol +nae JJ nae +naemorhedus NN naemorhedus +naething NN naething +naethings NNS naething +naeve NN naeve +naeves NNS naeve +naevi NNS naevus +naevoid JJ naevoid +naevus NN naevus +nafcillin NN nafcillin +naffness NN naffness +nag NN nag +nag VB nag +nag VBP nag +naga NN naga +nagami NN nagami +nagana NN nagana +naganas NNS nagana +nagas NNS naga +nageia NN nageia +nagged VBD nag +nagged VBN nag +nagger NN nagger +naggers NNS nagger +naggier JJR naggy +naggiest JJS naggy +nagging JJ nagging +nagging VBG nag +naggingly RB naggingly +naggingness NN naggingness +naggish JJ naggish +naggy JJ naggy +nagi NN nagi +nagor NN nagor +nagors NNS nagor +nags NNS nag +nags VBZ nag +nagual NN nagual +nahal NN nahal +nahals NNS nahal +naiad NN naiad +naiadaceae NN naiadaceae +naiadales NN naiadales +naiades NNS naiad +naiads NNS naiad +naiant JJ naiant +naias NN naias +naif JJ naif +naif NN naif +naifs NNS naif +naik NN naik +naiki NN naiki +naiks NNS naik +nail NN nail +nail VB nail +nail VBP nail +nail-biting NNN nail-biting +nail-sick JJ nail-sick +nailbitingly RB nailbitingly +nailbrush NN nailbrush +nailbrushes NNS nailbrush +nailed VBD nail +nailed VBN nail +nailer NN nailer +naileries NNS nailery +nailers NNS nailer +nailery NN nailery +nailfile NN nailfile +nailfold NN nailfold +nailfolds NNS nailfold +nailhead NN nailhead +nailheads NNS nailhead +nailing NNN nailing +nailing VBG nail +nailings NNS nailing +nailless JJ nailless +naillike JJ naillike +nailrod NN nailrod +nails NNS nail +nails VBZ nail +nailset NN nailset +nailsets NNS nailset +nailsickness NN nailsickness +nainsook NN nainsook +nainsooks NNS nainsook +naira NN naira +nairas NNS naira +naiskos NN naiskos +naissant JJ naissant +naive JJ naive +naive NN naive +naively RB naively +naiveness NN naiveness +naivenesses NNS naiveness +naiver JJR naive +naives NNS naive +naives NNS naif +naivest JJS naive +naivete NN naivete +naivetes NNS naivete +naiveties NNS naivety +naivetivet NN naivetivet +naivety NN naivety +naja NN naja +najadaceae NN najadaceae +najas NN najas +naked JJ naked +nakeder JJR naked +nakedest JJS naked +nakedly RB nakedly +nakedness NN nakedness +nakednesses NNS nakedness +nakedwood NN nakedwood +naker NN naker +nakers NNS naker +nala NN nala +nalas NNS nala +naled NN naled +naleds NNS naled +nalfon NN nalfon +nalidixic JJ nalidixic +nallah NN nallah +nallahs NNS nallah +nalorphine NN nalorphine +nalorphines NNS nalorphine +naloxone NN naloxone +naloxones NNS naloxone +naltrexone NN naltrexone +naltrexones NNS naltrexone +namability NNN namability +namaskar NN namaskar +namaskars NNS namaskar +namaste NN namaste +namastes NNS namaste +namaycush NN namaycush +namby-pambiness NN namby-pambiness +namby-pamby JJ namby-pamby +namby-pamby NN namby-pamby +namby-pambyish JJ namby-pambyish +namby-pambyism NNN namby-pambyism +name NN name +name VB name +name VBP name +name-caller NN name-caller +name-calling NNN name-calling +name-dropper NN name-dropper +name-dropping NN name-dropping +nameability NNN nameability +nameable JJ nameable +named VBD name +named VBN name +namedrop VB namedrop +namedrop VBP namedrop +namedropped VBD namedrop +namedropped VBN namedrop +namedropper NN namedropper +namedroppers NNS namedropper +namedropping NN namedropping +namedropping VBG namedrop +namedroppings NNS namedropping +namedrops VBZ namedrop +nameko NN nameko +nameless JJ nameless +namelessly RB namelessly +namelessness NN namelessness +namelessnesses NNS namelessness +namely RB namely +nameplate NN nameplate +nameplates NNS nameplate +namer NN namer +namers NNS namer +names NNS name +names VBZ name +namesake NN namesake +namesakes NNS namesake +nametag NN nametag +nametags NNS nametag +nametape NN nametape +nametapes NNS nametape +namibian JJ namibian +naming NNN naming +naming VBG name +namings NNS naming +namma NN namma +nammad NN nammad +namtaru NN namtaru +nan NN nan +nana NN nana +nanako NN nanako +nanas NNS nana +nance NN nance +nancere NN nancere +nances NNS nance +nancies NNS nancy +nancy NN nancy +nancys NNS nancy +nandin NN nandin +nandina NN nandina +nandinas NNS nandina +nandine NN nandine +nandines NNS nandine +nandins NNS nandin +nandoo NN nandoo +nandoos NNS nandoo +nandrolone NN nandrolone +nandu NN nandu +nanism NNN nanism +nanisms NNS nanism +nanjing NN nanjing +nankeen NN nankeen +nankeens NNS nankeen +nankin NN nankin +nankins NNS nankin +nanna NN nanna +nannas NNS nanna +nannies NNS nanny +nannofossil NN nannofossil +nannofossils NNS nannofossil +nannoplankton NN nannoplankton +nannoplanktons NNS nannoplankton +nanny NN nanny +nanny-goat NN nanny-goat +nannyberry NN nannyberry +nannygai NN nannygai +nannygais NNS nannygai +nanobot NN nanobot +nanobots NNS nanobot +nanocephalic JJ nanocephalic +nanocephaly NN nanocephaly +nanocurie NN nanocurie +nanoelectronic JJ nanoelectronic +nanofossil NN nanofossil +nanofossils NNS nanofossil +nanogram NN nanogram +nanograms NNS nanogram +nanoid JJ nanoid +nanometer NN nanometer +nanometers NNS nanometer +nanometre NN nanometre +nanometres NNS nanometre +nanomia NN nanomia +nanoplankton NN nanoplankton +nanoplanktons NNS nanoplankton +nanosecond NN nanosecond +nanoseconds NNS nanosecond +nanotechnologies NNS nanotechnology +nanotechnology NNN nanotechnology +nanotesla NN nanotesla +nanoteslas NNS nanotesla +nanowatt NN nanowatt +nanowatts NNS nanowatt +nans NNS nan +nantua NN nantua +naos NN naos +naoses NNS naos +naovely RB naovely +nap NNN nap +nap VB nap +nap VBP nap +napa NN napa +napaea NN napaea +napalm NN napalm +napalm VB napalm +napalm VBP napalm +napalmed VBD napalm +napalmed VBN napalm +napalming VBG napalm +napalms NNS napalm +napalms VBZ napalm +napas NNS napa +nape NN nape +napea NN napea +naperies NNS napery +napery NN napery +napes NNS nape +naphtha NN naphtha +naphthalene NN naphthalene +naphthalenes NNS naphthalene +naphthalic JJ naphthalic +naphthalin NN naphthalin +naphthaline NN naphthaline +naphthalines NNS naphthaline +naphthalins NNS naphthalin +naphthas NNS naphtha +naphthene NN naphthene +naphthenes NNS naphthene +naphthenic JJ naphthenic +naphthol NN naphthol +naphthols NNS naphthol +naphthoquinone NN naphthoquinone +naphthous JJ naphthous +naphthyl NN naphthyl +naphthylamine NN naphthylamine +naphthylamines NNS naphthylamine +naphthyls NNS naphthyl +naphtol NN naphtol +naphtols NNS naphtol +napiform JJ napiform +napkin NN napkin +napkins NNS napkin +napless JJ napless +naplessness NN naplessness +napoleon NN napoleon +napoleons NNS napoleon +nappa NN nappa +nappas NNS nappa +nappe NN nappe +napped VBD nap +napped VBN nap +napper NN napper +nappers NNS napper +nappie JJ nappie +nappie NN nappie +nappier JJR nappie +nappier JJR nappy +nappies NNS nappie +nappies NNS nappy +nappiest JJS nappie +nappiest JJS nappy +nappiness NN nappiness +nappinesses NNS nappiness +napping VBG nap +nappy JJ nappy +nappy NN nappy +naprapath NN naprapath +naprapathies NNS naprapathy +naprapathy NN naprapathy +naprosyn NN naprosyn +naproxen NN naproxen +naproxens NNS naproxen +naps NNS nap +naps VBZ nap +naptime NN naptime +naptimes NNS naptime +napu NN napu +naranjilla NN naranjilla +narc NN narc +narcein NN narcein +narceine NN narceine +narceines NNS narceine +narceins NNS narcein +narcism NNN narcism +narcisms NNS narcism +narcissi NNS narcissus +narcissism NN narcissism +narcissisms NNS narcissism +narcissist NN narcissist +narcissistic JJ narcissistic +narcissistically RB narcissistically +narcissists NNS narcissist +narcissus NN narcissus +narcissus NNS narcissus +narcissuses NNS narcissus +narcist NN narcist +narcistic JJ narcistic +narcists NNS narcist +narco NN narco +narcoanalyses NNS narcoanalysis +narcoanalysis NN narcoanalysis +narcolepsies NNS narcolepsy +narcolepsy NN narcolepsy +narcoleptic JJ narcoleptic +narcoleptic NN narcoleptic +narcoleptics NNS narcoleptic +narcoma NN narcoma +narcomania NN narcomania +narcomaniac NN narcomaniac +narcomaniacal JJ narcomaniacal +narcomas NNS narcoma +narcomatous JJ narcomatous +narcos NN narcos +narcos NNS narco +narcose JJ narcose +narcose NN narcose +narcoses NNS narcose +narcoses NNS narcos +narcoses NNS narcosis +narcosis NN narcosis +narcosyntheses NNS narcosynthesis +narcosynthesis NN narcosynthesis +narcotic JJ narcotic +narcotic NN narcotic +narcotically RB narcotically +narcoticalness NN narcoticalness +narcoticness NN narcoticness +narcotics NNS narcotic +narcotisation NNN narcotisation +narcotise VB narcotise +narcotise VBP narcotise +narcotised VBD narcotise +narcotised VBN narcotise +narcotises VBZ narcotise +narcotising VBG narcotise +narcotism NNN narcotism +narcotisms NNS narcotism +narcotist NN narcotist +narcotists NNS narcotist +narcotization NN narcotization +narcotizations NNS narcotization +narcotize VB narcotize +narcotize VBP narcotize +narcotized JJ narcotized +narcotized VBD narcotize +narcotized VBN narcotize +narcotizes VBZ narcotize +narcotizing JJ narcotizing +narcotizing VBG narcotize +narcs NNS narc +nard NN nard +nardine JJ nardine +nardo NN nardo +nardoo NN nardoo +nardoos NNS nardoo +nards NNS nard +nare NN nare +nares NNS nare +nares NNS naris +narghile NN narghile +narghiles NNS narghile +nargile NN nargile +nargileh NN nargileh +nargilehs NNS nargileh +nargiles NNS nargile +narial JJ narial +naricorn NN naricorn +naricorns NNS naricorn +naris NN naris +nark NN nark +nark VB nark +nark VBP nark +narked VBD nark +narked VBN nark +narkier JJR narky +narkiest JJS narky +narking VBG nark +narks NNS nark +narks VBZ nark +narky JJ narky +narras NN narras +narrases NNS narras +narratable JJ narratable +narrate VB narrate +narrate VBP narrate +narrated VBD narrate +narrated VBN narrate +narrater NN narrater +narraters NNS narrater +narrates VBZ narrate +narrating VBG narrate +narration NNN narration +narrations NNS narration +narrative JJ narrative +narrative NNN narrative +narratively RB narratively +narratives NNS narrative +narratologies NNS narratology +narratologist NN narratologist +narratologists NNS narratologist +narratology NNN narratology +narrator NN narrator +narrators NNS narrator +narrow JJ narrow +narrow NN narrow +narrow VB narrow +narrow VBP narrow +narrow-fisted JJ narrow-fisted +narrow-gage JJ narrow-gage +narrow-gauge JJ narrow-gauge +narrow-gauged JJ narrow-gauged +narrow-minded JJ narrow-minded +narrow-mindedly RB narrow-mindedly +narrow-mindedness NN narrow-mindedness +narrowboat NN narrowboat +narrowcasting NN narrowcasting +narrowcastings NNS narrowcasting +narrowed JJ narrowed +narrowed VBD narrow +narrowed VBN narrow +narrower JJR narrow +narrowest JJS narrow +narrowing JJ narrowing +narrowing NNN narrowing +narrowing VBG narrow +narrowings NNS narrowing +narrowly RB narrowly +narrowminded JJ narrow-minded +narrowmindedness NNS narrow-mindedness +narrowness NN narrowness +narrownesses NNS narrowness +narrows NNS narrow +narrows VBZ narrow +narthecal JJ narthecal +narthecium NN narthecium +narthex NN narthex +narthexes NNS narthex +nartjie NN nartjie +nartjies NNS nartjie +narwal NN narwal +narwals NNS narwal +narwhal NN narwhal +narwhale NN narwhale +narwhales NNS narwhale +narwhals NNS narwhal +nary DT nary +nary JJ nary +nasal JJ nasal +nasal NN nasal +nasale VB nasale +nasale VBP nasale +nasalis NN nasalis +nasalisation NNN nasalisation +nasalisations NNS nasalisation +nasalise VB nasalise +nasalise VBP nasalise +nasalised VBD nasalise +nasalised VBN nasalise +nasalises VBZ nasalise +nasalising VBG nasalise +nasalism NNN nasalism +nasalisms NNS nasalism +nasalities NNS nasality +nasality NN nasality +nasalization NN nasalization +nasalizations NNS nasalization +nasalize VB nasalize +nasalize VBP nasalize +nasalized VBD nasalize +nasalized VBN nasalize +nasalizes VBZ nasalize +nasalizing VBG nasalize +nasally RB nasally +nasals NNS nasal +nasard NN nasard +nasards NNS nasard +nascence NN nascence +nascences NNS nascence +nascencies NNS nascency +nascency NN nascency +nascent JJ nascent +nasdaq NN nasdaq +naseberries NNS naseberry +naseberry NN naseberry +nashgab NN nashgab +nashgabs NNS nashgab +nasial JJ nasial +nasion NN nasion +nasions NNS nasion +nasofrontal JJ nasofrontal +nasogastric JJ nasogastric +nasolacrimal JJ nasolacrimal +nasological JJ nasological +nasologist NN nasologist +nasology NNN nasology +nasopalatine JJ nasopalatine +nasopharyngeal JJ nasopharyngeal +nasopharynx NN nasopharynx +nasopharynxes NNS nasopharynx +nasotracheal JJ nasotracheal +nastier JJR nasty +nasties NNS nasty +nastiest JJS nasty +nastily RB nastily +nastiness NN nastiness +nastinesses NNS nastiness +nasturtium NN nasturtium +nasturtiums NNS nasturtium +nasty JJ nasty +nasty NN nasty +nasua NN nasua +nasute NN nasute +nasuteness NN nasuteness +nasutes NNS nasute +nat NN nat +natal JJ natal +natalities NNS natality +natality NNN natality +natant JJ natant +natantia NN natantia +natation NNN natation +natational JJ natational +natations NNS natation +natator NN natator +natatorial JJ natatorial +natatorium NN natatorium +natatoriums NNS natatorium +natatory JJ natatory +natch JJ natch +natch NN natch +natch RB natch +natches NNS natch +naticidae NN naticidae +nation NN nation +nation-state NNN nation-state +national JJ national +national NN national +nationalisation NN nationalisation +nationalisations NNS nationalisation +nationalise VB nationalise +nationalise VBP nationalise +nationalised VBD nationalise +nationalised VBN nationalise +nationaliser NN nationaliser +nationalises VBZ nationalise +nationalising VBG nationalise +nationalism NN nationalism +nationalisms NNS nationalism +nationalist JJ nationalist +nationalist NN nationalist +nationalistic JJ nationalistic +nationalistically RB nationalistically +nationalists NNS nationalist +nationalities NNS nationality +nationality NNN nationality +nationalization NNN nationalization +nationalizations NNS nationalization +nationalize VB nationalize +nationalize VBP nationalize +nationalized VBD nationalize +nationalized VBN nationalize +nationalizer NN nationalizer +nationalizers NNS nationalizer +nationalizes VBZ nationalize +nationalizing VBG nationalize +nationally RB nationally +nationals NNS national +nationhood NN nationhood +nationhoods NNS nationhood +nationless JJ nationless +nations NNS nation +nationstate NNS nation-state +nationstates NNS nation-state +nationwide JJ nationwide +nationwide RB nationwide +native JJ native +native NN native +native-born JJ native-born +nativeborn JJ native-born +natively RB natively +nativeness NN nativeness +nativenesses NNS nativeness +natives NNS native +nativism NNN nativism +nativisms NNS nativism +nativist JJ nativist +nativist NN nativist +nativistic JJ nativistic +nativists NNS nativist +nativities NNS nativity +nativity NN nativity +natl NN natl +natrium NN natrium +natriums NNS natrium +natriureses NNS natriuresis +natriuresis NN natriuresis +natriuretic NN natriuretic +natriuretics NNS natriuretic +natrix NN natrix +natrolite NN natrolite +natrolites NNS natrolite +natron NN natron +natrons NNS natron +nats NNS nat +natter NN natter +natter VB natter +natter VBP natter +nattered VBD natter +nattered VBN natter +natterer NN natterer +natterers NNS natterer +nattering VBG natter +natterjack NN natterjack +natterjacks NNS natterjack +natters NNS natter +natters VBZ natter +nattier JJR natty +nattiest JJS natty +nattily RB nattily +nattiness NN nattiness +nattinesses NNS nattiness +natty JJ natty +natural JJ natural +natural NN natural +natural-born JJ natural-born +naturalisation NNN naturalisation +naturalisations NNS naturalization +naturalise VB naturalise +naturalise VBP naturalise +naturalised VBD naturalise +naturalised VBN naturalise +naturaliser NN naturaliser +naturalises VBZ naturalise +naturalising VBG naturalise +naturalism NN naturalism +naturalisms NNS naturalism +naturalist NN naturalist +naturalistic JJ naturalistic +naturalistically RB naturalistically +naturalists NNS naturalist +naturalization NN naturalization +naturalizations NNS naturalization +naturalize VB naturalize +naturalize VBP naturalize +naturalized VBD naturalize +naturalized VBN naturalize +naturalizer NN naturalizer +naturalizers NNS naturalizer +naturalizes VBZ naturalize +naturalizing VBG naturalize +naturally RB naturally +naturalness NN naturalness +naturalnesses NNS naturalness +naturals NNS natural +nature NNN nature +naturedly RB naturedly +naturelike JJ naturelike +natures NNS nature +naturism NNN naturism +naturisms NNS naturism +naturist NN naturist +naturistic JJ naturistic +naturists NNS naturist +naturopath NN naturopath +naturopathic JJ naturopathic +naturopathies NNS naturopathy +naturopaths NNS naturopath +naturopathy NN naturopathy +nauch NN nauch +nauclea NN nauclea +naucrates NN naucrates +naught NN naught +naughtier JJR naughty +naughties NNS naughty +naughtiest JJS naughty +naughtily RB naughtily +naughtiness NN naughtiness +naughtinesses NNS naughtiness +naughts NNS naught +naughty JJ naughty +naughty NN naughty +naumachia NN naumachia +naumachias NNS naumachia +naumachies NNS naumachy +naumachy NN naumachy +naunt NN naunt +naunts NNS naunt +naupathia NN naupathia +nauplial JJ nauplial +naupliform JJ naupliform +nauplii NNS nauplius +nauplioid JJ nauplioid +nauplius NN nauplius +nauran NN nauran +nausea NN nausea +nauseant NN nauseant +nauseants NNS nauseant +nauseas NNS nausea +nauseate VB nauseate +nauseate VBP nauseate +nauseated JJ nauseated +nauseated VBD nauseate +nauseated VBN nauseate +nauseates VBZ nauseate +nauseating JJ nauseating +nauseating VBG nauseate +nauseatingly RB nauseatingly +nauseatingness NN nauseatingness +nauseation NNN nauseation +nauseations NNS nauseation +nauseous JJ nauseous +nauseously RB nauseously +nauseousness NN nauseousness +nauseousnesses NNS nauseousness +naut NN naut +nautch NN nautch +nautches NNS nautch +nautic NN nautic +nautical JJ nautical +nauticality NNN nauticality +nautically RB nautically +nautics NNS nautic +nautili NNS nautilus +nautilidae NN nautilidae +nautiloid JJ nautiloid +nautiloid NN nautiloid +nautiloids NNS nautiloid +nautilus NN nautilus +nautiluses NNS nautilus +nav NN nav +navaid NN navaid +navaids NNS navaid +navajo NN navajo +naval JJ naval +navally RB navally +navar NN navar +navarch NN navarch +navarchies NNS navarchy +navarchs NNS navarch +navarchy NN navarchy +navarin NN navarin +navarins NNS navarin +navars NNS navar +nave NN nave +navel NN navel +navels NNS navel +navelwort NN navelwort +navelworts NNS navelwort +naves NNS nave +navette NN navette +navettes NNS navette +navew NN navew +navews NNS navew +navicert NN navicert +navicerts NNS navicert +navicula NN navicula +navicular JJ navicular +navicular NN navicular +naviculars NNS navicular +naviculas NNS navicula +navies NNS navy +navig NN navig +navigabilities NNS navigability +navigability NN navigability +navigable JJ navigable +navigableness NN navigableness +navigablenesses NNS navigableness +navigably RB navigably +navigate VB navigate +navigate VBP navigate +navigated VBD navigate +navigated VBN navigate +navigates VBZ navigate +navigating VBG navigate +navigation NN navigation +navigational JJ navigational +navigationally RB navigationally +navigations NNS navigation +navigator NN navigator +navigators NNS navigator +navvies NNS navvy +navvy NN navvy +navy JJ navy +navy NN navy +nawab NN nawab +nawabs NNS nawab +nawabship NN nawabship +nay JJ nay +nay NN nay +nays NNS nay +naysayer NN naysayer +naysayers NNS naysayer +naysaying NN naysaying +naze NN naze +nazes NNS naze +nazes NNS nazis +nazi NN nazi +nazification NNN nazification +nazifications NNS nazification +naziism NNN naziism +nazir NN nazir +nazirs NNS nazir +nazis NN nazis +nazis NNS nazi +nazism NNN nazism +naïvely RB naïvely +naïveness NNN naïveness +ne NN ne +neafe NN neafe +neafes NNS neafe +neaffe NN neaffe +neaffes NNS neaffe +neandertal JJ neandertal +neanderthal NN neanderthal +neanderthaler NN neanderthaler +neanderthalers NNS neanderthaler +neanderthalian JJ neanderthalian +neanderthals NNS neanderthal +neap JJ neap +neap NN neap +neaped JJ neaped +neaps NNS neap +neaptide NN neaptide +neaptides NNS neaptide +near IN near +near JJ near +near VB near +near VBP near +near-blind JJ near-blind +near-normal JJ near-normal +near-point NNN near-point +near-sighted JJ near-sighted +near-sightedly RB near-sightedly +near-sightedness NNN near-sightedness +nearby JJ nearby +nearby RB nearby +neared VBD near +neared VBN near +nearer JJR near +nearest IN nearest +nearest JJS near +nearing VBG near +nearlier JJR nearly +nearliest JJS nearly +nearly JJ nearly +nearly RB nearly +nearness NN nearness +nearnesses NNS nearness +nears VBZ near +nearside NN nearside +nearsides NNS nearside +nearsighted JJ nearsighted +nearsightedness NN nearsightedness +nearsightednesses NNS nearsightedness +neat JJ neat +neat NN neat +neaten VB neaten +neaten VBP neaten +neatened VBD neaten +neatened VBN neaten +neatening VBG neaten +neatens VBZ neaten +neater JJR neat +neatest JJS neat +neath IN neath +neatherd NN neatherd +neatherds NNS neatherd +neatly RB neatly +neatness NN neatness +neatnesses NNS neatness +neb NN neb +nebbich NN nebbich +nebbiches NNS nebbich +nebbish NN nebbish +nebbishe NN nebbishe +nebbisher NN nebbisher +nebbishers NNS nebbisher +nebbishes NNS nebbishe +nebbishes NNS nebbish +nebbuk NN nebbuk +nebbuks NNS nebbuk +nebeck NN nebeck +nebecks NNS nebeck +nebek NN nebek +nebeks NNS nebek +nebel NN nebel +nebels NNS nebel +nebenkern NN nebenkern +nebenkerns NNS nebenkern +nebish NN nebish +nebishes NNS nebish +nebraskan NN nebraskan +nebris NN nebris +nebrises NNS nebris +nebs NNS neb +nebuchadnezzar NN nebuchadnezzar +nebuchadnezzars NNS nebuchadnezzar +nebula NN nebula +nebulae NNS nebula +nebular JJ nebular +nebulas NNS nebula +nebulated JJ nebulated +nebule JJ nebule +nebule NN nebule +nebules NNS nebule +nebulisation NNN nebulisation +nebuliser NN nebuliser +nebulisers NNS nebuliser +nebulization NNN nebulization +nebulizations NNS nebulization +nebulizer NN nebulizer +nebulizers NNS nebulizer +nebulose JJ nebulose +nebulosities NNS nebulosity +nebulosity NNN nebulosity +nebulosus JJ nebulosus +nebulous JJ nebulous +nebulously RB nebulously +nebulousness NN nebulousness +nebulousnesses NNS nebulousness +nebuly RB nebuly +necessarian JJ necessarian +necessarian NN necessarian +necessarianism NNN necessarianism +necessarians NNS necessarian +necessaries NNS necessary +necessarily RB necessarily +necessariness NN necessariness +necessary JJ necessary +necessary NN necessary +necessitarian NN necessitarian +necessitarianism NNN necessitarianism +necessitarianisms NNS necessitarianism +necessitarians NNS necessitarian +necessitate VB necessitate +necessitate VBP necessitate +necessitated VBD necessitate +necessitated VBN necessitate +necessitates VBZ necessitate +necessitating VBG necessitate +necessitation NNN necessitation +necessitations NNS necessitation +necessitative JJ necessitative +necessities NNS necessity +necessitous JJ necessitous +necessitously RB necessitously +necessitousness NN necessitousness +necessitousnesses NNS necessitousness +necessitude NN necessitude +necessity NNN necessity +neck NN neck +neck VB neck +neck VBP neck +neckband NN neckband +neckbands NNS neckband +neckcloth NN neckcloth +neckcloths NNS neckcloth +necked JJ necked +necked VBD neck +necked VBN neck +necker NN necker +neckerchief NN neckerchief +neckerchiefs NNS neckerchief +neckerchieves NNS neckerchief +neckers NNS necker +necking NN necking +necking VBG neck +neckings NNS necking +necklace NN necklace +necklace VB necklace +necklace VBP necklace +necklaced VBD necklace +necklaced VBN necklace +necklaces NNS necklace +necklaces VBZ necklace +necklacing VBG necklace +neckless JJ neckless +necklet NN necklet +necklets NNS necklet +necklike JJ necklike +neckline NN neckline +necklines NNS neckline +neckpiece NN neckpiece +neckpieces NNS neckpiece +necks NNS neck +necks VBZ neck +necktie NN necktie +necktieless JJ necktieless +neckties NNS necktie +neckwear NN neckwear +neckweed NN neckweed +neckweeds NNS neckweed +necremia NN necremia +necro NN necro +necrobacillosis NN necrobacillosis +necrobioses NNS necrobiosis +necrobiosis NN necrobiosis +necrographer NN necrographer +necrographers NNS necrographer +necrolatries NNS necrolatry +necrolatry NN necrolatry +necrologic JJ necrologic +necrological JJ necrological +necrologically RB necrologically +necrologies NNS necrology +necrologist NN necrologist +necrologists NNS necrologist +necrology NN necrology +necrolysis NN necrolysis +necromancer NN necromancer +necromancers NNS necromancer +necromancies NNS necromancy +necromancy NN necromancy +necromania NN necromania +necromantic JJ necromantic +necromantical JJ necromantical +necromantically RB necromantically +necromimesis NN necromimesis +necrophagia NN necrophagia +necrophagias NNS necrophagia +necrophagy NN necrophagy +necrophile NN necrophile +necrophiles NNS necrophile +necrophilia NN necrophilia +necrophiliac JJ necrophiliac +necrophiliac NN necrophiliac +necrophiliacs NNS necrophiliac +necrophilias NNS necrophilia +necrophilic JJ necrophilic +necrophilic NN necrophilic +necrophilism NNN necrophilism +necrophilisms NNS necrophilism +necrophobia NN necrophobia +necrophobias NNS necrophobia +necrophobic JJ necrophobic +necropoleis NNS necropolis +necropoles NNS necropolis +necropoli NN necropoli +necropoli NNS necropolis +necropolis NN necropolis +necropolis NNS necropoli +necropolises NNS necropolis +necropolitan JJ necropolitan +necropsies NNS necropsy +necropsy NN necropsy +necroscopies NNS necroscopy +necroscopy NN necroscopy +necrose VB necrose +necrose VBP necrose +necrosed VBD necrose +necrosed VBN necrose +necroses VBZ necrose +necroses NNS necrosis +necrosing VBG necrose +necrosis NN necrosis +necrotic JJ necrotic +necrotomic JJ necrotomic +necrotomies NNS necrotomy +necrotomist NN necrotomist +necrotomy NN necrotomy +nectar NN nectar +nectareous JJ nectareous +nectareously RB nectareously +nectareousness NN nectareousness +nectaries NNS nectary +nectariferous JJ nectariferous +nectarine NN nectarine +nectarines NNS nectarine +nectarous JJ nectarous +nectars NNS nectar +nectary NN nectary +nectocalyces NNS nectocalyx +nectocalyx NN nectocalyx +necturus NN necturus +ned NN ned +neddies NNS neddy +neddy NN neddy +neds NNS ned +nee JJ nee +need MD need +need NNN need +need VB need +need VBP need +needed JJ needed +needed VBD need +needed VBN need +needer NN needer +needers NNS needer +needfire NN needfire +needful JJ needful +needful NN needful +needfully RB needfully +needfulness NN needfulness +needfulnesses NNS needfulness +needfuls NNS needful +needier JJR needy +neediest JJS needy +needily RB needily +neediness NN neediness +needinesses NNS neediness +needing VBG need +needle NN needle +needle VB needle +needle VBP needle +needle-shaped JJ needle-shaped +needlebush NN needlebush +needlecord NN needlecord +needlecords NNS needlecord +needlecraft NN needlecraft +needlecrafts NNS needlecraft +needled VBD needle +needled VBN needle +needlefish NN needlefish +needlefish NNS needlefish +needleful NN needleful +needlefuls NNS needleful +needleless JJ needleless +needlelike JJ needlelike +needlepoint NN needlepoint +needlepoints NNS needlepoint +needler NN needler +needlers NNS needler +needles NNS needle +needles VBZ needle +needless JJ needless +needlessly RB needlessly +needlessness NN needlessness +needlessnesses NNS needlessness +needlewoman NN needlewoman +needlewomen NNS needlewoman +needlewood NN needlewood +needlework NN needlework +needleworker NN needleworker +needleworkers NNS needleworker +needleworks NNS needlework +needling NNN needling +needling NNS needling +needling VBG needle +needn MD need +needs RB needs +needs NNS need +needs VBZ need +needy JJ needy +neem NN neem +neems NNS neem +neencephalon NN neencephalon +neep NN neep +neeps NNS neep +nef NN nef +nefarious JJ nefarious +nefariously RB nefariously +nefariousness NN nefariousness +nefariousnesses NNS nefariousness +nefs NNS nef +neg NN neg +negaprion NN negaprion +negate VB negate +negate VBP negate +negated VBD negate +negated VBN negate +negatedness NN negatedness +negater NN negater +negaters NNS negater +negates VBZ negate +negating NNN negating +negating VBG negate +negation NNN negation +negational JJ negational +negationist NN negationist +negationists NNS negationist +negations NNS negation +negative JJ negative +negative NNN negative +negative VB negative +negative VBG negative +negative VBP negative +negative-raising NNN negative-raising +negatived VBD negative +negatived VBN negative +negatively RB negatively +negativeness NN negativeness +negativenesses NNS negativeness +negatives NNS negative +negatives VBZ negative +negativing VBG negative +negativism NN negativism +negativisms NNS negativism +negativist NN negativist +negativists NNS negativist +negativities NNS negativity +negativity NN negativity +negaton NN negaton +negatons NNS negaton +negator NN negator +negators NNS negator +negatron NN negatron +negatrons NNS negatron +neglect NN neglect +neglect VB neglect +neglect VBP neglect +neglected JJ neglected +neglected VBD neglect +neglected VBN neglect +neglectedly RB neglectedly +neglectedness NN neglectedness +neglecter NN neglecter +neglecters NNS neglecter +neglectful JJ neglectful +neglectfully RB neglectfully +neglectfulness NN neglectfulness +neglectfulnesses NNS neglectfulness +neglecting VBG neglect +neglectingly RB neglectingly +neglection NNN neglection +neglections NNS neglection +neglector NN neglector +neglectors NNS neglector +neglects NNS neglect +neglects VBZ neglect +neglige NN neglige +negligee NNN negligee +negligees NNS negligee +negligence NN negligence +negligences NNS negligence +negligent JJ negligent +negligently RB negligently +negliges NNS neglige +negligibilities NNS negligibility +negligibility NNN negligibility +negligible JJ negligible +negligibleness NN negligibleness +negligiblenesses NNS negligibleness +negligibly RB negligibly +negociant NN negociant +negociants NNS negociant +negociate VB negociate +negociate VBP negociate +negotiabilities NNS negotiability +negotiability NN negotiability +negotiable JJ negotiable +negotiable NN negotiable +negotiables NNS negotiable +negotiant NN negotiant +negotiants NNS negotiant +negotiate VB negotiate +negotiate VBP negotiate +negotiated VBD negotiate +negotiated VBN negotiate +negotiates VBZ negotiate +negotiating VBG negotiate +negotiation NNN negotiation +negotiations NNS negotiation +negotiator NN negotiator +negotiators NNS negotiator +negotiatress NN negotiatress +negotiatresses NNS negotiatress +negotiatrix NN negotiatrix +negotiatrixes NNS negotiatrix +negritude NN negritude +negritudes NNS negritude +negro JJ negro +negroid JJ negroid +negroid NN negroid +negroids NNS negroid +negroism NNN negroism +negroisms NNS negroism +negroni NN negroni +negronis NNS negroni +negrophil NN negrophil +negrophile NN negrophile +negrophiles NNS negrophile +negrophilism NNN negrophilism +negrophilisms NNS negrophilism +negrophilist NN negrophilist +negrophilists NNS negrophilist +negrophils NNS negrophil +negrophobe NN negrophobe +negrophobes NNS negrophobe +negrophobia NN negrophobia +negrophobias NNS negrophobia +negs NNS neg +negus NN negus +neguses NNS negus +neif NN neif +neifs NNS neif +neigh NN neigh +neigh VB neigh +neigh VBP neigh +neighbor JJ neighbor +neighbor NN neighbor +neighbor VB neighbor +neighbor VBP neighbor +neighbored VBD neighbor +neighbored VBN neighbor +neighborhood NNN neighborhood +neighborhoods NNS neighborhood +neighboring JJ neighboring +neighboring VBG neighbor +neighborless JJ neighborless +neighborliness NN neighborliness +neighborlinesses NNS neighborliness +neighborly RB neighborly +neighbors NNS neighbor +neighbors VBZ neighbor +neighbour JJ neighbour +neighbour NN neighbour +neighbour VB neighbour +neighbour VBP neighbour +neighboured VBD neighbour +neighboured VBN neighbour +neighbourhood NN neighbourhood +neighbourhoods NNS neighbourhood +neighbouring JJ neighbouring +neighbouring VBG neighbour +neighbourless JJ neighbourless +neighbourliness NN neighbourliness +neighbourly RB neighbourly +neighbours NNS neighbour +neighbours VBZ neighbour +neighed VBD neigh +neighed VBN neigh +neighing VBG neigh +neighs NNS neigh +neighs VBZ neigh +neisseria NN neisseria +neither CC neither +neither DT neither +neive NN neive +neives NNS neive +neives NNS neif +nek NN nek +nekton NN nekton +nektonic JJ nektonic +nektons NNS nekton +nellie NN nellie +nellies NNS nellie +nellies NNS nelly +nelly NN nelly +nelson NN nelson +nelsons NNS nelson +nelumbian JJ nelumbian +nelumbium NN nelumbium +nelumbiums NNS nelumbium +nelumbo NN nelumbo +nelumbonaceae NN nelumbonaceae +nelumbos NNS nelumbo +nema NN nema +nemas NNS nema +nemathecial JJ nemathecial +nemathecium NN nemathecium +nemathelminth NN nemathelminth +nemathelminths NNS nemathelminth +nematic JJ nematic +nematicide NN nematicide +nematicides NNS nematicide +nematocera NN nematocera +nematocide NN nematocide +nematocides NNS nematocide +nematocyst NN nematocyst +nematocystic JJ nematocystic +nematocysts NNS nematocyst +nematode NN nematode +nematodes NNS nematode +nematological JJ nematological +nematologies NNS nematology +nematologist NN nematologist +nematologists NNS nematologist +nematology NNN nematology +nemertean JJ nemertean +nemertean NN nemertean +nemerteans NNS nemertean +nemertina NN nemertina +nemertine NN nemertine +nemertines NNS nemertine +nemeses NNS nemesis +nemesia NN nemesia +nemesias NNS nemesia +nemesis NN nemesis +nemo NN nemo +nemophila NN nemophila +nemophilas NNS nemophila +nemoricole JJ nemoricole +nene NN nene +nenes NNS nene +nenets NN nenets +nentsi NN nentsi +nentsy NN nentsy +nenuphar NN nenuphar +nenuphars NNS nenuphar +neo JJ neo +neo-Plastic JJ neo-Plastic +neo-classicist NN neo-classicist +neo-orthodoxy NN neo-orthodoxy +neoanthropic JJ neoanthropic +neoarsphenamine NN neoarsphenamine +neoarsphenamines NNS neoarsphenamine +neoblast NN neoblast +neoblasts NNS neoblast +neoceratodus NN neoceratodus +neoclassic JJ neoclassic +neoclassic NN neoclassic +neoclassical JJ neoclassical +neoclassicism NN neoclassicism +neoclassicisms NNS neoclassicism +neoclassicist JJ neoclassicist +neoclassicist NN neoclassicist +neoclassicistic JJ neoclassicistic +neoclassicists NNS neoclassicist +neocolonial JJ neocolonial +neocolonialism NN neocolonialism +neocolonialisms NNS neocolonialism +neocolonialist NN neocolonialist +neocolonialists NNS neocolonialist +neocon NN neocon +neocons NNS neocon +neoconservatism NNN neoconservatism +neoconservatisms NNS neoconservatism +neoconservative NN neoconservative +neoconservatives NNS neoconservative +neocortex NN neocortex +neocortexes NNS neocortex +neocortical JJ neocortical +neocortices NNS neocortex +neodymium NN neodymium +neodymiums NNS neodymium +neoencephalon NN neoencephalon +neoexpressionism NNN neoexpressionism +neofascism NNN neofascism +neofascisms NNS neofascism +neofascist NN neofascist +neofascists NNS neofascist +neofiber NN neofiber +neoformation NNN neoformation +neoformative JJ neoformative +neogeneses NNS neogenesis +neogenesis NN neogenesis +neogrammarian NN neogrammarian +neogrammarians NNS neogrammarian +neohygrophorus NN neohygrophorus +neoimperialism NNN neoimperialism +neoimpressionism NNN neoimpressionism +neoimpressionisms NNS neoimpressionism +neoimpressionist NN neoimpressionist +neoimpressionists NNS neoimpressionist +neolentinus NN neolentinus +neoliberal JJ neoliberal +neoliberal NN neoliberal +neoliberalism NNN neoliberalism +neoliberalisms NNS neoliberalism +neoliberals NNS neoliberal +neolith NN neolith +neoliths NNS neolith +neologian NN neologian +neologians NNS neologian +neologic JJ neologic +neological JJ neological +neologically RB neologically +neologies NNS neology +neologism NNN neologism +neologisms NNS neologism +neologist NN neologist +neologistic JJ neologistic +neologistical JJ neologistical +neologists NNS neologist +neology NNN neology +neomorph NN neomorph +neomorphs NNS neomorph +neomycin NN neomycin +neomycins NNS neomycin +neomys NN neomys +neon NN neon +neonatal JJ neonatal +neonatally RB neonatally +neonate NN neonate +neonates NNS neonate +neonatologies NNS neonatology +neonatologist NN neonatologist +neonatologists NNS neonatologist +neonatology NNN neonatology +neonomian NN neonomian +neonomians NNS neonomian +neons NNS neon +neoorthodox JJ neoorthodox +neoorthodoxies NNS neoorthodoxy +neoorthodoxy NN neoorthodoxy +neopagan NN neopagan +neopagans NNS neopagan +neopallium NN neopallium +neophile NN neophile +neophiles NNS neophile +neophilia NN neophilia +neophiliac NN neophiliac +neophiliacs NNS neophiliac +neophilias NNS neophilia +neophron NN neophron +neophyte NN neophyte +neophytes NNS neophyte +neophytic JJ neophytic +neophytism NNN neophytism +neoplasia NN neoplasia +neoplasias NNS neoplasia +neoplasm NN neoplasm +neoplasms NNS neoplasm +neoplasticism NNN neoplasticism +neoplasticisms NNS neoplasticism +neoplasticist NN neoplasticist +neoplasticists NNS neoplasticist +neoplasties NNS neoplasty +neoplasty NNN neoplasty +neoplatonist NN neoplatonist +neoplatonists NNS neoplatonist +neopolitan NN neopolitan +neoprene NN neoprene +neoprenes NNS neoprene +neorealism NNN neorealism +neorealisms NNS neorealism +neorealist NN neorealist +neorealists NNS neorealist +neoromantic JJ neoromantic +neoromanticism NNN neoromanticism +neostigmine NN neostigmine +neostigmines NNS neostigmine +neotenies NNS neoteny +neotenous JJ neotenous +neoteny NN neoteny +neoteric JJ neoteric +neoteric NN neoteric +neoterics NNS neoteric +neoterism NNN neoterism +neoterist NN neoterist +neoterists NNS neoterist +neoterminal JJ neoterminal +neotoma NN neotoma +neotraditional JJ neotraditional +neotropical JJ neotropical +neotype NN neotype +neotypes NNS neotype +neourthodox JJ neourthodox +neovascularisation NNN neovascularisation +neoytterbium NN neoytterbium +nep NN nep +nepa NN nepa +nepenthaceae NN nepenthaceae +nepenthe NN nepenthe +nepenthean JJ nepenthean +nepenthes NNS nepenthe +neper NN neper +nepers NNS neper +nepeta NN nepeta +nephalist NN nephalist +nephalists NNS nephalist +nepheline NN nepheline +nephelines NNS nepheline +nephelinite NN nephelinite +nephelinites NNS nephelinite +nephelinitic JJ nephelinitic +nephelite NN nephelite +nephelites NNS nephelite +nephelium NN nephelium +nephelometer NN nephelometer +nephelometers NNS nephelometer +nephelometries NNS nephelometry +nephelometry NN nephelometry +nephew NN nephew +nephews NNS nephew +nephogram NN nephogram +nephograms NNS nephogram +nephograph NN nephograph +nephographs NNS nephograph +nephological JJ nephological +nephologies NNS nephology +nephologist NN nephologist +nephologists NNS nephologist +nephology NNN nephology +nephoscope NN nephoscope +nephoscopes NNS nephoscope +nephralgia NN nephralgia +nephralgias NNS nephralgia +nephralgic JJ nephralgic +nephrectomies NNS nephrectomy +nephrectomy NN nephrectomy +nephric JJ nephric +nephridial JJ nephridial +nephridium NN nephridium +nephridiums NNS nephridium +nephrism NNN nephrism +nephrisms NNS nephrism +nephrite NN nephrite +nephrites NNS nephrite +nephritic JJ nephritic +nephritides NNS nephritis +nephritis NN nephritis +nephritises NNS nephritis +nephrocalcinosis NN nephrocalcinosis +nephrocele NN nephrocele +nephrogenous JJ nephrogenous +nephrolepis NN nephrolepis +nephrolith NN nephrolith +nephrolithiasis NN nephrolithiasis +nephrolithic JJ nephrolithic +nephrolithotomy NN nephrolithotomy +nephrologies NNS nephrology +nephrologist NN nephrologist +nephrologists NNS nephrologist +nephrology NNN nephrology +nephron NN nephron +nephrons NNS nephron +nephropathic JJ nephropathic +nephropathies NNS nephropathy +nephropathy NN nephropathy +nephrops NN nephrops +nephropsidae NN nephropsidae +nephroses NNS nephrosis +nephrosis NN nephrosis +nephrostome NN nephrostome +nephrostomes NNS nephrostome +nephrostomial JJ nephrostomial +nephrostomous JJ nephrostomous +nephrotic JJ nephrotic +nephrotic NN nephrotic +nephrotics NNS nephrotic +nephrotome NN nephrotome +nephrotomies NNS nephrotomy +nephrotomise NN nephrotomise +nephrotomy NN nephrotomy +nephrotoxic JJ nephrotoxic +nephrotoxicities NNS nephrotoxicity +nephrotoxicity NN nephrotoxicity +nephthys NN nephthys +nephthytis NN nephthytis +nepidae NN nepidae +nepit NN nepit +nepits NNS nepit +nepman NN nepman +nepotic JJ nepotic +nepotism NN nepotism +nepotisms NNS nepotism +nepotist NN nepotist +nepotistic JJ nepotistic +nepotistical JJ nepotistical +nepotists NNS nepotist +neps NNS nep +neptunium NN neptunium +neptuniums NNS neptunium +neral NN neral +nerals NNS neral +nerd NN nerd +nerdier JJR nerdy +nerdiest JJS nerdy +nerdiness NN nerdiness +nerds NNS nerd +nerdy JJ nerdy +nereid NN nereid +nereides NNS nereid +nereids NNS nereid +nereis NN nereis +nereises NNS nereis +nergal NN nergal +nerine NN nerine +nerines NNS nerine +nerita NN nerita +neritic JJ neritic +neritid NN neritid +neritidae NN neritidae +neritina NN neritina +nerium NN nerium +nerk NN nerk +nerka NN nerka +nerkas NNS nerka +nerks NNS nerk +nerodia NN nerodia +nerol NN nerol +neroli NN neroli +nerolis NNS neroli +nerols NNS nerol +nerthus NN nerthus +nerts UH nerts +nervate JJ nervate +nervation NNN nervation +nervations NNS nervation +nervature NN nervature +nervatures NNS nervature +nerve NNN nerve +nerve VB nerve +nerve VBP nerve +nerve-racking JJ nerve-racking +nerve-wracking JJ nerve-wracking +nerved VBD nerve +nerved VBN nerve +nerveless JJ nerveless +nervelessly RB nervelessly +nervelessness NN nervelessness +nervelessnesses NNS nervelessness +nervelet NN nervelet +nervelets NNS nervelet +nerver NN nerver +nerveroot NN nerveroot +nervers NNS nerver +nerves NNS nerve +nerves VBZ nerve +nervi NN nervi +nervier JJR nervy +nerviest JJS nervy +nervily RB nervily +nervine JJ nervine +nervine NN nervine +nervines NN nervines +nervines NNS nervine +nerviness NN nerviness +nervinesses NNS nerviness +nervinesses NNS nervines +nerving NNN nerving +nerving VBG nerve +nervings NNS nerving +nervosities NNS nervosity +nervosity NNN nervosity +nervous JJ nervous +nervously RB nervously +nervousness NN nervousness +nervousnesses NNS nervousness +nervule NN nervule +nervules NNS nervule +nervuration NNN nervuration +nervurations NNS nervuration +nervure NN nervure +nervures NNS nervure +nervus NN nervus +nervy JJ nervy +nescience NN nescience +nesciences NNS nescience +nescient JJ nescient +nescient NN nescient +nescients NNS nescient +nesh JJ nesh +nesokia NN nesokia +nesosilicate NN nesosilicate +ness NN ness +nesses NNS ness +nest NN nest +nest VB nest +nest VBP nest +nestable JJ nestable +nested VBD nest +nested VBN nest +nester NN nester +nesters NNS nester +nesting VBG nest +nestle NN nestle +nestle VB nestle +nestle VBP nestle +nestled JJ nestled +nestled VBD nestle +nestled VBN nestle +nestler NN nestler +nestlers NNS nestler +nestles NNS nestle +nestles VBZ nestle +nestlike JJ nestlike +nestling NNN nestling +nestling NNS nestling +nestling VBG nestle +nestlings NNS nestling +nestor NN nestor +nestors NNS nestor +nests NNS nest +nests VBZ nest +nesty JJ nesty +net JJ net +net NNN net +net VB net +net VBP net +netback NN netback +netbacks NNS netback +netball NN netball +nete NN nete +netes NNS nete +netful NN netful +netfuls NNS netful +nether JJ nether +nethermost DT nethermost +netherstock NN netherstock +netherstocks NNS netherstock +netherward JJ netherward +netherward NN netherward +netherwards NNS netherward +netherworld NN netherworld +netherworlds NNS netherworld +netiquette NN netiquette +netiquettes NNS netiquette +netizen NN netizen +netizens NNS netizen +netkeeper NN netkeeper +netless JJ netless +netlike JJ netlike +netmail VB netmail +netmail VBP netmail +netman NN netman +netminder NN netminder +netminders NNS netminder +netop NN netop +netops NNS netop +nets NNS net +nets VBZ net +netscape NN netscape +netsuke NN netsuke +netsukes NNS netsuke +nett JJ nett +nettable JJ nettable +netted VBD net +netted VBN net +netter NN netter +netter JJR nett +netter JJR net +netters NNS netter +nettier JJR netty +nettiest JJS netty +netting NN netting +netting VBG net +nettings NNS netting +nettle NN nettle +nettle VB nettle +nettle VBP nettle +nettled VBD nettle +nettled VBN nettle +nettlefish NN nettlefish +nettlefish NNS nettlefish +nettlelike JJ nettlelike +nettler NN nettler +nettlers NNS nettler +nettles NNS nettle +nettles VBZ nettle +nettlesome JJ nettlesome +nettlier JJR nettly +nettliest JJS nettly +nettling NNN nettling +nettling NNS nettling +nettling VBG nettle +nettly RB nettly +netty JJ netty +network NN network +network VB network +network VBP network +networkable JJ networkable +networked VBD network +networked VBN network +networker NN networker +networkers NNS networker +networking NN networking +networking VBG network +networkings NNS networking +networklike JJ networklike +networks NNS network +networks VBZ network +networkwide JJ networkwide +neuk NN neuk +neuks NNS neuk +neum NN neum +neumatic JJ neumatic +neume NN neume +neumes NNS neume +neumic JJ neumic +neums NNS neum +neural JJ neural +neuralgia NN neuralgia +neuralgias NNS neuralgia +neuralgic JJ neuralgic +neuralgy NN neuralgy +neurally RB neurally +neuraminidase NN neuraminidase +neuraminidases NNS neuraminidase +neurasthenia NN neurasthenia +neurasthenias NNS neurasthenia +neurasthenic JJ neurasthenic +neurasthenic NN neurasthenic +neurasthenically RB neurasthenically +neurasthenics NNS neurasthenic +neuration NNN neuration +neurations NNS neuration +neuraxitis NN neuraxitis +neuraxon NN neuraxon +neuraxons NNS neuraxon +neurectomies NNS neurectomy +neurectomy NN neurectomy +neurilemma NN neurilemma +neurilemmal JJ neurilemmal +neurilemmas NNS neurilemma +neurilemmatic JJ neurilemmatic +neurine NN neurine +neurines NNS neurine +neurite NN neurite +neuritic JJ neuritic +neuritic NN neuritic +neuritics NNS neuritic +neuritides NNS neuritis +neuritis NN neuritis +neuritises NNS neuritis +neuroanatomic JJ neuroanatomic +neuroanatomical JJ neuroanatomical +neuroanatomies NNS neuroanatomy +neuroanatomist NN neuroanatomist +neuroanatomists NNS neuroanatomist +neuroanatomy NN neuroanatomy +neurobehavioural JJ neurobehavioural +neurobiological JJ neurobiological +neurobiologies NNS neurobiology +neurobiologist NN neurobiologist +neurobiologists NNS neurobiologist +neurobiology NNN neurobiology +neuroblast NN neuroblast +neuroblastic JJ neuroblastic +neuroblastoma NN neuroblastoma +neuroblastomas NNS neuroblastoma +neuroblasts NNS neuroblast +neurocelian JJ neurocelian +neurochemical NN neurochemical +neurochemicals NNS neurochemical +neurochemist NN neurochemist +neurochemistries NNS neurochemistry +neurochemistry NN neurochemistry +neurochemists NNS neurochemist +neurochip NN neurochip +neurochips NNS neurochip +neurocoele NN neurocoele +neurocoelian JJ neurocoelian +neurocomputer NN neurocomputer +neurocomputers NNS neurocomputer +neurodegeneration NNN neurodegeneration +neurodegenerative JJ neurodegenerative +neurodevelopment NN neurodevelopment +neurodevelopmental JJ neurodevelopmental +neuroembryological NN neuroembryological +neuroembryology NNN neuroembryology +neuroendocrine JJ neuroendocrine +neuroendocrinologies NNS neuroendocrinology +neuroendocrinologist NN neuroendocrinologist +neuroendocrinologists NNS neuroendocrinologist +neuroendocrinology NNN neuroendocrinology +neurofibril NN neurofibril +neurofibrils NNS neurofibril +neurofibroma NN neurofibroma +neurofibromas NNS neurofibroma +neurofibromatoses NNS neurofibromatosis +neurofibromatosis NN neurofibromatosis +neurogeneses NNS neurogenesis +neurogenesis NN neurogenesis +neurogenetic NN neurogenetic +neurogenetics NNS neurogenetic +neurogenic JJ neurogenic +neuroglia NN neuroglia +neurogliac JJ neurogliac +neurogliacyte NN neurogliacyte +neuroglial JJ neuroglial +neurogliar JJ neurogliar +neuroglias NNS neuroglia +neuroglic JJ neuroglic +neuroglycopenic JJ neuroglycopenic +neurogram NN neurogram +neurogrammic JJ neurogrammic +neurograms NNS neurogram +neurohormone NN neurohormone +neurohormones NNS neurohormone +neurohumor NN neurohumor +neurohumoral JJ neurohumoral +neurohumors NNS neurohumor +neurohypophyses NNS neurohypophysis +neurohypophysis NN neurohypophysis +neurohypophysises NNS neurohypophysis +neurolemma NN neurolemma +neurolemmas NNS neurolemma +neuroleptic NN neuroleptic +neuroleptics NNS neuroleptic +neurolinguist NN neurolinguist +neurolinguistic NN neurolinguistic +neurolinguistics NNS neurolinguistic +neurolinguists NNS neurolinguist +neurologic JJ neurologic +neurological JJ neurological +neurologically RB neurologically +neurologies NNS neurology +neurologist NN neurologist +neurologists NNS neurologist +neurology NN neurology +neurolytic JJ neurolytic +neuroma NN neuroma +neuromas NNS neuroma +neuromast NN neuromast +neuromastic JJ neuromastic +neuromasts NNS neuromast +neuromatous JJ neuromatous +neuromotor JJ neuromotor +neuromuscular JJ neuromuscular +neuron JJ neuron +neuron NN neuron +neuronal JJ neuronal +neurone NN neurone +neurones NNS neurone +neuronic JJ neuronic +neurons NNS neuron +neuropath NN neuropath +neuropathic JJ neuropathic +neuropathically RB neuropathically +neuropathies NNS neuropathy +neuropathist NN neuropathist +neuropathists NNS neuropathist +neuropathological JJ neuropathological +neuropathologically RB neuropathologically +neuropathologies NNS neuropathology +neuropathologist NN neuropathologist +neuropathologists NNS neuropathologist +neuropathology NNN neuropathology +neuropaths NNS neuropath +neuropathy NN neuropathy +neuropeptide NN neuropeptide +neuropeptides NNS neuropeptide +neuropharmacological JJ neuropharmacological +neuropharmacologies NNS neuropharmacology +neuropharmacologist NN neuropharmacologist +neuropharmacologists NNS neuropharmacologist +neuropharmacology NNN neuropharmacology +neurophysiologic JJ neurophysiologic +neurophysiological JJ neurophysiological +neurophysiologically RB neurophysiologically +neurophysiologies NNS neurophysiology +neurophysiologist NN neurophysiologist +neurophysiologists NNS neurophysiologist +neurophysiology NNN neurophysiology +neuroplasm NN neuroplasm +neuroplasmatic JJ neuroplasmatic +neuroplasmic JJ neuroplasmic +neuroprotective JJ neuroprotective +neuropsychiatric JJ neuropsychiatric +neuropsychiatries NNS neuropsychiatry +neuropsychiatrist NN neuropsychiatrist +neuropsychiatrists NNS neuropsychiatrist +neuropsychiatry NN neuropsychiatry +neuropsychological JJ neuropsychological +neuropsychologies NNS neuropsychology +neuropsychologist NN neuropsychologist +neuropsychologists NNS neuropsychologist +neuropsychology NNN neuropsychology +neuropsychopharmacology NNN neuropsychopharmacology +neuroptera NN neuroptera +neuropteran NN neuropteran +neuropterans NNS neuropteran +neuropterist NN neuropterist +neuropterists NNS neuropterist +neuropteron NN neuropteron +neuropterous JJ neuropterous +neuroradiological JJ neuroradiological +neuroradiologies NNS neuroradiology +neuroradiologist NN neuroradiologist +neuroradiologists NNS neuroradiologist +neuroradiology NNN neuroradiology +neurosarcoma NN neurosarcoma +neuroscience NN neuroscience +neurosciences NNS neuroscience +neuroscientific JJ neuroscientific +neuroscientist NN neuroscientist +neuroscientists NNS neuroscientist +neurosecretion NNN neurosecretion +neurosecretions NNS neurosecretion +neuroses NNS neurosis +neurosis NN neurosis +neurospora NN neurospora +neurosporas NNS neurospora +neurosurgeon NN neurosurgeon +neurosurgeons NNS neurosurgeon +neurosurgeries NNS neurosurgery +neurosurgery NN neurosurgery +neurosurgical JJ neurosurgical +neurosyphilis NN neurosyphilis +neurotic JJ neurotic +neurotic NN neurotic +neurotically RB neurotically +neuroticism NNN neuroticism +neuroticisms NNS neuroticism +neurotics NNS neurotic +neurotomies NNS neurotomy +neurotomy NN neurotomy +neurotoxic JJ neurotoxic +neurotoxicities NNS neurotoxicity +neurotoxicity NN neurotoxicity +neurotoxicology NNN neurotoxicology +neurotoxin NN neurotoxin +neurotoxins NNS neurotoxin +neurotransmission NN neurotransmission +neurotransmissions NNS neurotransmission +neurotransmitter NN neurotransmitter +neurotransmitters NNS neurotransmitter +neurotrichus NN neurotrichus +neurotrophic JJ neurotrophic +neurotrophy NN neurotrophy +neurotropic JJ neurotropic +neurotropism NNN neurotropism +neurotropisms NNS neurotropism +neurovascular JJ neurovascular +neurula NN neurula +neurulas NNS neurula +neurulation NNN neurulation +neurulations NNS neurulation +neustic JJ neustic +neuston NN neuston +neustonic JJ neustonic +neustons NNS neuston +neut NN neut +neuter JJ neuter +neuter NNN neuter +neuter VB neuter +neuter VBG neuter +neuter VBP neuter +neutered JJ neutered +neutered VBD neuter +neutered VBN neuter +neutering NNN neutering +neutering VBG neuter +neuters NNS neuter +neuters VBZ neuter +neutral JJ neutral +neutral NN neutral +neutralisation NNN neutralisation +neutralise NN neutralise +neutralise VB neutralise +neutralise VBP neutralise +neutralised VBD neutralise +neutralised VBN neutralise +neutraliser NN neutraliser +neutralisers NNS neutraliser +neutralises VBZ neutralise +neutralising VBG neutralise +neutralism NN neutralism +neutralisms NNS neutralism +neutralist NN neutralist +neutralists NNS neutralist +neutralities NNS neutrality +neutrality NN neutrality +neutralization NN neutralization +neutralizations NNS neutralization +neutralize VB neutralize +neutralize VBP neutralize +neutralized VBD neutralize +neutralized VBN neutralize +neutralizer NN neutralizer +neutralizers NNS neutralizer +neutralizes VBZ neutralize +neutralizing VBG neutralize +neutrally RB neutrally +neutralness NN neutralness +neutralnesses NNS neutralness +neutrals NNS neutral +neutretto NN neutretto +neutrettos NNS neutretto +neutrino NN neutrino +neutrinoless JJ neutrinoless +neutrinos NNS neutrino +neutron NN neutron +neutrons NNS neutron +neutropenia NN neutropenia +neutropenic JJ neutropenic +neutrophil JJ neutrophil +neutrophil NN neutrophil +neutrophile NN neutrophile +neutrophiles NNS neutrophile +neutrophilic JJ neutrophilic +neutrophils NNS neutrophil +neutrosphere NN neutrosphere +nevadan NN nevadan +neve NN neve +nevelling NN nevelling +nevelling NNS nevelling +never RB never +never UH never +never-ending JJ never-ending +never-never JJ never-never +never-never NN never-never +never-say-die JJ never-say-die +nevermind NN nevermind +neverminds NNS nevermind +nevermore RB nevermore +nevertheless CC nevertheless +nevertheless RB nevertheless +neves NNS neve +neves NNS nef +nevi NNS nevus +nevirapine NN nevirapine +nevoid JJ nevoid +nevus NN nevus +new JJ new +new-car JJ new-car +new-fashioned JJ new-fashioned +new-made JJ new-made +new-model JJ new-model +new-mown JJ new-mown +new-rich JJ new-rich +new-rich NN new-rich +new-sprung JJ new-sprung +newari NN newari +newbie NN newbie +newbies NNS newbie +newborn JJ newborn +newborn NN newborn +newborns NNS newborn +newcomer NN newcomer +newcomers NNS newcomer +newel NN newel +newels NNS newel +newer JJR new +newest JJS new +newfangled JJ newfangled +newfangledly RB newfangledly +newfangledness NN newfangledness +newfanglednesses NNS newfangledness +newfound JJ newfound +newground NN newground +newie NN newie +newies NNS newie +newish JJ newish +newline NN newline +newlines NNS newline +newly RB newly +newlywed NN newlywed +newlyweds NNS newlywed +newmarket NN newmarket +newmarkets NNS newmarket +newmusic JJ newmusic +newness NN newness +newnesses NNS newness +news NN news +newsagent NN newsagent +newsagents NNS newsagent +newsbeat NN newsbeat +newsbeats NNS newsbeat +newsboard NN newsboard +newsboy NN newsboy +newsboys NNS newsboy +newsbreak NN newsbreak +newsbreaks NNS newsbreak +newscast NN newscast +newscaster NN newscaster +newscasters NNS newscaster +newscasting NN newscasting +newscastings NNS newscasting +newscasts NNS newscast +newsdealer NN newsdealer +newsdealers NNS newsdealer +newsdesk NN newsdesk +newsdesks NNS newsdesk +newses NNS news +newsflash NN newsflash +newsflashes NNS newsflash +newsgathering NN newsgathering +newsgatherings NNS newsgathering +newsgirl NN newsgirl +newsgirls NNS newsgirl +newsgroup NN newsgroup +newsgroups NNS newsgroup +newshawk NN newshawk +newshawks NNS newshawk +newshen NN newshen +newshound NN newshound +newshounds NNS newshound +newsie JJ newsie +newsie NN newsie +newsier JJR newsie +newsier JJR newsy +newsies NNS newsie +newsiest JJS newsie +newsiest JJS newsy +newsiness NN newsiness +newsinesses NNS newsiness +newsless JJ newsless +newslessness NN newslessness +newsletter NN newsletter +newsletters NNS newsletter +newsmagazine NN newsmagazine +newsmagazines NNS newsmagazine +newsmaker NN newsmaker +newsmakers NNS newsmaker +newsman NN newsman +newsmen NNS newsman +newsmonger NN newsmonger +newsmongers NNS newsmonger +newspaper NNN newspaper +newspaperdom NN newspaperdom +newspapering NN newspapering +newspaperings NNS newspapering +newspaperish JJ newspaperish +newspaperman NN newspaperman +newspapermen NNS newspaperman +newspapers NNS newspaper +newspaperwoman NN newspaperwoman +newspaperwomen NNS newspaperwoman +newspeak NN newspeak +newspeaks NNS newspeak +newspeople NNS newsperson +newsperson NN newsperson +newspersons NNS newsperson +newsprint NN newsprint +newsprints NNS newsprint +newsreader NN newsreader +newsreaders NNS newsreader +newsreel NNN newsreel +newsreels NNS newsreel +newsroom NN newsroom +newsrooms NNS newsroom +newssheet NN newssheet +newssheets NNS newssheet +newsstand NN newsstand +newsstands NNS newsstand +newsvendor NN newsvendor +sissonne NN sissonne +sissoo NN sissoo +sissoos NNS sissoo +sissu NN sissu +sissy JJ sissy +sissy NN sissy +sissyish JJ sissyish +sissyness NN sissyness +sissynesses NNS sissyness +sister JJ sister +sister NN sister +sister-in-law NN sister-in-law +sisterhood NN sisterhood +sisterhoods NNS sisterhood +sisterless JJ sisterless +sisterlike JJ sisterlike +sisterliness NN sisterliness +sisterlinesses NNS sisterliness +sisterly RB sisterly +sisters NNS sister +sisters-in-law NNS sister-in-law +sistership NN sistership +sistroid JJ sistroid +sistrum NN sistrum +sistrums NNS sistrum +sistrurus NN sistrurus +sisyridae NN sisyridae +sisyrinchium NN sisyrinchium +sit VB sit +sit VBP sit +sit-down NNN sit-down +sit-up NN sit-up +sit-upon NN sit-upon +sitar NN sitar +sitarist NN sitarist +sitarists NNS sitarist +sitars NNS sitar +sitatunga NN sitatunga +sitatungas NNS sitatunga +sitcom NN sitcom +sitcoms NNS sitcom +sitdown NN sitdown +sitdowns NNS sitdown +site NN site +site VB site +site VBP site +site-specific JJ site-specific +sited VBD site +sited VBN site +sitella NN sitella +sitellas NNS sitella +sites NNS site +sites VBZ site +sitewide JJ sitewide +sitfast NN sitfast +sitfasts NNS sitfast +sith CC sith +sith RB sith +sithe NN sithe +sithen NN sithen +sithens NNS sithen +sithes NNS sithe +siting VBG site +sitologies NNS sitology +sitology NNN sitology +sitomania NN sitomania +sitomanias NNS sitomania +sitophylus NN sitophylus +sitosterol NN sitosterol +sitosterols NNS sitosterol +sitotroga NN sitotroga +sitrep NN sitrep +sitreps NNS sitrep +sits VBZ sit +sitta NN sitta +sitter NN sitter +sitters NNS sitter \ No newline at end of file diff --git a/apache-libraries/src/test/java/com/baeldung/apache/beam/intro/WordCountUnitTest.java b/apache-libraries/src/test/java/com/baeldung/apache/beam/intro/WordCountUnitTest.java index f2558635dc..77287066ac 100644 --- a/apache-libraries/src/test/java/com/baeldung/apache/beam/intro/WordCountUnitTest.java +++ b/apache-libraries/src/test/java/com/baeldung/apache/beam/intro/WordCountUnitTest.java @@ -10,7 +10,6 @@ import com.baeldung.apache.beam.intro.WordCount; public class WordCountUnitTest { @Test - // @Ignore public void givenInputFile_whenWordCountRuns_thenJobFinishWithoutError() { boolean jobDone = WordCount.wordCount("src/test/resources/wordcount.txt", "target/output"); assertTrue(jobDone); diff --git a/apache-spark/src/main/resources/log4j.properties b/apache-spark/src/main/resources/log4j.properties new file mode 100644 index 0000000000..07a2943655 --- /dev/null +++ b/apache-spark/src/main/resources/log4j.properties @@ -0,0 +1,42 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Set everything to be logged to the console +log4j.rootCategory=WARN, console +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.target=System.err +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n + +# Set the default spark-shell log level to WARN. When running the spark-shell, the +# log level for this class is used to overwrite the root logger's log level, so that +# the user can have different defaults for the shell and regular Spark apps. +log4j.logger.org.apache.spark.repl.Main=WARN + +# Settings to quiet third party logs that are too verbose +log4j.logger.org.spark_project.jetty=WARN +log4j.logger.org.spark_project.jetty.util.component.AbstractLifeCycle=ERROR +log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO +log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO + +# SPARK-9183: Settings to avoid annoying messages when looking up nonexistent UDFs in SparkSQL with Hive support +log4j.logger.org.apache.hadoop.hive.metastore.RetryingHMSHandler=FATAL +log4j.logger.org.apache.hadoop.hive.ql.exec.FunctionRegistry=ERROR + +# Parquet related logging +log4j.logger.org.apache.parquet.CorruptStatistics=ERROR +log4j.logger.parquet.CorruptStatistics=ERROR diff --git a/apache-tapestry/pom.xml b/apache-tapestry/pom.xml index 13ae49b0ba..7a4c2b53b5 100644 --- a/apache-tapestry/pom.xml +++ b/apache-tapestry/pom.xml @@ -32,7 +32,6 @@ - @@ -110,8 +109,6 @@ - - jboss diff --git a/apache-thrift/pom.xml b/apache-thrift/pom.xml index 9562ae7dfe..d2623f92e7 100644 --- a/apache-thrift/pom.xml +++ b/apache-thrift/pom.xml @@ -29,7 +29,7 @@ org.slf4j slf4j-simple - ${org.slf4j.slf4j-simple.version} + ${org.slf4j.version} test @@ -61,7 +61,6 @@ 0.10.0 0.1.11 - 1.7.12 3.0.0 diff --git a/aws-reactive/pom.xml b/aws-reactive/pom.xml index ea1e0c44a4..923e1361ab 100644 --- a/aws-reactive/pom.xml +++ b/aws-reactive/pom.xml @@ -93,5 +93,5 @@ 2.2.1.RELEASE 2.10.27 - + \ No newline at end of file diff --git a/aws/README.md b/aws/README.md index fcb9735878..9006c2d190 100644 --- a/aws/README.md +++ b/aws/README.md @@ -6,7 +6,7 @@ This module contains articles about Amazon Web Services (AWS) - [AWS Lambda Using DynamoDB With Java](https://www.baeldung.com/aws-lambda-dynamodb-java) - [AWS S3 with Java](https://www.baeldung.com/aws-s3-java) -- [AWS Lambda With Java](https://www.baeldung.com/java-aws-lambda) +- [A Basic AWS Lambda Example With Java](https://www.baeldung.com/java-aws-lambda) - [Managing EC2 Instances in Java](https://www.baeldung.com/ec2-java) - [Multipart Uploads in Amazon S3 with Java](https://www.baeldung.com/aws-s3-multipart-upload) - [Integration Testing with a Local DynamoDB Instance](https://www.baeldung.com/dynamodb-local-integration-tests) diff --git a/axon/src/main/java/com/baeldung/axon/OrderApplicationConfiguration.java b/axon/src/main/java/com/baeldung/axon/OrderApplicationConfiguration.java new file mode 100644 index 0000000000..8b743144b4 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/OrderApplicationConfiguration.java @@ -0,0 +1,18 @@ +package com.baeldung.axon; + +import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition; +import org.axonframework.eventsourcing.SnapshotTriggerDefinition; +import org.axonframework.eventsourcing.Snapshotter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OrderApplicationConfiguration { + + @Bean + public SnapshotTriggerDefinition orderAggregateSnapshotTriggerDefinition(Snapshotter snapshotter, + @Value("${axon.aggregate.order.snapshot-threshold:250}") int threshold) { + return new EventCountSnapshotTriggerDefinition(snapshotter, threshold); + } +} diff --git a/axon/src/main/java/com/baeldung/axon/commandmodel/order/OrderAggregate.java b/axon/src/main/java/com/baeldung/axon/commandmodel/order/OrderAggregate.java index 97342bdb3a..1065e9d22b 100644 --- a/axon/src/main/java/com/baeldung/axon/commandmodel/order/OrderAggregate.java +++ b/axon/src/main/java/com/baeldung/axon/commandmodel/order/OrderAggregate.java @@ -23,7 +23,7 @@ import java.util.Map; import static org.axonframework.modelling.command.AggregateLifecycle.apply; -@Aggregate +@Aggregate(snapshotTriggerDefinition = "orderAggregateSnapshotTriggerDefinition") public class OrderAggregate { @AggregateIdentifier diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index f8ef654293..89df666333 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -166,7 +166,6 @@ 2.4.0 1.1-groovy-2.4 1.1.3 - 1.2.3 2.5.7 3.1.0 3.8.0 diff --git a/core-java-modules/core-java-11-2/README.md b/core-java-modules/core-java-11-2/README.md index ca9a306b82..93920864cc 100644 --- a/core-java-modules/core-java-11-2/README.md +++ b/core-java-modules/core-java-11-2/README.md @@ -8,3 +8,4 @@ This module contains articles about Java 11 core features - [Guide to Java 8’s Collectors](https://www.baeldung.com/java-8-collectors) - [New Features in Java 11](https://www.baeldung.com/java-11-new-features) - [Getting the Java Version at Runtime](https://www.baeldung.com/get-java-version-runtime) +- [Invoking a SOAP Web Service in Java](https://www.baeldung.com/java-soap-web-service) diff --git a/core-java-modules/core-java-12/README.md b/core-java-modules/core-java-12/README.md index b509be876c..4ad7bae21c 100644 --- a/core-java-modules/core-java-12/README.md +++ b/core-java-modules/core-java-12/README.md @@ -2,3 +2,4 @@ - [String API Updates in Java 12](https://www.baeldung.com/java12-string-api) - [New Features in Java 12](https://www.baeldung.com/java-12-new-features) +- [Compare the Content of Two Files in Java](https://www.baeldung.com/java-compare-files) diff --git a/core-java-modules/core-java-12/pom.xml b/core-java-modules/core-java-12/pom.xml index ce7ec72aeb..931fce820b 100644 --- a/core-java-modules/core-java-12/pom.xml +++ b/core-java-modules/core-java-12/pom.xml @@ -1,60 +1,60 @@ - 4.0.0 - core-java-12 - 0.1.0-SNAPSHOT - core-java-12 - jar - http://maven.apache.org + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + core-java-12 + 0.1.0-SNAPSHOT + core-java-12 + jar + http://maven.apache.org - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + - - - org.assertj - assertj-core - ${assertj.version} - test - - - commons-io - commons-io - 2.11.0 - - + + + org.assertj + assertj-core + ${assertj.version} + test + + + commons-io + commons-io + 2.11.0 + + - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${maven.compiler.source.version} - ${maven.compiler.target.version} - --enable-preview - - - - maven-surefire-plugin - - --enable-preview - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source.version} + ${maven.compiler.target.version} + --enable-preview + + + + maven-surefire-plugin + + --enable-preview + + + + - - 12 - 12 - 3.6.1 - + + 12 + 12 + 3.6.1 + \ No newline at end of file diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index f3382f6577..a03332d8bc 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -14,7 +14,7 @@ 1.0.0-SNAPSHOT ../../ - + org.assertj @@ -35,7 +35,7 @@ test - + diff --git a/core-java-modules/core-java-16/README.md b/core-java-modules/core-java-16/README.md index 760513189f..b2740d194c 100644 --- a/core-java-modules/core-java-16/README.md +++ b/core-java-modules/core-java-16/README.md @@ -1,3 +1,7 @@ ### Relevant articles: - [Collect a Java Stream to an Immutable Collection](https://www.baeldung.com/java-stream-immutable-collection) +- [Guide to mapMulti in Stream API](https://www.baeldung.com/java-mapmulti) +- [Collecting Stream Elements into a List in Java](https://www.baeldung.com/java-stream-to-list-collecting) +- [New Features in Java 16](https://www.baeldung.com/java-16-new-features) +- [Guide to Java 8 groupingBy Collector](https://www.baeldung.com/java-groupingby-collector) diff --git a/core-java-modules/core-java-16/pom.xml b/core-java-modules/core-java-16/pom.xml index a8a84511db..5d10325f03 100644 --- a/core-java-modules/core-java-16/pom.xml +++ b/core-java-modules/core-java-16/pom.xml @@ -1,53 +1,86 @@ - 4.0.0 - core-java-16 - 0.1.0-SNAPSHOT - core-java-16 - jar - http://maven.apache.org + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + core-java-16 + 0.1.0-SNAPSHOT + core-java-16 + jar + http://maven.apache.org - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + - + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.apache.commons + commons-lang3 + 3.12.0 + - org.assertj - assertj-core - ${assertj.version} + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} test - org.apache.commons - commons-lang3 - 3.12.0 + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test - + - - + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.release} + --enable-preview + ${maven.compiler.source.version} + ${maven.compiler.target.version} + + org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} + maven-surefire-plugin + ${surefire.plugin.version} - ${maven.compiler.source.version} - ${maven.compiler.target.version} + --enable-preview + 1 + + + org.apache.maven.surefire + surefire-api + ${surefire.plugin.version} + + - - + + - - 16 - 16 - 3.6.1 - + + 16 + 16 + 16 + 3.8.1 + 3.0.0-M5 + 3.17.2 + \ No newline at end of file diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/HelloWorld.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/HelloWorld.java new file mode 100644 index 0000000000..7d72c4b71c --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/HelloWorld.java @@ -0,0 +1,7 @@ +package com.baeldung.features; + +interface HelloWorld { + default String hello() { + return "world"; + } +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/OuterClass.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/OuterClass.java new file mode 100644 index 0000000000..6e08674bff --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/OuterClass.java @@ -0,0 +1,9 @@ +package com.baeldung.features; + +import com.baeldung.features.record.Book; + +public class OuterClass { + class InnerClass { + Book book = new Book("Title", "author", "isbn"); + } +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/VectorExample.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/VectorExample.java new file mode 100644 index 0000000000..1f25290270 --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/VectorExample.java @@ -0,0 +1,23 @@ +package com.baeldung.features; + +import jdk.incubator.vector.IntVector; + +public class VectorExample { + public int[] scalarComputation(int[] a, int[] b) { + var c = new int[a.length]; + for (int i = 0; i < a.length; i++) { + c[i] = a[i] * b[i]; + } + return c; + } + + public int[] vectorComputation(int[] a, int[] b) { + var c = new int[a.length]; + + var vectorA = IntVector.fromArray(IntVector.SPECIES_128, a, 0); + var vectorB = IntVector.fromArray(IntVector.SPECIES_128, b, 0); + var vectorC = vectorA.mul(vectorB); + vectorC.intoArray(c, 0); + return c; + } +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/model/Book.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/model/Book.java new file mode 100644 index 0000000000..c532e41649 --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/model/Book.java @@ -0,0 +1,44 @@ +package com.baeldung.features.model; + +import java.util.Objects; + +public final class Book { + private final String title; + private final String author; + private final String isbn; + + public Book(String title, String author, String isbn) { + this.title = title; + this.author = author; + this.isbn = isbn; + } + + public String getTitle() { + return title; + } + + public String getAuthor() { + return author; + } + + public String getIsbn() { + return isbn; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Book book = (Book) o; + return Objects.equals(title, book.title) && Objects.equals(author, book.author) && Objects.equals(isbn, book.isbn); + } + + @Override + public int hashCode() { + return Objects.hash(title, author, isbn); + } +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/record/Book.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/record/Book.java new file mode 100644 index 0000000000..3bddf143be --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/record/Book.java @@ -0,0 +1,4 @@ +package com.baeldung.features.record; + +public record Book(String title, String author, String isbn) { +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/JungleAnimal.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/JungleAnimal.java new file mode 100644 index 0000000000..1853f8449c --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/JungleAnimal.java @@ -0,0 +1,4 @@ +package com.baeldung.features.sealed; + +public sealed interface JungleAnimal permits Monkey, Snake { +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Monkey.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Monkey.java new file mode 100644 index 0000000000..aeddfdddda --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Monkey.java @@ -0,0 +1,4 @@ +package com.baeldung.features.sealed; + +public final class Monkey implements JungleAnimal { +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Sealed.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Sealed.java new file mode 100644 index 0000000000..1ee4ff6e57 --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Sealed.java @@ -0,0 +1,13 @@ +package com.baeldung.features.sealed; + +public class Sealed { + public static void main(String... args) { + JungleAnimal j = new Monkey(); + + if (j instanceof Monkey m) { + // do logic + } else if (j instanceof Snake s) { + // do logic + } + } +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Snake.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Snake.java new file mode 100644 index 0000000000..c35575f5e0 --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/features/sealed/Snake.java @@ -0,0 +1,4 @@ +package com.baeldung.features.sealed; + +public non-sealed class Snake implements JungleAnimal { +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/groupingby/BlogPost.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/groupingby/BlogPost.java index adaa1044ff..960a75a58e 100644 --- a/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/groupingby/BlogPost.java +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/groupingby/BlogPost.java @@ -1,5 +1,8 @@ package com.baeldung.java_16_features.groupingby; +import java.util.IntSummaryStatistics; + + public class BlogPost { private String title; @@ -7,7 +10,9 @@ public class BlogPost { private BlogPostType type; private int likes; record AuthPostTypesLikes(String author, BlogPostType type, int likes) {}; - + record PostcountTitlesLikesStats(long postCount, String titles, IntSummaryStatistics likesStats){}; + record TitlesBoundedSumOfLikes(String titles, int boundedSumOfLikes) {}; + public BlogPost(String title, String author, BlogPostType type, int likes) { this.title = title; this.author = author; diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/mapmulti/Album.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/mapmulti/Album.java new file mode 100644 index 0000000000..fa7ec02307 --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/mapmulti/Album.java @@ -0,0 +1,49 @@ +package com.baeldung.java_16_features.mapmulti; + +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + +public class Album { + + private String albumName; + private int albumCost; + private List artists; + + Album(String name, int albumCost, List artists) { + this.albumName = name; + this.artists = artists; + this.albumCost = albumCost; + } + + public void artistAlbumPairsToMajorLabels(Consumer> consumer) { + + for (Artist artist : artists) { + if (artist.isAssociatedMajorLabels()) { + String concatLabels = artist.getMajorLabels() + .stream() + .collect(Collectors.joining(",")); + consumer.accept(new ImmutablePair<>(artist.getName() + ":" + albumName, concatLabels)); + } + } + } + + public String getAlbumName() { + return albumName; + } + + public int getAlbumCost() { + return albumCost; + } + + List getArtists() { + return artists; + } + + public String toString() { + return albumName; + } +} diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/mapmulti/Artist.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/mapmulti/Artist.java new file mode 100644 index 0000000000..b3b9b7aa10 --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/mapmulti/Artist.java @@ -0,0 +1,50 @@ +package com.baeldung.java_16_features.mapmulti; + +import java.util.List; +import java.util.Objects; + +public class Artist { + + private final String name; + private boolean associatedMajorLabels; + private List majorLabels; + + Artist(String name, boolean associatedMajorLabels, List majorLabels) { + this.name = name; + this.associatedMajorLabels = associatedMajorLabels; + this.majorLabels = majorLabels; + } + + public String getName() { + return name; + } + + public boolean isAssociatedMajorLabels() { + return associatedMajorLabels; + } + + public List getMajorLabels() { + return majorLabels; + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Artist other = (Artist) obj; + return Objects.equals(name, other.name); + } + + public String toString() { + return name; + } +} diff --git a/core-java-modules/core-java-16/src/main/java/module-info.java b/core-java-modules/core-java-16/src/main/java/module-info.java new file mode 100644 index 0000000000..ee983a6832 --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/module-info.java @@ -0,0 +1,4 @@ +module core.java { + requires jdk.incubator.vector; + requires org.apache.commons.lang3; +} \ No newline at end of file diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/features/DayPeriodSupportUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/DayPeriodSupportUnitTest.java new file mode 100644 index 0000000000..6ae6232f00 --- /dev/null +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/DayPeriodSupportUnitTest.java @@ -0,0 +1,24 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; + +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DayPeriodSupportUnitTest { + + @Test + public void givenASpecificTime_whenFormattingUsingTheBSymbol_thenExpectVerbosePeriodOfDay() { + LocalTime date = LocalTime.parse("15:25:08.690791"); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h B"); + assertThat(date.format(formatter)).isEqualTo("3 in the afternoon"); + + formatter = DateTimeFormatter.ofPattern("h BBBB"); + assertThat(date.format(formatter)).isEqualTo("3 in the afternoon"); + + formatter = DateTimeFormatter.ofPattern("h BBBBB"); + assertThat(date.format(formatter)).isEqualTo("3 in the afternoon"); + } +} diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/features/HelloWorldUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/HelloWorldUnitTest.java new file mode 100644 index 0000000000..d421f13dd1 --- /dev/null +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/HelloWorldUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.features; + + +import org.junit.jupiter.api.Test; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +import static java.lang.ClassLoader.getSystemClassLoader; +import static org.assertj.core.api.Assertions.assertThat; + +class HelloWorldUnitTest { + + @Test + public void givenAnInterfaceWithDefaulMethod_whenCreatingProxyInstance_thenCanInvokeDefaultMethod() throws Exception { + Object proxy = Proxy.newProxyInstance(getSystemClassLoader(), new Class[] { HelloWorld.class }, + (prox, method, args) -> { + if (method.isDefault()) { + return InvocationHandler.invokeDefault(prox, method, args); + } + return method.invoke(prox, args); + } + ); + Method method = proxy.getClass().getMethod("hello"); + assertThat(method.invoke(proxy)).isEqualTo("world"); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/features/InstanceOfPatternMatchingUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/InstanceOfPatternMatchingUnitTest.java new file mode 100644 index 0000000000..7243957332 --- /dev/null +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/InstanceOfPatternMatchingUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class InstanceOfPatternMatchingUnitTest { + + @Test + void givenTheNewPatternMatchingAbility_whenComparingAgainstTheTradiationalApproach_thenBothVariablesAreEqual() { + Object obj = "TEST"; + + if (obj instanceof String a) { + String b = (String) obj; + assertThat(a).isEqualTo(b); + } + } +} diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/features/StreamToListUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/StreamToListUnitTest.java new file mode 100644 index 0000000000..00d090a240 --- /dev/null +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/StreamToListUnitTest.java @@ -0,0 +1,20 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; + +public class StreamToListUnitTest { + + @Test + void givenAStream_whenCreatingANewListFromStream_thenCollectorsOrInbuiltFunctionAreEquivalent() { + List integersAsString = Arrays.asList("1", "2", "3"); + List ints = integersAsString.stream().map(Integer::parseInt).collect(Collectors.toList()); + List intsEquivalent = integersAsString.stream().map(Integer::parseInt).toList(); + assertThat(ints).isEqualTo(intsEquivalent); + } +} diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/features/VectorExampleUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/VectorExampleUnitTest.java new file mode 100644 index 0000000000..981f106ec7 --- /dev/null +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/features/VectorExampleUnitTest.java @@ -0,0 +1,21 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +class VectorExampleUnitTest { + + @Test + void givenAScalarComputation_whenCalculatingUsingVectorAPI_thenResultIsSameAsPreviousMethodOfComputation() { + VectorExample objectUnderTest = new VectorExample(); + + int[] a = {1, 2, 3, 4}; + int[] b = {5, 6, 7, 8}; + + int[] result = objectUnderTest.scalarComputation(a, b); + int[] result2 = objectUnderTest.vectorComputation(a, b); + + assertArrayEquals(result, result2); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/groupingby/JavaGroupingByCollectorUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/groupingby/JavaGroupingByCollectorUnitTest.java index 0e926246ff..0dea142658 100644 --- a/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/groupingby/JavaGroupingByCollectorUnitTest.java +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/groupingby/JavaGroupingByCollectorUnitTest.java @@ -5,6 +5,8 @@ import static java.util.stream.Collectors.averagingInt; import static java.util.stream.Collectors.counting; import static java.util.stream.Collectors.groupingBy; import static java.util.stream.Collectors.groupingByConcurrent; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.mapping; import static java.util.stream.Collectors.maxBy; @@ -13,6 +15,7 @@ import static java.util.stream.Collectors.summingInt; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.offset; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -201,9 +204,9 @@ public class JavaGroupingByCollectorUnitTest { @Test public void givenAListOfPosts_whenGroupedByComplexMapPairKeyType_thenGetAMapBetweenPairAndList() { - + Map, List> postsPerTypeAndAuthor = posts.stream() - .collect(groupingBy(post -> new ImmutablePair<>(post.getType(), post.getAuthor()))); + .collect(groupingBy(post -> new ImmutablePair<>(post.getType(), post.getAuthor()))); List result = postsPerTypeAndAuthor.get(new ImmutablePair<>(BlogPostType.GUIDE, "Author 1")); @@ -218,7 +221,7 @@ public class JavaGroupingByCollectorUnitTest { @Test public void givenAListOfPosts_whenGroupedByComplexMapKeyType_thenGetAMapBetweenTupleAndList() { - + Map> postsPerTypeAndAuthor = posts.stream() .collect(groupingBy(post -> new Tuple(post.getType(), post.getAuthor()))); @@ -232,12 +235,12 @@ public class JavaGroupingByCollectorUnitTest { assertThat(blogPost.getType()).isEqualTo(BlogPostType.GUIDE); assertThat(blogPost.getAuthor()).isEqualTo("Author 1"); } - + @Test public void givenAListOfPosts_whenGroupedByRecord_thenGetAMapBetweenRecordAndList() { - + Map> postsPerTypeAndAuthor = posts.stream() - .collect(groupingBy(post -> new BlogPost.AuthPostTypesLikes(post.getAuthor(), post.getType(), post.getLikes()))); + .collect(groupingBy(post -> new BlogPost.AuthPostTypesLikes(post.getAuthor(), post.getType(), post.getLikes()))); List result = postsPerTypeAndAuthor.get(new BlogPost.AuthPostTypesLikes("Author 1", BlogPostType.GUIDE, 20)); @@ -250,5 +253,50 @@ public class JavaGroupingByCollectorUnitTest { assertThat(blogPost.getAuthor()).isEqualTo("Author 1"); assertThat(blogPost.getLikes()).isEqualTo(20); } - + + @Test + public void givenListOfPosts_whenGroupedByAuthor_thenGetAMapUsingCollectingAndThen() { + + Map postsPerAuthor = posts.stream() + .collect(groupingBy(BlogPost::getAuthor, collectingAndThen(toList(), list -> { + long count = list.stream() + .map(BlogPost::getTitle) + .collect(counting()); + String titles = list.stream() + .map(BlogPost::getTitle) + .collect(joining(" : ")); + IntSummaryStatistics summary = list.stream() + .collect(summarizingInt(BlogPost::getLikes)); + return new BlogPost.PostcountTitlesLikesStats(count, titles, summary); + }))); + + BlogPost.PostcountTitlesLikesStats result = postsPerAuthor.get("Author 1"); + assertThat(result.postCount()).isEqualTo(3L); + assertThat(result.titles()).isEqualTo("News item 1 : Programming guide : Tech review 2"); + assertThat(result.likesStats().getMax()).isEqualTo(20); + assertThat(result.likesStats().getMin()).isEqualTo(15); + assertThat(result.likesStats().getAverage()).isEqualTo(16.666d, offset(0.001d)); + } + + @Test + public void givenListOfPosts_whenGroupedByAuthor_thenGetAMapUsingToMap() { + + int maxValLikes = 17; + Map postsPerAuthor = posts.stream() + .collect(toMap(BlogPost::getAuthor, post -> { + int likes = (post.getLikes() > maxValLikes) ? maxValLikes : post.getLikes(); + return new BlogPost.TitlesBoundedSumOfLikes(post.getTitle(), likes); + }, (u1, u2) -> { + int likes = (u2.boundedSumOfLikes() > maxValLikes) ? maxValLikes : u2.boundedSumOfLikes(); + return new BlogPost.TitlesBoundedSumOfLikes(u1.titles() + .toUpperCase() + " : " + + u2.titles() + .toUpperCase(), + u1.boundedSumOfLikes() + likes); + })); + + BlogPost.TitlesBoundedSumOfLikes result = postsPerAuthor.get("Author 1"); + assertThat(result.titles()).isEqualTo("NEWS ITEM 1 : PROGRAMMING GUIDE : TECH REVIEW 2"); + assertThat(result.boundedSumOfLikes()).isEqualTo(47); + } } diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/mapmulti/JavaStreamMapMultiUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/mapmulti/JavaStreamMapMultiUnitTest.java new file mode 100644 index 0000000000..0ab1a95ed0 --- /dev/null +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/mapmulti/JavaStreamMapMultiUnitTest.java @@ -0,0 +1,134 @@ +package com.baeldung.java_16_features.mapmulti; + +import static java.util.stream.Collectors.toList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.offset; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.junit.jupiter.api.Test; + +public class JavaStreamMapMultiUnitTest { + + private static final List albums = Arrays.asList(new Album("album1", 10, Arrays.asList(new Artist("bob", true, Arrays.asList("label1", "label3")), new Artist("tom", true, Arrays.asList("label2", "label3")))), + new Album("album2", 20, Arrays.asList(new Artist("bill", true, Arrays.asList("label2", "label3")), new Artist("tom", true, Arrays.asList("label2", "label4"))))); + + @Test + public void givenAListOfintegers_whenMapMulti_thenGetListOfOfEvenDoublesPlusPercentage() { + + List integers = Arrays.asList(1, 2, 3, 4, 5); + double percentage = .01; + List evenDoubles = integers.stream() + . mapMulti((integer, consumer) -> { + if (integer % 2 == 0) { + consumer.accept((double) integer * (1 + percentage)); + } + }) + .collect(toList()); + + assertThat(evenDoubles).containsAll(Arrays.asList(2.02D, 4.04D)); + } + + @Test + public void givenAListOfintegers_whenFilterMap_thenGetListOfOfEvenDoublesPlusPercentage() { + + List integers = Arrays.asList(1, 2, 3, 4, 5); + double percentage = .01; + List evenDoubles = integers.stream() + .filter(integer -> integer % 2 == 0) + . map(integer -> ((double) integer * (1 + percentage))) + .collect(toList()); + + assertThat(evenDoubles).containsAll(Arrays.asList(2.02D, 4.04D)); + } + + @Test + public void givenAListOfintegers_whenMapMultiToDouble_thenGetSumOfEvenNumbersAfterApplyPercentage() { + + List integers = Arrays.asList(1, 2, 3, 4, 5, 6, 7); + double percentage = .01; + double sum = integers.stream() + .mapMultiToDouble((integer, consumer) -> { + if (integer % 2 == 0) { + consumer.accept(integer * (1 + percentage)); + } + }) + .sum(); + + assertThat(sum).isEqualTo(12.12, offset(0.001d)); + } + + @Test + public void givenAListOfAlbums_whenFlatMap_thenGetListOfArtistAlbumPairs() { + + List> artistAlbum = albums.stream() + .flatMap(album -> album.getArtists() + .stream() + .map(artist -> new ImmutablePair(artist.getName(), album.getAlbumName()))) + .collect(toList()); + + assertThat(artistAlbum).contains(new ImmutablePair("bob", "album1"), new ImmutablePair("tom", "album1"), new ImmutablePair("bill", "album2"), new ImmutablePair("tom", "album2")); + } + + @Test + public void givenAListOfAlbums_whenMapMulti_thenGetListOfPairsOfArtistAlbum() { + + List> artistAlbum = albums.stream() + .> mapMulti((album, consumer) -> { + for (Artist artist : album.getArtists()) { + consumer.accept(new ImmutablePair(artist.getName(), album.getAlbumName())); + } + }) + .collect(toList()); + + assertThat(artistAlbum).contains(new ImmutablePair("bob", "album1"), new ImmutablePair("tom", "album1"), + new ImmutablePair("bill", "album2"), new ImmutablePair("tom", "album2")); + } + + @Test + public void givenAListOfAlbums_whenFlatMap_thenGetListOfArtistAlbumjPairsBelowGivenCost() { + + int upperCost = 9; + List> artistAlbum = albums.stream() + .flatMap(album -> album.getArtists() + .stream() + .filter(artist -> upperCost > album.getAlbumCost()) + .map(artist -> new ImmutablePair(artist.getName(), album.getAlbumName()))) + .collect(toList()); + + assertTrue(artistAlbum.isEmpty()); + } + + @Test + public void givenAListOfAlbums_whenMapMulti_thenGetListOfArtistAlbumPairsBelowGivenCost() { + + int upperCost = 9; + List> artistAlbum = albums.stream() + .> mapMulti((album, consumer) -> { + if (album.getAlbumCost() < upperCost) { + for (Artist artist : album.getArtists()) { + consumer.accept(new ImmutablePair(artist.getName(), album.getAlbumName())); + } + } + }) + .collect(toList()); + + assertTrue(artistAlbum.isEmpty()); + } + + @Test + public void givenAListOfAlbums_whenMapMulti_thenGetPairsOfArtistMajorLabelsUsingMethodReference() { + + List> artistLabels = albums.stream() + .mapMulti(Album::artistAlbumPairsToMajorLabels) + .collect(toList()); + + assertThat(artistLabels).contains(new ImmutablePair("bob:album1", "label1,label3"), new ImmutablePair("tom:album1", "label2,label3"), + new ImmutablePair("bill:album2", "label2,label3"), new ImmutablePair("tom:album2", "label2,label4")); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/streams/StreamToListComparisonWithCollectorsToListUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/streams/StreamToListComparisonWithCollectorsToListUnitTest.java new file mode 100644 index 0000000000..e1330bb4f7 --- /dev/null +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/streams/StreamToListComparisonWithCollectorsToListUnitTest.java @@ -0,0 +1,128 @@ +package com.baeldung.streams; + +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class StreamToListComparisonWithCollectorsToListUnitTest { + + @Test + public void whenAddingtoCollectToList_thenSuccess() { + + List result = Stream.of(Locale.getISOCountries()) + .collect(Collectors.toList()); + + Assertions.assertDoesNotThrow(() -> { + result.add("test"); + }); + } + + @Test + public void whenSortingtoCollectToList_thenSuccess() { + + List result = Stream.of(Locale.getISOCountries()) + .collect(Collectors.toList()); + + Assertions.assertDoesNotThrow(() -> { + result.sort(String::compareToIgnoreCase); + }); + } + + @Test + public void whenAddingCollectUnmodifiableToList_thenException() { + + List result = Stream.of(Locale.getISOCountries()) + .collect(Collectors.toUnmodifiableList()); + + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + result.add("test"); + }); + } + + @Test + public void whenSortingCollectUnmodifiableToList_thenSortException() { + + List result = Stream.of(Locale.getISOCountries()) + .collect(Collectors.toUnmodifiableList()); + + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + result.sort(String::compareToIgnoreCase); + }); + } + + @Test + public void whenAddingStreamToList_thenException() { + + List result = Stream.of(Locale.getISOCountries()) + .toList(); + + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + result.add("test"); + }); + } + + @Test + public void whenSortingStreamToList_thenException() { + + List result = Stream.of(Locale.getISOCountries()) + .toList(); + + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + result.sort(String::compareToIgnoreCase); + }); + } + + @Test + public void whenComparingStreamToList_withCollectToList_thenEqual() { + + List streamToList = Stream.of(Locale.getISOCountries()) + .toList(); + List collectToList = Stream.of(Locale.getISOCountries()) + .collect(Collectors.toList()); + + Assertions.assertEquals(streamToList, collectToList); + } + + @Test + public void whenComparingStreamToList_withUnmodifiedCollectToList_thenEqual() { + + List streamToList = Stream.of(Locale.getISOCountries()) + .toList(); + List collectToUnmodifiableList = Stream.of(Locale.getISOCountries()) + .collect(Collectors.toUnmodifiableList()); + + Assertions.assertEquals(streamToList, collectToUnmodifiableList); + } + + @Test + public void whenNullCollectorsToList_thenSuccess() { + + Assertions.assertDoesNotThrow(() -> { + Stream.of(null, null) + .collect(Collectors.toList()); + }); + } + + @Test + public void whenNullCollectorsUnmodifiableToList_thenException() { + + Assertions.assertThrows(NullPointerException.class, () -> { + Stream.of(null, null) + .collect(Collectors.toUnmodifiableList()); + }); + } + + @Test + public void whenNullStreamToList_thenSuccess() { + + Assertions.assertDoesNotThrow(() -> { + Stream.of(null, null) + .toList(); + }); + } + +} diff --git a/core-java-modules/core-java-8-2/pom.xml b/core-java-modules/core-java-8-2/pom.xml index e1a861a63c..f3e60f8d5f 100644 --- a/core-java-modules/core-java-8-2/pom.xml +++ b/core-java-modules/core-java-8-2/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-8-2 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-8-datetime-2/pom.xml b/core-java-modules/core-java-8-datetime-2/pom.xml index 9972122544..a5a0417374 100644 --- a/core-java-modules/core-java-8-datetime-2/pom.xml +++ b/core-java-modules/core-java-8-datetime-2/pom.xml @@ -7,7 +7,7 @@ ${project.parent.version} core-java-8-datetime-2 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-8-datetime/pom.xml b/core-java-modules/core-java-8-datetime/pom.xml index 48b2d062b0..a79d5d089b 100644 --- a/core-java-modules/core-java-8-datetime/pom.xml +++ b/core-java-modules/core-java-8-datetime/pom.xml @@ -7,7 +7,7 @@ ${project.parent.version} core-java-8-datetime jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-8/README.md b/core-java-modules/core-java-8/README.md index 72bdafe5fa..ff4ceaf6db 100644 --- a/core-java-modules/core-java-8/README.md +++ b/core-java-modules/core-java-8/README.md @@ -4,7 +4,6 @@ This module contains articles about Java 8 core features ### Relevant Articles: - [New Features in Java 8](https://www.baeldung.com/java-8-new-features) -- [Guide to Java 8 groupingBy Collector](https://www.baeldung.com/java-groupingby-collector) - [Strategy Design Pattern in Java 8](https://www.baeldung.com/java-strategy-pattern) - [Guide to Java 8 Comparator.comparing()](https://www.baeldung.com/java-8-comparator-comparing) - [Guide to the Java 8 forEach](https://www.baeldung.com/foreach-java) diff --git a/core-java-modules/core-java-8/pom.xml b/core-java-modules/core-java-8/pom.xml index 13b2fbcf89..a7a2a1a0f8 100644 --- a/core-java-modules/core-java-8/pom.xml +++ b/core-java-modules/core-java-8/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-8 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPost.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPost.java deleted file mode 100644 index afc05e356a..0000000000 --- a/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPost.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.java_8_features.groupingby; - -public class BlogPost { - private String title; - private String author; - private BlogPostType type; - private int likes; - - public BlogPost(String title, String author, BlogPostType type, int likes) { - this.title = title; - this.author = author; - this.type = type; - this.likes = likes; - } - - public String getTitle() { - return title; - } - - public String getAuthor() { - return author; - } - - public BlogPostType getType() { - return type; - } - - public int getLikes() { - return likes; - } - - @Override - public String toString() { - return "BlogPost{" + "title='" + title + '\'' + ", type=" + type + ", likes=" + likes + '}'; - } -} diff --git a/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPostType.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPostType.java deleted file mode 100644 index 2029784e91..0000000000 --- a/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPostType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.java_8_features.groupingby; - -public enum BlogPostType { - NEWS, REVIEW, GUIDE -} diff --git a/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/Tuple.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/Tuple.java deleted file mode 100644 index 82a84bb2d6..0000000000 --- a/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/Tuple.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.baeldung.java_8_features.groupingby; - -import java.util.Objects; - -public class Tuple { - private final BlogPostType type; - private final String author; - - public Tuple(BlogPostType type, String author) { - this.type = type; - this.author = author; - } - - public BlogPostType getType() { - return type; - } - - public String getAuthor() { - return author; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Tuple tuple = (Tuple) o; - return type == tuple.type && author.equals(tuple.author); - } - - @Override - public int hashCode() { - return Objects.hash(type, author); - } - - @Override - public String toString() { - return "Tuple{" + "type=" + type + ", author='" + author + '\'' + '}'; - } -} diff --git a/core-java-modules/core-java-8/src/test/java/com/baeldung/java_8_features/groupingby/Java8GroupingByCollectorUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java_8_features/groupingby/Java8GroupingByCollectorUnitTest.java deleted file mode 100644 index 1da705294e..0000000000 --- a/core-java-modules/core-java-8/src/test/java/com/baeldung/java_8_features/groupingby/Java8GroupingByCollectorUnitTest.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.baeldung.java_8_features.groupingby; - -import static java.util.Comparator.comparingInt; -import static java.util.stream.Collectors.averagingInt; -import static java.util.stream.Collectors.counting; -import static java.util.stream.Collectors.groupingBy; -import static java.util.stream.Collectors.groupingByConcurrent; -import static java.util.stream.Collectors.joining; -import static java.util.stream.Collectors.mapping; -import static java.util.stream.Collectors.maxBy; -import static java.util.stream.Collectors.summarizingInt; -import static java.util.stream.Collectors.summingInt; -import static java.util.stream.Collectors.toList; -import static java.util.stream.Collectors.toSet; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.EnumMap; -import java.util.IntSummaryStatistics; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentMap; - -import org.junit.Test; - -public class Java8GroupingByCollectorUnitTest { - - private static final List posts = Arrays.asList(new BlogPost("News item 1", "Author 1", BlogPostType.NEWS, 15), new BlogPost("Tech review 1", "Author 2", BlogPostType.REVIEW, 5), - new BlogPost("Programming guide", "Author 1", BlogPostType.GUIDE, 20), new BlogPost("News item 2", "Author 2", BlogPostType.NEWS, 35), new BlogPost("Tech review 2", "Author 1", BlogPostType.REVIEW, 15)); - - @Test - public void givenAListOfPosts_whenGroupedByType_thenGetAMapBetweenTypeAndPosts() { - Map> postsPerType = posts.stream() - .collect(groupingBy(BlogPost::getType)); - - assertEquals(2, postsPerType.get(BlogPostType.NEWS) - .size()); - assertEquals(1, postsPerType.get(BlogPostType.GUIDE) - .size()); - assertEquals(2, postsPerType.get(BlogPostType.REVIEW) - .size()); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeAndTheirTitlesAreJoinedInAString_thenGetAMapBetweenTypeAndCsvTitles() { - Map postsPerType = posts.stream() - .collect(groupingBy(BlogPost::getType, mapping(BlogPost::getTitle, joining(", ", "Post titles: [", "]")))); - - assertEquals("Post titles: [News item 1, News item 2]", postsPerType.get(BlogPostType.NEWS)); - assertEquals("Post titles: [Programming guide]", postsPerType.get(BlogPostType.GUIDE)); - assertEquals("Post titles: [Tech review 1, Tech review 2]", postsPerType.get(BlogPostType.REVIEW)); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeAndSumTheLikes_thenGetAMapBetweenTypeAndPostLikes() { - Map likesPerType = posts.stream() - .collect(groupingBy(BlogPost::getType, summingInt(BlogPost::getLikes))); - - assertEquals(50, likesPerType.get(BlogPostType.NEWS) - .intValue()); - assertEquals(20, likesPerType.get(BlogPostType.REVIEW) - .intValue()); - assertEquals(20, likesPerType.get(BlogPostType.GUIDE) - .intValue()); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeInAnEnumMap_thenGetAnEnumMapBetweenTypeAndPosts() { - EnumMap> postsPerType = posts.stream() - .collect(groupingBy(BlogPost::getType, () -> new EnumMap<>(BlogPostType.class), toList())); - - assertEquals(2, postsPerType.get(BlogPostType.NEWS) - .size()); - assertEquals(1, postsPerType.get(BlogPostType.GUIDE) - .size()); - assertEquals(2, postsPerType.get(BlogPostType.REVIEW) - .size()); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeInSets_thenGetAMapBetweenTypesAndSetsOfPosts() { - Map> postsPerType = posts.stream() - .collect(groupingBy(BlogPost::getType, toSet())); - - assertEquals(2, postsPerType.get(BlogPostType.NEWS) - .size()); - assertEquals(1, postsPerType.get(BlogPostType.GUIDE) - .size()); - assertEquals(2, postsPerType.get(BlogPostType.REVIEW) - .size()); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeConcurrently_thenGetAMapBetweenTypeAndPosts() { - ConcurrentMap> postsPerType = posts.parallelStream() - .collect(groupingByConcurrent(BlogPost::getType)); - - assertEquals(2, postsPerType.get(BlogPostType.NEWS) - .size()); - assertEquals(1, postsPerType.get(BlogPostType.GUIDE) - .size()); - assertEquals(2, postsPerType.get(BlogPostType.REVIEW) - .size()); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeAndAveragingLikes_thenGetAMapBetweenTypeAndAverageNumberOfLikes() { - Map averageLikesPerType = posts.stream() - .collect(groupingBy(BlogPost::getType, averagingInt(BlogPost::getLikes))); - - assertEquals(25, averageLikesPerType.get(BlogPostType.NEWS) - .intValue()); - assertEquals(20, averageLikesPerType.get(BlogPostType.GUIDE) - .intValue()); - assertEquals(10, averageLikesPerType.get(BlogPostType.REVIEW) - .intValue()); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeAndCounted_thenGetAMapBetweenTypeAndNumberOfPosts() { - Map numberOfPostsPerType = posts.stream() - .collect(groupingBy(BlogPost::getType, counting())); - - assertEquals(2, numberOfPostsPerType.get(BlogPostType.NEWS) - .intValue()); - assertEquals(1, numberOfPostsPerType.get(BlogPostType.GUIDE) - .intValue()); - assertEquals(2, numberOfPostsPerType.get(BlogPostType.REVIEW) - .intValue()); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeAndMaxingLikes_thenGetAMapBetweenTypeAndMaximumNumberOfLikes() { - Map> maxLikesPerPostType = posts.stream() - .collect(groupingBy(BlogPost::getType, maxBy(comparingInt(BlogPost::getLikes)))); - - assertTrue(maxLikesPerPostType.get(BlogPostType.NEWS) - .isPresent()); - assertEquals(35, maxLikesPerPostType.get(BlogPostType.NEWS) - .get() - .getLikes()); - - assertTrue(maxLikesPerPostType.get(BlogPostType.GUIDE) - .isPresent()); - assertEquals(20, maxLikesPerPostType.get(BlogPostType.GUIDE) - .get() - .getLikes()); - - assertTrue(maxLikesPerPostType.get(BlogPostType.REVIEW) - .isPresent()); - assertEquals(15, maxLikesPerPostType.get(BlogPostType.REVIEW) - .get() - .getLikes()); - } - - @Test - public void givenAListOfPosts_whenGroupedByAuthorAndThenByType_thenGetAMapBetweenAuthorAndMapsBetweenTypeAndBlogPosts() { - Map>> map = posts.stream() - .collect(groupingBy(BlogPost::getAuthor, groupingBy(BlogPost::getType))); - - assertEquals(1, map.get("Author 1") - .get(BlogPostType.NEWS) - .size()); - assertEquals(1, map.get("Author 1") - .get(BlogPostType.GUIDE) - .size()); - assertEquals(1, map.get("Author 1") - .get(BlogPostType.REVIEW) - .size()); - - assertEquals(1, map.get("Author 2") - .get(BlogPostType.NEWS) - .size()); - assertEquals(1, map.get("Author 2") - .get(BlogPostType.REVIEW) - .size()); - assertNull(map.get("Author 2") - .get(BlogPostType.GUIDE)); - } - - @Test - public void givenAListOfPosts_whenGroupedByTypeAndSummarizingLikes_thenGetAMapBetweenTypeAndSummary() { - Map likeStatisticsPerType = posts.stream() - .collect(groupingBy(BlogPost::getType, summarizingInt(BlogPost::getLikes))); - - IntSummaryStatistics newsLikeStatistics = likeStatisticsPerType.get(BlogPostType.NEWS); - - assertEquals(2, newsLikeStatistics.getCount()); - assertEquals(50, newsLikeStatistics.getSum()); - assertEquals(25.0, newsLikeStatistics.getAverage(), 0.001); - assertEquals(35, newsLikeStatistics.getMax()); - assertEquals(15, newsLikeStatistics.getMin()); - } - - @Test - public void givenAListOfPosts_whenGroupedByComplexMapKeyType_thenGetAMapBetweenTupleAndList() { - Map> postsPerTypeAndAuthor = posts.stream() - .collect(groupingBy(post -> new Tuple(post.getType(), post.getAuthor()))); - - List result = postsPerTypeAndAuthor.get(new Tuple(BlogPostType.GUIDE, "Author 1")); - - assertThat(result.size()).isEqualTo(1); - - BlogPost blogPost = result.get(0); - - assertThat(blogPost.getTitle()).isEqualTo("Programming guide"); - assertThat(blogPost.getType()).isEqualTo(BlogPostType.GUIDE); - assertThat(blogPost.getAuthor()).isEqualTo("Author 1"); - } -} diff --git a/core-java-modules/core-java-9-new-features/pom.xml b/core-java-modules/core-java-9-new-features/pom.xml index 2f174002bb..00480a28e1 100644 --- a/core-java-modules/core-java-9-new-features/pom.xml +++ b/core-java-modules/core-java-9-new-features/pom.xml @@ -39,7 +39,7 @@ test - + incubator-features @@ -131,7 +131,7 @@ - + core-java-9-new-features diff --git a/core-java-modules/core-java-arrays-operations-advanced/README.md b/core-java-modules/core-java-arrays-operations-advanced/README.md index 0e003b5cd9..f0d3d1fd93 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/README.md +++ b/core-java-modules/core-java-arrays-operations-advanced/README.md @@ -10,3 +10,4 @@ This module contains articles about advanced operations on arrays in Java. They - [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) - [Comparing Arrays in Java](https://www.baeldung.com/java-comparing-arrays) - [Concatenate Two Arrays in Java](https://www.baeldung.com/java-concatenate-arrays) +- [Performance of System.arraycopy() vs. Arrays.copyOf()](https://www.baeldung.com/java-system-arraycopy-arrays-copyof-performance) diff --git a/core-java-modules/core-java-arrays-operations-advanced/pom.xml b/core-java-modules/core-java-arrays-operations-advanced/pom.xml index 5663a7d1ca..065f1930e2 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/pom.xml +++ b/core-java-modules/core-java-arrays-operations-advanced/pom.xml @@ -26,10 +26,50 @@ ${assertj-core.version} test + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + 3.10.0 + 1.33 + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + com.baeldung.copyarraymethodsperformance.BenchmarkRunner + + + + + + make-assembly + package + + single + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/BenchmarkRunner.java b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/BenchmarkRunner.java new file mode 100644 index 0000000000..0adbcc1986 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/BenchmarkRunner.java @@ -0,0 +1,11 @@ +package com.baeldung.copyarraymethodsperformance; + +public class BenchmarkRunner { + + public static void main(String[] args) throws Exception { + + org.openjdk.jmh.Main.main(args); + + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/ObjectsCopyBenchmark.java b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/ObjectsCopyBenchmark.java new file mode 100644 index 0000000000..6a492bf0d1 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/ObjectsCopyBenchmark.java @@ -0,0 +1,42 @@ +package com.baeldung.copyarraymethodsperformance; + +import org.openjdk.jmh.annotations.*; + +import java.util.Arrays; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.AverageTime) +@State(Scope.Thread) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Warmup(iterations = 10) +@Fork(1) +@Measurement(iterations = 100) +public class ObjectsCopyBenchmark { + + @Param({ "10", "1000000" }) + public int SIZE; + Integer[] src; + + @Setup + public void setup() { + Random r = new Random(); + src = new Integer[SIZE]; + + for (int i = 0; i < SIZE; i++) { + src[i] = r.nextInt(); + } + } + + @Benchmark + public Integer[] systemArrayCopyBenchmark() { + Integer[] target = new Integer[SIZE]; + System.arraycopy(src, 0, target, 0, SIZE); + return target; + } + + @Benchmark + public Integer[] arraysCopyOfBenchmark() { + return Arrays.copyOf(src, SIZE); + } +} diff --git a/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/PrimitivesCopyBenchmark.java b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/PrimitivesCopyBenchmark.java new file mode 100644 index 0000000000..767e91a350 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/copyarraymethodsperformance/PrimitivesCopyBenchmark.java @@ -0,0 +1,43 @@ +package com.baeldung.copyarraymethodsperformance; + +import org.openjdk.jmh.annotations.*; + +import java.util.Arrays; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.AverageTime) +@State(Scope.Thread) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Warmup(iterations = 10) +@Fork(1) +@Measurement(iterations = 100) +public class PrimitivesCopyBenchmark { + + @Param({ "10", "1000000" }) + public int SIZE; + + int[] src; + + @Setup + public void setup() { + Random r = new Random(); + src = new int[SIZE]; + + for (int i = 0; i < SIZE; i++) { + src[i] = r.nextInt(); + } + } + + @Benchmark + public int[] systemArrayCopyBenchmark() { + int[] target = new int[SIZE]; + System.arraycopy(src, 0, target, 0, SIZE); + return target; + } + + @Benchmark + public int[] arraysCopyOfBenchmark() { + return Arrays.copyOf(src, SIZE); + } +} diff --git a/core-java-modules/core-java-arrays-sorting/pom.xml b/core-java-modules/core-java-arrays-sorting/pom.xml index d30e2bfabc..8c55204347 100644 --- a/core-java-modules/core-java-arrays-sorting/pom.xml +++ b/core-java-modules/core-java-arrays-sorting/pom.xml @@ -78,4 +78,5 @@ 28.2-jre 3.10.0 + \ No newline at end of file diff --git a/core-java-modules/core-java-char/pom.xml b/core-java-modules/core-java-char/pom.xml index ef356d9542..23156b5a22 100644 --- a/core-java-modules/core-java-char/pom.xml +++ b/core-java-modules/core-java-char/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-char jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-collections-2/pom.xml b/core-java-modules/core-java-collections-2/pom.xml index 421ba9abac..ad76990af3 100644 --- a/core-java-modules/core-java-collections-2/pom.xml +++ b/core-java-modules/core-java-collections-2/pom.xml @@ -6,7 +6,7 @@ core-java-collections-2 core-java-collections-2 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-collections-3/pom.xml b/core-java-modules/core-java-collections-3/pom.xml index c7b1284d5c..40f1867738 100644 --- a/core-java-modules/core-java-collections-3/pom.xml +++ b/core-java-modules/core-java-collections-3/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-collections-3 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-collections-4/pom.xml b/core-java-modules/core-java-collections-4/pom.xml index 7eb8222211..9dc26cd5d5 100644 --- a/core-java-modules/core-java-collections-4/pom.xml +++ b/core-java-modules/core-java-collections-4/pom.xml @@ -1,31 +1,31 @@ - 4.0.0 - core-java-collections-4 - 0.1.0-SNAPSHOT - core-java-collections-4 - jar + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + core-java-collections-4 + 0.1.0-SNAPSHOT + core-java-collections-4 + jar - - com.baeldung.core-java-modules - core-java-modules - 0.0.1-SNAPSHOT - ../pom.xml - + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../pom.xml + - - - org.assertj - assertj-core - ${assertj.version} - test - - + + + org.assertj + assertj-core + ${assertj.version} + test + + - - 3.19.0 - + + 3.19.0 + \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-3/README.md b/core-java-modules/core-java-collections-maps-3/README.md index 530a9310c2..68df2b9556 100644 --- a/core-java-modules/core-java-collections-maps-3/README.md +++ b/core-java-modules/core-java-collections-maps-3/README.md @@ -8,5 +8,5 @@ This module contains articles about Map data structures in Java. - [The Map.computeIfAbsent() Method](https://www.baeldung.com/java-map-computeifabsent) - [Collections.synchronizedMap vs. ConcurrentHashMap](https://www.baeldung.com/java-synchronizedmap-vs-concurrenthashmap) - [Java HashMap Load Factor](https://www.baeldung.com/java-hashmap-load-factor) -- [Converting java.util.Properties to HashMap](https://www.baeldung.com/java-convert-properties-to-hashmap) +- [Converting Java Properties to HashMap](https://www.baeldung.com/java-convert-properties-to-hashmap) - More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps-2) diff --git a/core-java-modules/core-java-collections-maps-4/README.md b/core-java-modules/core-java-collections-maps-4/README.md new file mode 100644 index 0000000000..4449d3859b --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/README.md @@ -0,0 +1,6 @@ +## Java Collections Cookbooks and Examples + +This module contains articles about Map data structures in Java. + +### Relevant Articles: +- [Using a Custom Class as a Key in a Java HashMap](https://www.baeldung.com/custom-key-hashmap) diff --git a/core-java-modules/core-java-collections-maps-4/pom.xml b/core-java-modules/core-java-collections-maps-4/pom.xml new file mode 100644 index 0000000000..1835e3ceac --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + core-java-collections-maps-4 + 0.1.0-SNAPSHOT + core-java-collections-maps-4 + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../pom.xml + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + !performance + + + + + + + diff --git a/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateKey.java b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateKey.java new file mode 100644 index 0000000000..34ae3d7952 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateKey.java @@ -0,0 +1,39 @@ +package com.baeldung.maps; + +import java.util.Objects; + +public class CoordinateKey { + + private final int x; + private final int y; + private final int hashCode; + + public CoordinateKey(int x, int y) { + this.x = x; + this.y = y; + this.hashCode = Objects.hash(x, y); + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CoordinateKey that = (CoordinateKey) o; + return x == that.x && y == that.y; + } + + @Override + public int hashCode() { + return this.hashCode; + } +} diff --git a/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateMutableKey.java b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateMutableKey.java new file mode 100644 index 0000000000..08b329de3d --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateMutableKey.java @@ -0,0 +1,45 @@ +package com.baeldung.maps; + +import java.util.Objects; + +public class CoordinateMutableKey { + + private int x; + private int y; + + public CoordinateMutableKey(int x, int y) { + this.x = x; + this.y = y; + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CoordinateMutableKey that = (CoordinateMutableKey) o; + return x == that.x && y == that.y; + } + + @Override + public int hashCode() { + return Objects.hash(x, y); + } +} diff --git a/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateSlowKey.java b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateSlowKey.java new file mode 100644 index 0000000000..9fe54bd9ea --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/maps/CoordinateSlowKey.java @@ -0,0 +1,13 @@ +package com.baeldung.maps; + +public class CoordinateSlowKey extends CoordinateKey { + + public CoordinateSlowKey(int x, int y) { + super(x, y); + } + + @Override + public int hashCode() { + return 1; + } +} diff --git a/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/maps/CoordinateKeyUnitTest.java b/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/maps/CoordinateKeyUnitTest.java new file mode 100644 index 0000000000..8ee68c4a3d --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/maps/CoordinateKeyUnitTest.java @@ -0,0 +1,80 @@ +package com.baeldung.maps; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class CoordinateKeyUnitTest { + + private Map pixels = new HashMap<>(); + + @Test + void testOptimalKey() { + // setup + CoordinateKey coord = new CoordinateKey(1, 2); + pixels.put(coord, Color.CYAN); + // read out color correctly + assertEquals(Color.CYAN, pixels.get(coord)); + } + + @Test + void testSlowKey() { + // setup + CoordinateKey coord = new CoordinateSlowKey(1, 2); + pixels.put(coord, Color.CYAN); + // read out color correctly + assertEquals(Color.CYAN, pixels.get(coord)); + } + + // Performance Test Parameters - change here + private static final int MAX_X = 100; + private static final int MAX_Y = 100; + private static final int COUNT_OF_QUERIES = 1000; + private static final int QUERY_X = 1; + private static final int QUERY_Y = 1; + + @Tag("performance") + @Test + void testKeyPerformance() { + // generate some sample keys and values + for (int x = 0; x < MAX_X; x++) { + for (int y = 0; y < MAX_Y; y++) { + pixels.put(new CoordinateKey(x, y), new Color(x % 255, y % 255, (x + y) % 255)); + } + } + // read out multiple times and measure time + CoordinateKey coord = new CoordinateKey(QUERY_X, QUERY_Y); + long t1 = System.currentTimeMillis(); + for (int i = 0; i < COUNT_OF_QUERIES; i++) { + assertNotNull(pixels.get(coord)); + } + long t2 = System.currentTimeMillis(); + System.out.printf("Optimal key performance: %d ms%n", t2 - t1); + } + + @Tag("performance") + @Test + void testSlowKeyPerformance() { + // generate some sample keys and values + for (int x = 0; x < MAX_X; x++) { + for (int y = 0; y < MAX_Y; y++) { + pixels.put(new CoordinateSlowKey(x, y), new Color(x % 255, y % 255, (x + y) % 255)); + } + } + // read out multiple times and measure time + CoordinateKey coord = new CoordinateSlowKey(QUERY_X, QUERY_Y); + long t1 = System.currentTimeMillis(); + for (int i = 0; i < COUNT_OF_QUERIES; i++) { + assertNotNull(pixels.get(coord)); + } + long t2 = System.currentTimeMillis(); + System.out.printf("Slow key performance: %d ms%n", t2 - t1); + } + +} diff --git a/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/maps/CoordinateMutableKeyUnitTest.java b/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/maps/CoordinateMutableKeyUnitTest.java new file mode 100644 index 0000000000..54a61be230 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/maps/CoordinateMutableKeyUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.maps; + +import org.junit.jupiter.api.Test; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +public class CoordinateMutableKeyUnitTest { + + @Test + void testKeyMutable() { + // setup + Map pixels = new HashMap<>(); + CoordinateMutableKey coord = new CoordinateMutableKey(1, 2); + pixels.put(coord, Color.CYAN); + // read out color correctly + assertEquals(Color.CYAN, pixels.get(coord)); + // change key's hashcode should result in null value + coord.setX(10); + assertNull(pixels.get(coord)); + } + +} diff --git a/core-java-modules/core-java-collections-maps/pom.xml b/core-java-modules/core-java-collections-maps/pom.xml index 68e5c736cd..855f40c304 100644 --- a/core-java-modules/core-java-collections-maps/pom.xml +++ b/core-java-modules/core-java-collections-maps/pom.xml @@ -33,5 +33,5 @@ 4.1 3.6.1 - - + + \ No newline at end of file diff --git a/core-java-modules/core-java-collections/pom.xml b/core-java-modules/core-java-collections/pom.xml index 81bcdc74aa..38513c889a 100644 --- a/core-java-modules/core-java-collections/pom.xml +++ b/core-java-modules/core-java-collections/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-collections jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-console/README.md b/core-java-modules/core-java-console/README.md index 0a31727588..9236e9cf99 100644 --- a/core-java-modules/core-java-console/README.md +++ b/core-java-modules/core-java-console/README.md @@ -3,6 +3,6 @@ ### Relevant Articles: - [Read and Write User Input in Java](http://www.baeldung.com/java-console-input-output) -- [Formatting with printf() in Java](https://www.baeldung.com/java-printstream-printf) +- [Formatting Output with printf() in Java](https://www.baeldung.com/java-printstream-printf) - [ASCII Art in Java](http://www.baeldung.com/ascii-art-in-java) - [System.console() vs. System.out](https://www.baeldung.com/java-system-console-vs-system-out) diff --git a/core-java-modules/core-java-date-operations-1/pom.xml b/core-java-modules/core-java-date-operations-1/pom.xml index 955cd910e9..7b7c68d1b6 100644 --- a/core-java-modules/core-java-date-operations-1/pom.xml +++ b/core-java-modules/core-java-date-operations-1/pom.xml @@ -26,7 +26,6 @@ commons-lang3 ${commons-lang3.version} - org.assertj assertj-core diff --git a/core-java-modules/core-java-datetime-string/README.md b/core-java-modules/core-java-datetime-string/README.md index cf00bdeb1f..aac123a884 100644 --- a/core-java-modules/core-java-datetime-string/README.md +++ b/core-java-modules/core-java-datetime-string/README.md @@ -11,3 +11,4 @@ This module contains articles about parsing and formatting Java date and time ob - [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones) - [Convert between String and Timestamp](https://www.baeldung.com/java-string-to-timestamp) - [Convert String to Date in Java](http://www.baeldung.com/java-string-to-date) +- [Format a Milliseconds Duration to HH:MM:SS](https://www.baeldung.com/java-ms-to-hhmmss) diff --git a/core-java-modules/core-java-datetime-string/pom.xml b/core-java-modules/core-java-datetime-string/pom.xml index dc0c5fd8b1..f50eb2ae5e 100644 --- a/core-java-modules/core-java-datetime-string/pom.xml +++ b/core-java-modules/core-java-datetime-string/pom.xml @@ -75,7 +75,7 @@ 1.6 - 2.10 + 2.10.10 3.6.1 1.9 diff --git a/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/formatduration/FormatDurationUnitTest.java b/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/formatduration/FormatDurationUnitTest.java new file mode 100644 index 0000000000..1612edd30b --- /dev/null +++ b/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/formatduration/FormatDurationUnitTest.java @@ -0,0 +1,54 @@ +package com.baeldung.formatduration; + +import org.apache.commons.lang3.time.DurationFormatUtils; +import org.joda.time.Period; +import org.junit.Test; + +import java.time.Duration; +import java.util.concurrent.TimeUnit; + +import static org.assertj.core.api.Assertions.assertThat; + +public class FormatDurationUnitTest { + + + @Test + public void givenInterval_WhenFormatInterval_formatDuration() { + long HH = TimeUnit.MILLISECONDS.toHours(38114000); + long MM = TimeUnit.MILLISECONDS.toMinutes(38114000) % 60; + long SS = TimeUnit.MILLISECONDS.toSeconds(38114000) % 60; + String timeInHHMMSS = String.format("%02d:%02d:%02d", HH, MM, SS); + + assertThat(timeInHHMMSS).isEqualTo("10:35:14"); + } + + @Test + public void givenInterval_WhenFormatUsingDuration_formatDuration() { + Duration duration = Duration.ofMillis(38114000); + long seconds = duration.getSeconds(); + long HH = seconds / 3600; + long MM = (seconds % 3600) / 60; + long SS = seconds % 60; + String timeInHHMMSS = String.format("%02d:%02d:%02d", HH, MM, SS); + assertThat(timeInHHMMSS).isEqualTo("10:35:14"); + } + + + @Test + public void givenInterval_WhenFormatDurationUsingApacheCommons_formatDuration() { + assertThat(DurationFormatUtils.formatDuration(38114000, "HH:mm:ss")) + .isEqualTo("10:35:14"); + } + + @Test + public void givenInterval_WhenFormatDurationUsingJodaTime_formatDuration() { + org.joda.time.Duration duration = new org.joda.time.Duration(38114000); + Period period = duration.toPeriod(); + long HH = period.getHours(); + long MM = period.getMinutes(); + long SS = period.getSeconds(); + + String timeInHHMMSS = String.format("%02d:%02d:%02d", HH, MM, SS); + assertThat(timeInHHMMSS).isEqualTo("10:35:14"); + } +} diff --git a/core-java-modules/core-java-exceptions-3/pom.xml b/core-java-modules/core-java-exceptions-3/pom.xml index 6e35845c6a..c4c3c00b56 100644 --- a/core-java-modules/core-java-exceptions-3/pom.xml +++ b/core-java-modules/core-java-exceptions-3/pom.xml @@ -36,4 +36,5 @@ 3.10.0 + \ No newline at end of file diff --git a/core-java-modules/core-java-io-conversions/README.md b/core-java-modules/core-java-io-conversions/README.md index 1f12c87241..52f5222040 100644 --- a/core-java-modules/core-java-io-conversions/README.md +++ b/core-java-modules/core-java-io-conversions/README.md @@ -13,4 +13,5 @@ This module contains articles about core Java input/output(IO) conversions. - [Java – Write a Reader to File](https://www.baeldung.com/java-write-reader-to-file) - [Java – Reader to Byte Array](https://www.baeldung.com/java-convert-reader-to-byte-array) - [Java – Reader to InputStream](https://www.baeldung.com/java-convert-reader-to-inputstream) +- [Java String to InputStream](https://www.baeldung.com/convert-string-to-input-stream) - More articles: [[next -->]](/core-java-modules/core-java-io-conversions-2) diff --git a/core-java-modules/core-java-io/src/main/resources/logback.xml b/core-java-modules/core-java-io/src/main/resources/logback.xml index 56af2d397e..617917dca2 100644 --- a/core-java-modules/core-java-io/src/main/resources/logback.xml +++ b/core-java-modules/core-java-io/src/main/resources/logback.xml @@ -9,6 +9,7 @@ + diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml index b638f81b0c..ae2333d721 100644 --- a/core-java-modules/core-java-jar/pom.xml +++ b/core-java-modules/core-java-jar/pom.xml @@ -76,6 +76,7 @@ org.apache.maven.plugins maven-dependency-plugin + ${maven-dependency-plugin.version} copy-dependencies @@ -106,6 +107,7 @@ org.apache.maven.plugins maven-assembly-plugin + ${maven-assembly-plugin.version} package @@ -383,6 +385,8 @@ 3.0.2 1.4.4 3.1.1 + 3.3.0 + 3.2.0 2.0.3.RELEASE 1.8 1.8 diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java index e0ad264797..3e4ee0a1bb 100644 --- a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java @@ -6,57 +6,80 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; public class IsInstanceIsAssignableFromUnitTest { - + @Test - public void whenUsingIsInstanceProperly_desiredResultsHappen() { + public void whenUsingInstanceOfProperly_thenDesiredResultsHappen() { + Shape shape = new Triangle(); + Triangle triangle = new Triangle(); + IsoscelesTriangle isoscelesTriangle = new IsoscelesTriangle(); + Shape nonspecificShape = null; + + assertTrue(shape instanceof Shape); + assertTrue(triangle instanceof Shape); + assertTrue(isoscelesTriangle instanceof Shape); + assertFalse(nonspecificShape instanceof Shape); + + assertTrue(shape instanceof Triangle); + assertTrue(triangle instanceof Triangle); + assertTrue(isoscelesTriangle instanceof Triangle); + assertFalse(nonspecificShape instanceof Triangle); + + assertFalse(shape instanceof IsoscelesTriangle); + assertFalse(triangle instanceof IsoscelesTriangle); + assertTrue(isoscelesTriangle instanceof IsoscelesTriangle); + assertFalse(nonspecificShape instanceof IsoscelesTriangle); + } + + @Test + public void whenUsingIsInstanceProperly_thenDesiredResultsHappen() { Shape shape = new Triangle(); Triangle triangle = new Triangle(); IsoscelesTriangle isoscelesTriangle = new IsoscelesTriangle(); Triangle isoscelesTriangle2 = new IsoscelesTriangle(); Shape nonspecificShape = null; - + assertTrue(Shape.class.isInstance(shape)); assertTrue(Shape.class.isInstance(triangle)); assertTrue(Shape.class.isInstance(isoscelesTriangle)); assertTrue(Shape.class.isInstance(isoscelesTriangle2)); assertFalse(Shape.class.isInstance(nonspecificShape)); - + assertTrue(Triangle.class.isInstance(shape)); assertTrue(Triangle.class.isInstance(triangle)); assertTrue(Triangle.class.isInstance(isoscelesTriangle)); assertTrue(Triangle.class.isInstance(isoscelesTriangle2)); - + assertFalse(IsoscelesTriangle.class.isInstance(shape)); assertFalse(IsoscelesTriangle.class.isInstance(triangle)); assertTrue(IsoscelesTriangle.class.isInstance(isoscelesTriangle)); - assertTrue(IsoscelesTriangle.class.isInstance(isoscelesTriangle2)); + assertTrue(IsoscelesTriangle.class.isInstance(isoscelesTriangle2)); } - + @Test - public void whenUsingIsAssignableFromProperly_desiredResultsHappen() { + public void whenUsingIsAssignableFromProperly_thenDesiredResultsHappen() { Shape shape = new Triangle(); Triangle triangle = new Triangle(); IsoscelesTriangle isoscelesTriangle = new IsoscelesTriangle(); Triangle isoscelesTriangle2 = new IsoscelesTriangle(); - + assertFalse(shape.getClass().isAssignableFrom(Shape.class)); assertTrue(shape.getClass().isAssignableFrom(shape.getClass())); assertTrue(shape.getClass().isAssignableFrom(triangle.getClass())); assertTrue(shape.getClass().isAssignableFrom(isoscelesTriangle.getClass())); assertTrue(shape.getClass().isAssignableFrom(isoscelesTriangle2.getClass())); - + assertFalse(triangle.getClass().isAssignableFrom(Shape.class)); assertTrue(triangle.getClass().isAssignableFrom(shape.getClass())); assertTrue(triangle.getClass().isAssignableFrom(triangle.getClass())); assertTrue(triangle.getClass().isAssignableFrom(isoscelesTriangle.getClass())); assertTrue(triangle.getClass().isAssignableFrom(isoscelesTriangle2.getClass())); - + assertFalse(isoscelesTriangle.getClass().isAssignableFrom(Shape.class)); assertFalse(isoscelesTriangle.getClass().isAssignableFrom(shape.getClass())); assertFalse(isoscelesTriangle.getClass().isAssignableFrom(triangle.getClass())); assertTrue(isoscelesTriangle.getClass().isAssignableFrom(isoscelesTriangle.getClass())); assertTrue(isoscelesTriangle.getClass().isAssignableFrom(isoscelesTriangle2.getClass())); - + assertFalse(isoscelesTriangle2.getClass().isAssignableFrom(Shape.class)); assertFalse(isoscelesTriangle2.getClass().isAssignableFrom(shape.getClass())); assertFalse(isoscelesTriangle2.getClass().isAssignableFrom(triangle.getClass())); @@ -64,4 +87,31 @@ public class IsInstanceIsAssignableFromUnitTest { assertTrue(isoscelesTriangle2.getClass().isAssignableFrom(isoscelesTriangle2.getClass())); } + @Test(expected = NullPointerException.class) + public void whenUsingNull_thenDesiredResultsHappen() { + assertFalse(null instanceof Shape); + assertFalse(Shape.class.isInstance(null)); + assertFalse(Shape.class.isAssignableFrom(null)); // NullPointerException + } + + @Test + public void whenUsingPrimitiveType_thenDesiredResultsHappen() { + //assertFalse(10 instanceof int); // illegal + assertFalse(int.class.isInstance(10)); + assertTrue(Integer.class.isInstance(10)); + assertTrue(int.class.isAssignableFrom(int.class)); + assertFalse(float.class.isAssignableFrom(int.class)); + } + + @Test + public void whenUsingClassInstanceVariable_thenDesiredResultsHappen() { + Shape shape = new Triangle(); + Triangle triangle = new Triangle(); + Class clazz = shape.getClass(); + + //assertFalse(triangle instanceof clazz); // illegal + assertTrue(clazz.isInstance(triangle)); + assertTrue(clazz.isAssignableFrom(triangle.getClass())); + } + } diff --git a/core-java-modules/core-java-lang-4/README.md b/core-java-modules/core-java-lang-4/README.md index 562be950c0..4546a00fe6 100644 --- a/core-java-modules/core-java-lang-4/README.md +++ b/core-java-modules/core-java-lang-4/README.md @@ -8,3 +8,4 @@ This module contains articles about core features in the Java language - [Java Objects.hash() vs Objects.hashCode()](https://www.baeldung.com/java-objects-hash-vs-objects-hashcode) - [Referencing a Method in Javadoc Comments](https://www.baeldung.com/java-method-in-javadoc) - [Tiered Compilation in JVM](https://www.baeldung.com/jvm-tiered-compilation) +- [Fixing the “Declared package does not match the expected package” Error](https://www.baeldung.com/java-declared-expected-package-error) diff --git a/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/bookstore/Book.java b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/bookstore/Book.java new file mode 100644 index 0000000000..83ed76bab0 --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/bookstore/Book.java @@ -0,0 +1,21 @@ +// The next line is commented out to avoid the code to fail the build. +// package com.baeldung; + +/** +* If the below package declaration is commented out and the above incorrect package +* declaration is uncommented, then the problem will replicate. +*/ +package com.baeldung.bookstore; + +public class Book { + + private String title; + private String author; + private long isbn; + + public Book(String title, String author, long isbn) { + this.title = title; + this.author = author; + this.isbn = isbn; + } +} diff --git a/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/bookstore/LibraryAdmin.java b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/bookstore/LibraryAdmin.java new file mode 100644 index 0000000000..9abd654589 --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/bookstore/LibraryAdmin.java @@ -0,0 +1,14 @@ +package com.baeldung.bookstore; + +import java.util.Random; + +public class LibraryAdmin { + + public Book createBook(String title, String author) { + + final long isbn = new Random().nextLong(); + + return new Book(title, author, isbn); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-types/pom.xml b/core-java-modules/core-java-lang-oop-types/pom.xml index b770caf970..a5b492f5ca 100644 --- a/core-java-modules/core-java-lang-oop-types/pom.xml +++ b/core-java-modules/core-java-lang-oop-types/pom.xml @@ -25,6 +25,7 @@ ${commons-codec.version} + 1.15 diff --git a/core-java-modules/core-java-networking-3/README.md b/core-java-modules/core-java-networking-3/README.md index 2e76ab5d51..0dc9ad9f70 100644 --- a/core-java-modules/core-java-networking-3/README.md +++ b/core-java-modules/core-java-networking-3/README.md @@ -8,4 +8,5 @@ This module contains articles about networking in Java - [Downloading Email Attachments in Java](https://www.baeldung.com/java-download-email-attachments) - [Connection Timeout vs. Read Timeout for Java Sockets](https://www.baeldung.com/java-socket-connection-read-timeout) - [Find Whether an IP Address Is in the Specified Range or Not in Java](https://www.baeldung.com/java-check-ip-address-range) +- [Find the IP Address of a Client Connected to a Server](https://www.baeldung.com/java-client-get-ip-address) - [[<-- Prev]](/core-java-modules/core-java-networking-2) diff --git a/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/clientaddress/ApplicationClient.java b/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/clientaddress/ApplicationClient.java new file mode 100644 index 0000000000..498046904d --- /dev/null +++ b/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/clientaddress/ApplicationClient.java @@ -0,0 +1,39 @@ +package com.baeldung.clientaddress; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.Socket; + +public class ApplicationClient { + + private Socket clientSocket; + private PrintWriter out; + private BufferedReader in; + + public void connect(String ip, int port) throws IOException { + clientSocket = new Socket(ip, port); + out = new PrintWriter(clientSocket.getOutputStream(), true); + in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); + } + + public void sendGreetings(String msg) throws IOException { + out.println(msg); + String reply = in.readLine(); + System.out.println("Reply received from the server :: " + reply); + } + + public void disconnect() throws IOException { + in.close(); + out.close(); + clientSocket.close(); + } + + public static void main(String[] args) throws IOException { + ApplicationClient client = new ApplicationClient(); + client.connect(args[0], Integer.parseInt(args[1])); // IP address and port number of the server + client.sendGreetings(args[2]); // greetings message + client.disconnect(); + } +} diff --git a/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/clientaddress/ApplicationServer.java b/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/clientaddress/ApplicationServer.java new file mode 100644 index 0000000000..ded4482b9a --- /dev/null +++ b/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/clientaddress/ApplicationServer.java @@ -0,0 +1,51 @@ +package com.baeldung.clientaddress; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; + +public class ApplicationServer { + + private ServerSocket serverSocket; + private Socket connectedSocket; + private PrintWriter out; + private BufferedReader in; + + public void startServer(int port) throws IOException { + serverSocket = new ServerSocket(port); + connectedSocket = serverSocket.accept(); + + InetSocketAddress socketAddress = (InetSocketAddress) connectedSocket.getRemoteSocketAddress(); + String clientIpAddress = socketAddress.getAddress() + .getHostAddress(); + System.out.println("IP address of the connected client :: " + clientIpAddress); + + out = new PrintWriter(connectedSocket.getOutputStream(), true); + in = new BufferedReader(new InputStreamReader(connectedSocket.getInputStream())); + String msg = in.readLine(); + System.out.println("Message received from the client :: " + msg); + out.println("Hello Client !!"); + + closeIO(); + stopServer(); + } + + private void closeIO() throws IOException { + in.close(); + out.close(); + } + + private void stopServer() throws IOException { + connectedSocket.close(); + serverSocket.close(); + } + + public static void main(String[] args) throws IOException { + ApplicationServer server = new ApplicationServer(); + server.startServer(5000); + } +} diff --git a/core-java-modules/core-java-os/README.md b/core-java-modules/core-java-os/README.md index 10e04a8ba6..6d477de70a 100644 --- a/core-java-modules/core-java-os/README.md +++ b/core-java-modules/core-java-os/README.md @@ -13,5 +13,6 @@ This module contains articles about working with the operating system (OS) in Ja - [Pattern Search with Grep in Java](http://www.baeldung.com/grep-in-java) - [How to Run a Shell Command in Java](http://www.baeldung.com/run-shell-command-in-java) - [Taking Screenshots Using Java](https://www.baeldung.com/java-taking-screenshots) +- [Java Sound API – Capturing Microphone](https://www.baeldung.com/java-sound-api-capture-mic) This module uses Java 9, so make sure to have the JDK 9 installed to run it. diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index 5f00b709e3..572000a714 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -1,93 +1,100 @@ - 4.0.0 - core-java-os - 0.1.0-SNAPSHOT - core-java-os - jar + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + core-java-os + 0.1.0-SNAPSHOT + core-java-os + jar - - com.baeldung.core-java-modules - core-java-modules - 0.0.1-SNAPSHOT - ../ - + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - commons-io - commons-io - ${commons-io.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - log4j - log4j - ${log4j.version} - - - - org.assertj - assertj-core - ${assertj.version} - test - - - org.unix4j - unix4j-command - ${unix4j.version} - - - com.googlecode.grep4j - grep4j - ${grep4j.version} - - + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter-engine.version} + test + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + commons-io + commons-io + ${commons-io.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + log4j + log4j + ${log4j.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.unix4j + unix4j-command + ${unix4j.version} + + + com.googlecode.grep4j + grep4j + ${grep4j.version} + + - - core-java-os - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${maven.compiler.source} - ${maven.compiler.target} - - - - + + core-java-os + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + - - - 4.1 - 4.01 - - 3.6.1 - 1.8.9 - 1.9 - 1.9 - 25.1-jre - 0.4 - 1.8.7 - + + + 4.1 + 4.01 + + 3.6.1 + 1.8.9 + 1.9 + 1.9 + 25.1-jre + 0.4 + 1.8.7 + 5.7.2 + \ No newline at end of file diff --git a/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/App.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/App.java new file mode 100644 index 0000000000..afd7687528 --- /dev/null +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/App.java @@ -0,0 +1,34 @@ +package com.baeldung.example.soundapi; + +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFormat; + +public class App { + public static void main(String[] args) throws Exception { + + AudioFormat format = buildAudioFormatInstance(); + + SoundRecorder soundRecorder = new SoundRecorder(); + soundRecorder.build(format); + + System.out.println("Start recording ...."); + soundRecorder.start(); + Thread.sleep(20000); + soundRecorder.stop(); + + WaveDataUtil wd = new WaveDataUtil(); + Thread.sleep(3000); + wd.saveToFile("/SoundClip", AudioFileFormat.Type.WAVE, soundRecorder.getAudioInputStream()); + } + + public static AudioFormat buildAudioFormatInstance() { + ApplicationProperties aConstants = new ApplicationProperties(); + AudioFormat.Encoding encoding = aConstants.ENCODING; + float rate = aConstants.RATE; + int channels = aConstants.CHANNELS; + int sampleSize = aConstants.SAMPLE_SIZE; + boolean bigEndian = aConstants.BIG_ENDIAN; + + return new AudioFormat(encoding, rate, sampleSize, channels, (sampleSize / 8) * channels, rate, bigEndian); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/ApplicationProperties.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/ApplicationProperties.java new file mode 100644 index 0000000000..985229b969 --- /dev/null +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/ApplicationProperties.java @@ -0,0 +1,10 @@ +package com.baeldung.example.soundapi; +import javax.sound.sampled.AudioFormat; + +public class ApplicationProperties { + public final AudioFormat.Encoding ENCODING = AudioFormat.Encoding.PCM_SIGNED; + public final float RATE = 44100.0f; + public final int CHANNELS = 1; + public final int SAMPLE_SIZE = 16; + public final boolean BIG_ENDIAN = true; +} \ No newline at end of file diff --git a/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/SoundRecorder.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/SoundRecorder.java new file mode 100644 index 0000000000..cae91ee74f --- /dev/null +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/SoundRecorder.java @@ -0,0 +1,123 @@ +package com.baeldung.example.soundapi; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.TargetDataLine; + +public class SoundRecorder implements Runnable { + private AudioInputStream audioInputStream; + private AudioFormat format; + public Thread thread; + private double duration; + + public SoundRecorder() { + super(); + } + + public SoundRecorder(AudioFormat format) { + this.format = format; + } + + public SoundRecorder build(AudioFormat format) { + this.format = format; + return this; + } + + public void start() { + thread = new Thread(this); + thread.setName("Capture Microphone"); + thread.start(); + } + + public void stop() { + thread = null; + } + + @Override + public void run() { + duration = 0; + + try (final ByteArrayOutputStream out = new ByteArrayOutputStream(); final TargetDataLine line = getTargetDataLineForRecord();) { + + int frameSizeInBytes = format.getFrameSize(); + int bufferLengthInFrames = line.getBufferSize() / 8; + final int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes; + buildByteOutputStream(out, line, frameSizeInBytes, bufferLengthInBytes); + this.audioInputStream = new AudioInputStream(line); + setAudioInputStream(convertToAudioIStream(out, frameSizeInBytes)); + audioInputStream.reset(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (Exception ex) { + ex.printStackTrace(); + return; + } + } + + public void buildByteOutputStream(final ByteArrayOutputStream out, final TargetDataLine line, int frameSizeInBytes, final int bufferLengthInBytes) throws IOException { + final byte[] data = new byte[bufferLengthInBytes]; + int numBytesRead; + + line.start(); + while (thread != null) { + if ((numBytesRead = line.read(data, 0, bufferLengthInBytes)) == -1) { + break; + } + out.write(data, 0, numBytesRead); + } + } + + private void setAudioInputStream(AudioInputStream aStream) { + this.audioInputStream = aStream; + } + + public AudioInputStream convertToAudioIStream(final ByteArrayOutputStream out, int frameSizeInBytes) { + byte audioBytes[] = out.toByteArray(); + ByteArrayInputStream bais = new ByteArrayInputStream(audioBytes); + AudioInputStream audioStream = new AudioInputStream(bais, format, audioBytes.length / frameSizeInBytes); + long milliseconds = (long) ((audioInputStream.getFrameLength() * 1000) / format.getFrameRate()); + duration = milliseconds / 1000.0; + System.out.println("Recorded duration in seconds:" + duration); + return audioStream; + } + + public TargetDataLine getTargetDataLineForRecord() { + TargetDataLine line; + DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); + if (!AudioSystem.isLineSupported(info)) { + return null; + } + try { + line = (TargetDataLine) AudioSystem.getLine(info); + line.open(format, line.getBufferSize()); + } catch (final Exception ex) { + return null; + } + return line; + } + + public AudioInputStream getAudioInputStream() { + return audioInputStream; + } + + public AudioFormat getFormat() { + return format; + } + + public void setFormat(AudioFormat format) { + this.format = format; + } + + public Thread getThread() { + return thread; + } + + public double getDuration() { + return duration; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/WaveDataUtil.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/WaveDataUtil.java new file mode 100644 index 0000000000..7d63e66fdd --- /dev/null +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/example/soundapi/WaveDataUtil.java @@ -0,0 +1,34 @@ +package com.baeldung.example.soundapi; + +import java.io.File; + +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; + +public class WaveDataUtil { + public boolean saveToFile(String name, AudioFileFormat.Type fileType, AudioInputStream audioInputStream) { + System.out.println("Saving..."); + if (null == name || null == fileType || audioInputStream == null) { + return false; + } + File myFile = new File(name + "." + fileType.getExtension()); + try { + audioInputStream.reset(); + } catch (Exception e) { + return false; + } + int i = 0; + while (myFile.exists()) { + String temp = "" + i + myFile.getName(); + myFile = new File(temp); + } + try { + AudioSystem.write(audioInputStream, fileType, myFile); + } catch (Exception ex) { + return false; + } + System.out.println("Saved " + myFile.getAbsolutePath()); + return true; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessAPIEnhancements.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessAPIEnhancements.java new file mode 100644 index 0000000000..cb3c183062 --- /dev/null +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessAPIEnhancements.java @@ -0,0 +1,101 @@ +package com.baeldung.java9.process; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.stream.Stream; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProcessAPIEnhancements { + + static Logger log = LoggerFactory.getLogger(ProcessAPIEnhancements.class); + + public static void main(String[] args) throws IOException, InterruptedException, ExecutionException { + infoOfCurrentProcess(); + infoOfLiveProcesses(); + infoOfSpawnProcess(); + infoOfExitCallback(); + infoOfChildProcess(); + } + + private static void infoOfCurrentProcess() { + ProcessHandle processHandle = ProcessHandle.current(); + ProcessHandle.Info processInfo = processHandle.info(); + + log.info("PID: " + processHandle.pid()); + log.info("Arguments: " + processInfo.arguments()); + log.info("Command: " + processInfo.command()); + log.info("Instant: " + processInfo.startInstant()); + log.info("Total CPU duration: " + processInfo.totalCpuDuration()); + log.info("User: " + processInfo.user()); + } + + private static void infoOfSpawnProcess() throws IOException { + + String javaCmd = ProcessUtils.getJavaCmd().getAbsolutePath(); + ProcessBuilder processBuilder = new ProcessBuilder(javaCmd, "-version"); + Process process = processBuilder.inheritIO().start(); + ProcessHandle processHandle = process.toHandle(); + ProcessHandle.Info processInfo = processHandle.info(); + + log.info("PID: " + processHandle.pid()); + log.info("Arguments: " + processInfo.arguments()); + log.info("Command: " + processInfo.command()); + log.info("Instant: " + processInfo.startInstant()); + log.info("Total CPU duration: " + processInfo.totalCpuDuration()); + log.info("User: " + processInfo.user()); + } + + private static void infoOfLiveProcesses() { + Stream liveProcesses = ProcessHandle.allProcesses(); + liveProcesses.filter(ProcessHandle::isAlive) + .forEach(ph -> { + log.info("PID: " + ph.pid()); + log.info("Instance: " + ph.info().startInstant()); + log.info("User: " + ph.info().user()); + }); + } + + private static void infoOfChildProcess() throws IOException { + int childProcessCount = 5; + for (int i = 0; i < childProcessCount; i++) { + String javaCmd = ProcessUtils.getJavaCmd() + .getAbsolutePath(); + ProcessBuilder processBuilder + = new ProcessBuilder(javaCmd, "-version"); + processBuilder.inheritIO().start(); + } + + Stream children = ProcessHandle.current() + .children(); + children.filter(ProcessHandle::isAlive) + .forEach(ph -> log.info("PID: {}, Cmd: {}", ph.pid(), ph.info() + .command())); + Stream descendants = ProcessHandle.current() + .descendants(); + descendants.filter(ProcessHandle::isAlive) + .forEach(ph -> log.info("PID: {}, Cmd: {}", ph.pid(), ph.info() + .command())); + } + + private static void infoOfExitCallback() throws IOException, InterruptedException, ExecutionException { + String javaCmd = ProcessUtils.getJavaCmd() + .getAbsolutePath(); + ProcessBuilder processBuilder + = new ProcessBuilder(javaCmd, "-version"); + Process process = processBuilder.inheritIO() + .start(); + ProcessHandle processHandle = process.toHandle(); + + log.info("PID: {} has started", processHandle.pid()); + CompletableFuture onProcessExit = processHandle.onExit(); + onProcessExit.get(); + log.info("Alive: " + processHandle.isAlive()); + onProcessExit.thenAccept(ph -> { + log.info("PID: {} has stopped", ph.pid()); + }); + } + +} diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/example/soundapi/AppUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/example/soundapi/AppUnitTest.java new file mode 100644 index 0000000000..38f21320e3 --- /dev/null +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/example/soundapi/AppUnitTest.java @@ -0,0 +1,75 @@ +package com.baeldung.example.soundapi; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Assertions; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.TargetDataLine; + +public class AppUnitTest { + + AudioFormat af = App.buildAudioFormatInstance(); + SoundRecorder soundRecorder = new SoundRecorder(); + + @Test + public void Given_SoundRecorderObject_When_Run_Then_ThrowsNoException() { + + soundRecorder.build(af); + try { + soundRecorder.start(); + Thread.sleep(20000); + soundRecorder.stop(); + } catch (InterruptedException ex) { + fail("Exception: " + ex); + } + + } + + @Test + public void Given_AudioFormatObject_When_NotNull_Then_ReturnsTargetDataLine() { + soundRecorder.setFormat(af); + Assertions.assertDoesNotThrow(() -> soundRecorder.getTargetDataLineForRecord()); + } + + @Test + public void Given_TargetLineDataObject_When_Run_Then_GeneratesOutputStream() { + + soundRecorder.setFormat(af); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + TargetDataLine tLine = soundRecorder.getTargetDataLineForRecord(); + + int frameSizeInBytes = af.getFrameSize(); + int bufferLengthInFrames = tLine.getBufferSize() / 8; + final int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes; + + Assertions.assertDoesNotThrow( + () -> soundRecorder.buildByteOutputStream(out, tLine, frameSizeInBytes, bufferLengthInBytes)); + } + + @Test + public void Given_AudioInputStream_When_NotNull_Then_SaveToWavFile() { + soundRecorder.setFormat(af); + soundRecorder.build(af); + try { + soundRecorder.start(); + Thread.sleep(20000); + soundRecorder.stop(); + WaveDataUtil wd = new WaveDataUtil(); + Thread.sleep(3000); + boolean saveFile = wd.saveToFile("/SoundClip", AudioFileFormat.Type.WAVE, + soundRecorder.getAudioInputStream()); + + assertEquals(saveFile, true); + + } catch (InterruptedException ex) { + fail("Exception: " + ex); + } + + } + +} diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java deleted file mode 100644 index c81f060150..0000000000 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.baeldung.java9.process; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Stream; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Created by sanaulla on 2/23/2017. - */ - -public class ProcessAPIEnhancementsUnitTest { - - Logger log = LoggerFactory.getLogger(ProcessAPIEnhancementsUnitTest.class); - - // @Test - // OS / Java version dependent - public void givenCurrentProcess_whenInvokeGetInfo_thenSuccess() throws IOException { - ProcessHandle processHandle = ProcessHandle.current(); - ProcessHandle.Info processInfo = processHandle.info(); - assertNotNull(processHandle.pid()); - assertEquals(true, processInfo.arguments() - .isPresent()); - assertEquals(true, processInfo.command() - .isPresent()); - assertTrue(processInfo.command() - .get() - .contains("java")); - - assertEquals(true, processInfo.startInstant() - .isPresent()); - assertEquals(true, processInfo.totalCpuDuration() - .isPresent()); - assertEquals(true, processInfo.user() - .isPresent()); - } - - // @Test - // OS / Java version dependent - public void givenSpawnProcess_whenInvokeGetInfo_thenSuccess() throws IOException { - - String javaCmd = ProcessUtils.getJavaCmd() - .getAbsolutePath(); - ProcessBuilder processBuilder = new ProcessBuilder(javaCmd, "-version"); - Process process = processBuilder.inheritIO() - .start(); - ProcessHandle processHandle = process.toHandle(); - ProcessHandle.Info processInfo = processHandle.info(); - assertNotNull(processHandle.pid()); - assertEquals(true, processInfo.arguments() - .isPresent()); - assertEquals(true, processInfo.command() - .isPresent()); - assertTrue(processInfo.command() - .get() - .contains("java")); - assertEquals(true, processInfo.startInstant() - .isPresent()); - assertEquals(false, processInfo.totalCpuDuration() - .isPresent()); - assertEquals(true, processInfo.user() - .isPresent()); - } - - // @Test - // OS / Java version dependent - public void givenLiveProcesses_whenInvokeGetInfo_thenSuccess() { - Stream liveProcesses = ProcessHandle.allProcesses(); - liveProcesses.filter(ProcessHandle::isAlive) - .forEach(ph -> { - assertNotNull(ph.pid()); - assertEquals(true, ph.info() - .startInstant() - .isPresent()); - assertEquals(true, ph.info() - .user() - .isPresent()); - }); - } - - // @Test - // OS / Java version dependent - public void givenProcess_whenGetChildProcess_thenSuccess() throws IOException { - int childProcessCount = 5; - for (int i = 0; i < childProcessCount; i++) { - String javaCmd = ProcessUtils.getJavaCmd() - .getAbsolutePath(); - ProcessBuilder processBuilder - = new ProcessBuilder(javaCmd, "-version"); - processBuilder.inheritIO().start(); - } - - Stream children = ProcessHandle.current() - .children(); - children.filter(ProcessHandle::isAlive) - .forEach(ph -> log.info("PID: {}, Cmd: {}", ph.pid(), ph.info() - .command())); - Stream descendants = ProcessHandle.current() - .descendants(); - descendants.filter(ProcessHandle::isAlive) - .forEach(ph -> log.info("PID: {}, Cmd: {}", ph.pid(), ph.info() - .command())); - } - - // @Test - // OS / Java version dependent - public void givenProcess_whenAddExitCallback_thenSuccess() throws Exception { - String javaCmd = ProcessUtils.getJavaCmd() - .getAbsolutePath(); - ProcessBuilder processBuilder - = new ProcessBuilder(javaCmd, "-version"); - Process process = processBuilder.inheritIO() - .start(); - ProcessHandle processHandle = process.toHandle(); - - log.info("PID: {} has started", processHandle.pid()); - CompletableFuture onProcessExit = processHandle.onExit(); - onProcessExit.get(); - assertEquals(false, processHandle.isAlive()); - onProcessExit.thenAccept(ph -> { - log.info("PID: {} has stopped", ph.pid()); - }); - } - -} diff --git a/core-java-modules/core-java-security-3/README.md b/core-java-modules/core-java-security-3/README.md index 970faaac88..a37719964b 100644 --- a/core-java-modules/core-java-security-3/README.md +++ b/core-java-modules/core-java-security-3/README.md @@ -5,4 +5,5 @@ This module contains articles about core Java Security ### Relevant Articles: - [Secret Key and String Conversion in Java](https://www.baeldung.com/java-secret-key-to-string) +- [Enabling Unlimited Strength Cryptography in Java](https://www.baeldung.com/jce-enable-unlimited-strength) - More articles: [[<-- prev]](/core-java-modules/core-java-security-2) diff --git a/core-java-modules/core-java-security-3/src/test/java/com/baeldung/cryptography/CryptographyStrengthUnitTest.java b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/cryptography/CryptographyStrengthUnitTest.java new file mode 100644 index 0000000000..5d5c30dc34 --- /dev/null +++ b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/cryptography/CryptographyStrengthUnitTest.java @@ -0,0 +1,17 @@ +package com.baeldung.cryptography; + +import org.junit.Test; + +import java.security.NoSuchAlgorithmException; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CryptographyStrengthUnitTest { + private static final int UNLIMITED_KEY_SIZE = 2147483647; + + @Test + public void whenDefaultCheck_thenUnlimitedReturned() throws NoSuchAlgorithmException { + int maxKeySize = javax.crypto.Cipher.getMaxAllowedKeyLength("AES"); + assertThat(maxKeySize).isEqualTo(UNLIMITED_KEY_SIZE); + } +} diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index c8243258c1..6d1c0b0e48 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -32,6 +32,11 @@ junit-jupiter test + + commons-validator + commons-validator + ${validator.version} + @@ -59,6 +64,7 @@ 3.6.1 28.1-jre + 1.7 - \ No newline at end of file + diff --git a/core-java-modules/core-java-string-algorithms-3/src/main/java/com/baeldung/emailvalidation/EmailValidation.java b/core-java-modules/core-java-string-algorithms-3/src/main/java/com/baeldung/emailvalidation/EmailValidation.java new file mode 100644 index 0000000000..f80c87ea01 --- /dev/null +++ b/core-java-modules/core-java-string-algorithms-3/src/main/java/com/baeldung/emailvalidation/EmailValidation.java @@ -0,0 +1,12 @@ +package com.baeldung.emailvalidation; + +import java.util.regex.Pattern; + +public class EmailValidation { + + public static boolean patternMatches(String emailAddress, String regexPattern) { + return Pattern.compile(regexPattern) + .matcher(emailAddress) + .matches(); + } +} diff --git a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/emailvalidation/EmailValidationUnitTest.java b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/emailvalidation/EmailValidationUnitTest.java new file mode 100644 index 0000000000..e6bee0ce63 --- /dev/null +++ b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/emailvalidation/EmailValidationUnitTest.java @@ -0,0 +1,79 @@ +package com.baeldung.emailvalidation; + +import static org.junit.Assert.assertTrue; +import org.apache.commons.validator.routines.EmailValidator; +import org.junit.Test; + +public class EmailValidationUnitTest { + + private String emailAddress; + private String regexPattern; + + @Test + public void testUsingEmailValidator() { + emailAddress = "username@domain.com"; + assertTrue(EmailValidator.getInstance() + .isValid(emailAddress)); + } + + @Test + public void testUsingSimpleRegex() { + emailAddress = "username@domain.com"; + regexPattern = "^(.+)@(\\S+)$"; + assertTrue(EmailValidation.patternMatches(emailAddress, regexPattern)); + } + + @Test + public void testUsingStrictRegex() { + emailAddress = "username@domain.com"; + regexPattern = "^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@" + + "[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$"; + assertTrue(EmailValidation.patternMatches(emailAddress, regexPattern)); + } + + @Test + public void testUsingUnicodeRegex() { + emailAddress = "用户名@领域.电脑"; + regexPattern = "^(?=.{1,64}@)[\\p{L}0-9_-]+(\\.[\\p{L}0-9_-]+)*@" + + "[^-][\\p{L}0-9-]+(\\.[\\p{L}0-9-]+)*(\\.[\\p{L}]{2,})$"; + assertTrue(EmailValidation.patternMatches(emailAddress, regexPattern)); + } + + @Test + public void testUsingRFC5322Regex() { + emailAddress = "username@domain.com"; + regexPattern = "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$"; + assertTrue(EmailValidation.patternMatches(emailAddress, regexPattern)); + } + + @Test + public void testRestrictDots() { + emailAddress = "username@domain.com"; + regexPattern = "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+(?:\\.[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+)*@" + + "[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"; + assertTrue(EmailValidation.patternMatches(emailAddress, regexPattern)); + } + + @Test + public void testOwaspValidation() { + emailAddress = "username@domain.com"; + regexPattern = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$"; + assertTrue(EmailValidation.patternMatches(emailAddress, regexPattern)); + } + + @Test + public void testTopLevelDomain() { + emailAddress = "username@domain.com"; + regexPattern = "^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*" + + "@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$"; + assertTrue(EmailValidation.patternMatches(emailAddress, regexPattern)); + } + + @Test + public void testGmailSpecialCase() { + emailAddress = "username+something@domain.com"; + regexPattern = "^(?=.{1,64}@)[A-Za-z0-9\\+_-]+(\\.[A-Za-z0-9\\+_-]+)*@" + + "[^-][A-Za-z0-9\\+-]+(\\.[A-Za-z0-9\\+-]+)*(\\.[A-Za-z]{2,})$"; + assertTrue(EmailValidation.patternMatches(emailAddress, regexPattern)); + } +} diff --git a/core-java-modules/core-java-string-operations-3/README.md b/core-java-modules/core-java-string-operations-3/README.md index ff6ac51fab..f4cde6104f 100644 --- a/core-java-modules/core-java-string-operations-3/README.md +++ b/core-java-modules/core-java-string-operations-3/README.md @@ -5,3 +5,4 @@ - [Split Java String by Newline](https://www.baeldung.com/java-string-split-by-newline) - [Split a String in Java and Keep the Delimiters](https://www.baeldung.com/java-split-string-keep-delimiters) - [Validate String as Filename in Java](https://www.baeldung.com/java-validate-filename) +- [Count Spaces in a Java String](https://www.baeldung.com/java-string-count-spaces) diff --git a/core-java-modules/core-java-string-operations-3/pom.xml b/core-java-modules/core-java-string-operations-3/pom.xml index b73851f90c..642ade5ab3 100644 --- a/core-java-modules/core-java-string-operations-3/pom.xml +++ b/core-java-modules/core-java-string-operations-3/pom.xml @@ -16,6 +16,16 @@ + + org.springframework + spring-core + ${spring-core.version} + + + org.apache.commons + commons-lang3 + ${apache-commons-lang3.version} + org.assertj assertj-core @@ -68,10 +78,12 @@ 11 11 3.6.1 + 5.3.9 + 3.12.0 3.6.3 6.1.1 2.11.1 3.1.0 - \ No newline at end of file + diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/countspaces/CountSpacesInStringUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/countspaces/CountSpacesInStringUnitTest.java new file mode 100644 index 0000000000..0432b7dd24 --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/countspaces/CountSpacesInStringUnitTest.java @@ -0,0 +1,65 @@ +package com.baeldung.countspaces; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.Test; + +class CountSpacesInStringUnitTest { + private static final String INPUT_STRING = " This string has nine spaces and a Tab:' '"; + private static final int EXPECTED_COUNT = 9; + + @Test + void givenString_whenCountSpaceByLooping_thenReturnsExpectedCount() { + int spaceCount = 0; + for (char c : INPUT_STRING.toCharArray()) { + if (c == ' ') { + spaceCount++; + } + } + assertThat(spaceCount).isEqualTo(EXPECTED_COUNT); + } + + @Test + void givenString_whenCountSpaceByJava8StreamFilter_thenReturnsExpectedCount() { + long spaceCount = INPUT_STRING.chars().filter(c -> c == (int) ' ').count(); + assertThat(spaceCount).isEqualTo(EXPECTED_COUNT); + } + + @Test + void givenString_whenCountSpaceByRegexMatcher_thenReturnsExpectedCount() { + Pattern pattern = Pattern.compile(" "); + Matcher matcher = pattern.matcher(INPUT_STRING); + int spaceCount = 0; + while (matcher.find()) { + spaceCount++; + } + assertThat(spaceCount).isEqualTo(EXPECTED_COUNT); + } + + @Test + void givenString_whenCountSpaceByReplaceAll_thenReturnsExpectedCount() { + int spaceCount = INPUT_STRING.replaceAll("[^ ]", "").length(); + assertThat(spaceCount).isEqualTo(EXPECTED_COUNT); + } + + @Test + void givenString_whenCountSpaceBySplit_thenReturnsExpectedCount() { + int spaceCount = INPUT_STRING.split(" ").length - 1; + assertThat(spaceCount).isEqualTo(EXPECTED_COUNT); + } + + @Test + void givenString_whenCountSpaceUsingApacheCommons_thenReturnsExpectedCount() { + int spaceCount = StringUtils.countMatches(INPUT_STRING, " "); + assertThat(spaceCount).isEqualTo(EXPECTED_COUNT); + } + + @Test + void givenString_whenCountSpaceUsingSpring_thenReturnsExpectedCount() { + int spaceCount = org.springframework.util.StringUtils.countOccurrencesOf(INPUT_STRING, " "); + assertThat(spaceCount).isEqualTo(EXPECTED_COUNT); + } +} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 13dd20b5da..5291c8c3ca 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -38,6 +38,7 @@ core-java-collections-maps core-java-collections-maps-2 core-java-collections-maps-3 + core-java-collections-maps-4 core-java-concurrency-2 core-java-concurrency-advanced core-java-concurrency-advanced-2 @@ -137,4 +138,5 @@ 2.22.2 5.6.2 - \ No newline at end of file + + diff --git a/deeplearning4j/pom.xml b/deeplearning4j/pom.xml index f1f9b9fa7b..c63e67d573 100644 --- a/deeplearning4j/pom.xml +++ b/deeplearning4j/pom.xml @@ -39,12 +39,12 @@ org.slf4j slf4j-api - ${slf4j.version} + ${org.slf4j.version} org.slf4j slf4j-log4j12 - ${slf4j.version} + ${org.slf4j.version} @@ -62,7 +62,6 @@ 0.9.1 4.3.5 - 1.7.5 \ No newline at end of file diff --git a/docker/README.md b/docker/README.md index f1b4181e64..ab3ddd35b7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,6 +1,6 @@ ## Relevant Articles: -- [Introduction to Docker Compose](https://www.baeldung.com/docker-compose) +- [Introduction to Docker Compose](https://www.baeldung.com/ops/docker-compose) - [Reusing Docker Layers with Spring Boot](https://www.baeldung.com/docker-layers-spring-boot) - [Running Spring Boot with PostgreSQL in Docker Compose](https://www.baeldung.com/spring-boot-postgresql-docker) - [How To Configure Java Heap Size Inside a Docker Container](https://www.baeldung.com/ops/docker-jvm-heap-size) diff --git a/drools/src/main/resources/logback.xml b/drools/src/main/resources/logback.xml index 7d900d8ea8..b928039804 100644 --- a/drools/src/main/resources/logback.xml +++ b/drools/src/main/resources/logback.xml @@ -6,7 +6,8 @@ - + + diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 4283714b98..b9a3870702 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -99,7 +99,7 @@ org.slf4j jcl-over-slf4j - ${slf4j.version} + ${org.slf4j.version} ch.qos.logback @@ -204,8 +204,6 @@ 1.5.6.RELEASE 2.21.0 2.4.0 - 1.2.3 - 1.7.25 2.0.4.RELEASE 3.1 diff --git a/gradle/gradle-jacoco/README.md b/gradle/gradle-jacoco/README.md new file mode 100644 index 0000000000..0da51cc539 --- /dev/null +++ b/gradle/gradle-jacoco/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Exclusions from Jacoco Report](https://www.baeldung.com/jacoco-report-exclude) diff --git a/grpc/pom.xml b/grpc/pom.xml index 915777f3bd..77ec9be464 100644 --- a/grpc/pom.xml +++ b/grpc/pom.xml @@ -1,81 +1,82 @@ - 4.0.0 - grpc - 0.0.1-SNAPSHOT - grpc - jar + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + grpc + 0.0.1-SNAPSHOT + grpc + jar - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + - - - io.grpc - grpc-netty - ${io.grpc.version} - - - io.grpc - grpc-protobuf - ${io.grpc.version} - - - io.grpc - grpc-stub - ${io.grpc.version} - - - junit - junit - ${junit.version} - test - - - - - - - kr.motd.maven - os-maven-plugin - ${os-maven-plugin.version} - - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - ${protobuf-maven-plugin.version} - - - com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier} - - grpc-java - - io.grpc:protoc-gen-grpc-java:1.4.0:exe:${os.detected.classifier} - - - - - - compile - compile-custom - - - - - - - - - 1.16.1 - 1.6.1 - 0.6.1 - + + + io.grpc + grpc-netty-shaded + runtime + ${io.grpc.version} + + + io.grpc + grpc-protobuf + ${io.grpc.version} + + + io.grpc + grpc-stub + ${io.grpc.version} + + + junit + junit + ${junit.version} + test + + + javax.annotation + javax.annotation-api + 1.2 + + + + + + kr.motd.maven + os-maven-plugin + ${os-maven-plugin.version} + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + ${protobuf-maven-plugin.version} + + com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:${io.grpc.version}:exe:${os.detected.classifier} + + + + + compile + compile-custom + + + + + + + + 1.40.1 + 3.17.2 + 1.6.2 + 0.6.1 + \ No newline at end of file diff --git a/grpc/src/main/java/com/baeldung/grpc/streaming/StockClient.java b/grpc/src/main/java/com/baeldung/grpc/streaming/StockClient.java new file mode 100644 index 0000000000..1850c975a2 --- /dev/null +++ b/grpc/src/main/java/com/baeldung/grpc/streaming/StockClient.java @@ -0,0 +1,183 @@ +package com.baeldung.grpc.streaming; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.baeldung.grpc.streaming.StockQuoteProviderGrpc.StockQuoteProviderBlockingStub; +import com.baeldung.grpc.streaming.StockQuoteProviderGrpc.StockQuoteProviderStub; + +import io.grpc.Channel; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import io.grpc.stub.StreamObserver; + +public class StockClient { + private static final Logger logger = Logger.getLogger(StockClient.class.getName()); + + private final StockQuoteProviderBlockingStub blockingStub; + private final StockQuoteProviderStub nonBlockingStub; + private List stocks; + + public StockClient(Channel channel) { + + blockingStub = StockQuoteProviderGrpc.newBlockingStub(channel); + nonBlockingStub = StockQuoteProviderGrpc.newStub(channel); + initializeStocks(); + } + + public void serverSideStreamingListOfStockPrices() { + + logInfo("######START EXAMPLE######: ServerSideStreaming - list of Stock prices from a given stock"); + Stock request = Stock.newBuilder() + .setTickerSymbol("AU") + .setCompanyName("Austich") + .setDescription("server streaming example") + .build(); + Iterator stockQuotes; + try { + logInfo("REQUEST - ticker symbol {0}", request.getTickerSymbol()); + stockQuotes = blockingStub.serverSideStreamingGetListStockQuotes(request); + for (int i = 1; stockQuotes.hasNext(); i++) { + StockQuote stockQuote = stockQuotes.next(); + logInfo("RESPONSE - Price #" + i + ": {0}", stockQuote.getPrice()); + } + } catch (StatusRuntimeException e) { + logInfo("RPC failed: {0}", e.getStatus()); + } + } + + public void clientSideStreamingGetStatisticsOfStocks() throws InterruptedException { + + logInfo("######START EXAMPLE######: ClientSideStreaming - getStatisticsOfStocks from a list of stocks"); + final CountDownLatch finishLatch = new CountDownLatch(1); + StreamObserver responseObserver = new StreamObserver() { + @Override + public void onNext(StockQuote summary) { + logInfo("RESPONSE, got stock statistics - Average Price: {0}, description: {1}", summary.getPrice(), summary.getDescription()); + } + + @Override + public void onCompleted() { + logInfo("Finished clientSideStreamingGetStatisticsOfStocks"); + finishLatch.countDown(); + } + + @Override + public void onError(Throwable t) { + logWarning("Stock Statistics Failed: {0}", Status.fromThrowable(t)); + finishLatch.countDown(); + } + }; + + StreamObserver requestObserver = nonBlockingStub.clientSideStreamingGetStatisticsOfStocks(responseObserver); + try { + + for (Stock stock : stocks) { + logInfo("REQUEST: {0}, {1}", stock.getTickerSymbol(), stock.getCompanyName()); + requestObserver.onNext(stock); + if (finishLatch.getCount() == 0) { + return; + } + } + } catch (RuntimeException e) { + requestObserver.onError(e); + throw e; + } + requestObserver.onCompleted(); + if (!finishLatch.await(1, TimeUnit.MINUTES)) { + logWarning("clientSideStreamingGetStatisticsOfStocks can not finish within 1 minutes"); + } + } + + public void bidirectionalStreamingGetListsStockQuotes() throws InterruptedException{ + + logInfo("#######START EXAMPLE#######: BidirectionalStreaming - getListsStockQuotes from list of stocks"); + final CountDownLatch finishLatch = new CountDownLatch(1); + StreamObserver responseObserver = new StreamObserver() { + @Override + public void onNext(StockQuote stockQuote) { + logInfo("RESPONSE price#{0} : {1}, description:{2}", stockQuote.getOfferNumber(), stockQuote.getPrice(), stockQuote.getDescription()); + } + + @Override + public void onCompleted() { + logInfo("Finished bidirectionalStreamingGetListsStockQuotes"); + finishLatch.countDown(); + } + + @Override + public void onError(Throwable t) { + logWarning("bidirectionalStreamingGetListsStockQuotes Failed: {0}", Status.fromThrowable(t)); + finishLatch.countDown(); + } + }; + StreamObserver requestObserver = nonBlockingStub.bidirectionalStreamingGetListsStockQuotes(responseObserver); + try { + for (Stock stock : stocks) { + logInfo("REQUEST: {0}, {1}", stock.getTickerSymbol(), stock.getCompanyName()); + requestObserver.onNext(stock); + Thread.sleep(200); + if (finishLatch.getCount() == 0) { + return; + } + } + } catch (RuntimeException e) { + requestObserver.onError(e); + throw e; + } + requestObserver.onCompleted(); + + if (!finishLatch.await(1, TimeUnit.MINUTES)) { + logWarning("bidirectionalStreamingGetListsStockQuotes can not finish within 1 minute"); + } + + } + + public static void main(String[] args) throws InterruptedException { + String target = "localhost:8980"; + if (args.length > 0) { + target = args[0]; + } + + ManagedChannel channel = ManagedChannelBuilder.forTarget(target) + .usePlaintext() + .build(); + try { + StockClient client = new StockClient(channel); + + client.serverSideStreamingListOfStockPrices(); + + client.clientSideStreamingGetStatisticsOfStocks(); + + client.bidirectionalStreamingGetListsStockQuotes(); + + } finally { + channel.shutdownNow() + .awaitTermination(5, TimeUnit.SECONDS); + } + } + + private void initializeStocks() { + + this.stocks = Arrays.asList(Stock.newBuilder().setTickerSymbol("AU").setCompanyName("Auburn Corp").setDescription("Aptitude Intel").build() + , Stock.newBuilder().setTickerSymbol("BAS").setCompanyName("Bassel Corp").setDescription("Business Intel").build() + , Stock.newBuilder().setTickerSymbol("COR").setCompanyName("Corvine Corp").setDescription("Corporate Intel").build() + , Stock.newBuilder().setTickerSymbol("DIA").setCompanyName("Dialogic Corp").setDescription("Development Intel").build() + , Stock.newBuilder().setTickerSymbol("EUS").setCompanyName("Euskaltel Corp").setDescription("English Intel").build()); + } + + private void logInfo(String msg, Object... params) { + logger.log(Level.INFO, msg, params); + } + + private void logWarning(String msg, Object... params) { + logger.log(Level.WARNING, msg, params); + } +} diff --git a/grpc/src/main/java/com/baeldung/grpc/streaming/StockServer.java b/grpc/src/main/java/com/baeldung/grpc/streaming/StockServer.java new file mode 100644 index 0000000000..f4dc6c39ac --- /dev/null +++ b/grpc/src/main/java/com/baeldung/grpc/streaming/StockServer.java @@ -0,0 +1,147 @@ +package com.baeldung.grpc.streaming; + +import java.io.IOException; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + +import io.grpc.Server; +import io.grpc.ServerBuilder; +import io.grpc.stub.StreamObserver; + +public class StockServer { + + private static final Logger logger = Logger.getLogger(StockServer.class.getName()); + private final int port; + private final Server server; + + public StockServer(int port) throws IOException { + this.port = port; + server = ServerBuilder.forPort(port) + .addService(new StockService()) + .build(); + } + + public void start() throws IOException { + server.start(); + logger.info("Server started, listening on " + port); + Runtime.getRuntime() + .addShutdownHook(new Thread() { + @Override + public void run() { + System.err.println("shutting down server"); + try { + StockServer.this.stop(); + } catch (InterruptedException e) { + e.printStackTrace(System.err); + } + System.err.println("server shutted down"); + } + }); + } + + public void stop() throws InterruptedException { + if (server != null) { + server.shutdown() + .awaitTermination(30, TimeUnit.SECONDS); + } + } + + public static void main(String[] args) throws Exception { + StockServer stockServer = new StockServer(8980); + stockServer.start(); + if (stockServer.server != null) { + stockServer.server.awaitTermination(); + } + } + + private static class StockService extends StockQuoteProviderGrpc.StockQuoteProviderImplBase { + + StockService() { + } + + @Override + public void serverSideStreamingGetListStockQuotes(Stock request, StreamObserver responseObserver) { + + for (int i = 1; i <= 5; i++) { + + StockQuote stockQuote = StockQuote.newBuilder() + .setPrice(fetchStockPriceBid(request)) + .setOfferNumber(i) + .setDescription("Price for stock:" + request.getTickerSymbol()) + .build(); + responseObserver.onNext(stockQuote); + } + responseObserver.onCompleted(); + } + + @Override + public StreamObserver clientSideStreamingGetStatisticsOfStocks(final StreamObserver responseObserver) { + return new StreamObserver() { + int count; + double price = 0.0; + StringBuffer sb = new StringBuffer(); + + @Override + public void onNext(Stock stock) { + count++; + price = +fetchStockPriceBid(stock); + sb.append(":") + .append(stock.getTickerSymbol()); + } + + @Override + public void onCompleted() { + responseObserver.onNext(StockQuote.newBuilder() + .setPrice(price / count) + .setDescription("Statistics-" + sb.toString()) + .build()); + responseObserver.onCompleted(); + } + + @Override + public void onError(Throwable t) { + logger.log(Level.WARNING, "error:{0}", t.getMessage()); + } + }; + } + + @Override + public StreamObserver bidirectionalStreamingGetListsStockQuotes(final StreamObserver responseObserver) { + return new StreamObserver() { + @Override + public void onNext(Stock request) { + + for (int i = 1; i <= 5; i++) { + + StockQuote stockQuote = StockQuote.newBuilder() + .setPrice(fetchStockPriceBid(request)) + .setOfferNumber(i) + .setDescription("Price for stock:" + request.getTickerSymbol()) + .build(); + responseObserver.onNext(stockQuote); + } + } + + @Override + public void onCompleted() { + responseObserver.onCompleted(); + } + + @Override + public void onError(Throwable t) { + logger.log(Level.WARNING, "error:{0}", t.getMessage()); + } + }; + } + } + + private static double fetchStockPriceBid(Stock stock) { + + return stock.getTickerSymbol() + .length() + + ThreadLocalRandom.current() + .nextDouble(-0.1d, 0.1d); + } +} \ No newline at end of file diff --git a/grpc/src/main/proto/stock_quote.proto b/grpc/src/main/proto/stock_quote.proto new file mode 100644 index 0000000000..66891a5008 --- /dev/null +++ b/grpc/src/main/proto/stock_quote.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package stockquote; + +option java_multiple_files = true; +option java_package = "com.baeldung.grpc.streaming"; +option java_outer_classname = "StockQuoteProto"; +option objc_class_prefix = "RTG"; + +//basic setup ... + +service StockQuoteProvider { + + rpc serverSideStreamingGetListStockQuotes(Stock) returns (stream StockQuote) {} + + rpc clientSideStreamingGetStatisticsOfStocks(stream Stock) returns (StockQuote) {} + + rpc bidirectionalStreamingGetListsStockQuotes(stream Stock) returns (stream StockQuote) {} +} + +message Stock { + string ticker_symbol = 1; + string company_name = 2; + string description = 3; +} + +message StockQuote { + double price = 1; + int32 offer_number = 2; + string description = 3; +} diff --git a/jackson-modules/jackson-conversions-2/pom.xml b/jackson-modules/jackson-conversions-2/pom.xml index 799fcb106a..a498c8b4f8 100644 --- a/jackson-modules/jackson-conversions-2/pom.xml +++ b/jackson-modules/jackson-conversions-2/pom.xml @@ -24,7 +24,7 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - ${jackson-datatype.version} + ${jackson.version} @@ -52,7 +52,6 @@ 3.11.0 - 2.9.8 \ No newline at end of file diff --git a/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/SubTypeHandlingUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/SubTypeHandlingUnitTest.java index b5b81fa4a3..8d6bc9ad6a 100644 --- a/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/SubTypeHandlingUnitTest.java +++ b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/SubTypeHandlingUnitTest.java @@ -1,14 +1,22 @@ package com.baeldung.jackson.inheritance; +import static org.hamcrest.CoreMatchers.instanceOf; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.junit.Test; -import java.util.List; -import java.util.ArrayList; -import java.io.IOException; - +import com.baeldung.jackson.inheritance.SubTypeConstructorStructure.Car; +import com.baeldung.jackson.inheritance.SubTypeConstructorStructure.Fleet; +import com.baeldung.jackson.inheritance.SubTypeConstructorStructure.Truck; +import com.baeldung.jackson.inheritance.SubTypeConstructorStructure.Vehicle; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator; +import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; public class SubTypeHandlingUnitTest { @Test @@ -23,21 +31,30 @@ public class SubTypeHandlingUnitTest { } @Test - public void givenSubType_whenNotUsingNoArgsConstructors_thenSucceed() throws IOException { + public void givenSubType_whenNotUsingNoArgsConstructors_thenSucceed() throws IOException { ObjectMapper mapper = new ObjectMapper(); - mapper.enableDefaultTyping(); + PolymorphicTypeValidator ptv = BasicPolymorphicTypeValidator.builder() + .allowIfSubType("com.baeldung.jackson.inheritance") + .allowIfSubType("java.util.ArrayList") + .build(); + mapper.activateDefaultTyping(ptv, ObjectMapper.DefaultTyping.NON_FINAL); + + Car car = new Car("Mercedes-Benz", "S500", 5, 250.0); + Truck truck = new Truck("Isuzu", "NQR", 7500.0); - SubTypeConstructorStructure.Car car = new SubTypeConstructorStructure.Car("Mercedes-Benz", "S500", 5, 250.0); - SubTypeConstructorStructure.Truck truck = new SubTypeConstructorStructure.Truck("Isuzu", "NQR", 7500.0); - - List vehicles = new ArrayList<>(); + List vehicles = new ArrayList<>(); vehicles.add(car); vehicles.add(truck); - SubTypeConstructorStructure.Fleet serializedFleet = new SubTypeConstructorStructure.Fleet(); + Fleet serializedFleet = new Fleet(); serializedFleet.setVehicles(vehicles); String jsonDataString = mapper.writeValueAsString(serializedFleet); - mapper.readValue(jsonDataString, SubTypeConstructorStructure.Fleet.class); + mapper.readValue(jsonDataString, Fleet.class); + + Fleet deserializedFleet = mapper.readValue(jsonDataString, Fleet.class); + + assertThat(deserializedFleet.getVehicles().get(0), instanceOf(Car.class)); + assertThat(deserializedFleet.getVehicles().get(1), instanceOf(Truck.class)); } } \ No newline at end of file diff --git a/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/TypeInfoInclusionUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/TypeInfoInclusionUnitTest.java index 02297b9ee8..ca057edadc 100644 --- a/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/TypeInfoInclusionUnitTest.java +++ b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/TypeInfoInclusionUnitTest.java @@ -10,12 +10,18 @@ import java.util.ArrayList; import java.io.IOException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator; +import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; public class TypeInfoInclusionUnitTest { @Test public void givenTypeInfo_whenAnnotatingGlobally_thenTypesAreCorrectlyRecovered() throws IOException { ObjectMapper mapper = new ObjectMapper(); - mapper.enableDefaultTyping(); + PolymorphicTypeValidator ptv = BasicPolymorphicTypeValidator.builder() + .allowIfSubType("com.baeldung.jackson.inheritance") + .allowIfSubType("java.util.ArrayList") + .build(); + mapper.activateDefaultTyping(ptv, ObjectMapper.DefaultTyping.NON_FINAL); TypeInfoStructure.Car car = new TypeInfoStructure.Car("Mercedes-Benz", "S500", 5, 250.0); TypeInfoStructure.Truck truck = new TypeInfoStructure.Truck("Isuzu", "NQR", 7500.0); diff --git a/java-lite/pom.xml b/java-lite/pom.xml index c422e9a421..092063a110 100644 --- a/java-lite/pom.xml +++ b/java-lite/pom.xml @@ -21,13 +21,11 @@ activeweb ${activeweb.version} - mysql mysql-connector-java ${mysql.connector.java.version} - com.sun tools @@ -35,14 +33,12 @@ system ${java.home}/../lib/tools.jar - org.javalite activeweb-testing ${activeweb-testing.version} test - @@ -73,7 +69,6 @@ - org.javalite activejdbc-instrumentation diff --git a/javafx/README.md b/javafx/README.md index 80c4f49026..8ef06eb012 100644 --- a/javafx/README.md +++ b/javafx/README.md @@ -3,5 +3,6 @@ This module contains articles about JavaFX. ### Relevant Articles: --[Introduction to JavaFX](https://www.baeldung.com/javafx) +- [Introduction to JavaFX](https://www.baeldung.com/javafx) +- [Display Custom Items in JavaFX ListView](https://www.baeldung.com/javafx-listview-display-custom-items) diff --git a/javafx/src/main/java/com/baeldung/listview/ExampleController.java b/javafx/src/main/java/com/baeldung/listview/ExampleController.java new file mode 100644 index 0000000000..c02fa68d2e --- /dev/null +++ b/javafx/src/main/java/com/baeldung/listview/ExampleController.java @@ -0,0 +1,38 @@ +package com.baeldung.listview; + +import com.baeldung.listview.cellfactory.CheckboxCellFactory; +import com.baeldung.listview.cellfactory.PersonCellFactory; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.ListView; + +import java.net.URL; +import java.util.ResourceBundle; + +public class ExampleController implements Initializable { + @FXML + private ListView listView; + + @Override + public void initialize(URL location, ResourceBundle resources) { + ObservableList wordsList = FXCollections.observableArrayList(); + wordsList.add(new Person("Isaac", "Newton")); + wordsList.add(new Person("Albert", "Einstein")); + wordsList.add(new Person("Ludwig", "Boltzmann")); + listView.setItems(wordsList); + } + + public void defaultButtonClick() { + listView.setCellFactory(null); + } + + public void cellFactoryButtonClick() { + listView.setCellFactory(new PersonCellFactory()); + } + + public void checkboxCellFactoryButtonClick() { + listView.setCellFactory(new CheckboxCellFactory()); + } +} diff --git a/javafx/src/main/java/com/baeldung/listview/Main.java b/javafx/src/main/java/com/baeldung/listview/Main.java new file mode 100644 index 0000000000..a067971758 --- /dev/null +++ b/javafx/src/main/java/com/baeldung/listview/Main.java @@ -0,0 +1,28 @@ +package com.baeldung.javafx.listview; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.net.URL; + +public class Main extends Application { + + public static void main(String args[]) { + launch(args); + } + + @Override + public void start(Stage primaryStage) throws Exception { + FXMLLoader loader = new FXMLLoader(); + URL xmlUrl = getClass().getResource("/example.fxml"); + loader.setLocation(xmlUrl); + Parent root = loader.load(); + + primaryStage.setTitle("List View Demo"); + primaryStage.setScene(new Scene(root)); + primaryStage.show(); + } +} diff --git a/javafx/src/main/java/com/baeldung/listview/Person.java b/javafx/src/main/java/com/baeldung/listview/Person.java new file mode 100644 index 0000000000..cdc0ab2dc8 --- /dev/null +++ b/javafx/src/main/java/com/baeldung/listview/Person.java @@ -0,0 +1,25 @@ +package com.baeldung.listview; + +public class Person { + + private final String firstName; + private final String lastName; + + public Person(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + @Override + public String toString() { + return firstName + " " + lastName; + } +} diff --git a/javafx/src/main/java/com/baeldung/listview/cellfactory/CheckboxCellFactory.java b/javafx/src/main/java/com/baeldung/listview/cellfactory/CheckboxCellFactory.java new file mode 100644 index 0000000000..522afcb76e --- /dev/null +++ b/javafx/src/main/java/com/baeldung/listview/cellfactory/CheckboxCellFactory.java @@ -0,0 +1,29 @@ +package com.baeldung.listview.cellfactory; + +import com.baeldung.listview.Person; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.util.Callback; + +public class CheckboxCellFactory implements Callback, ListCell> { + @Override + public ListCell call(ListView param) { + return new ListCell(){ + @Override + public void updateItem(Person person, boolean empty) { + super.updateItem(person, empty); + if (empty) { + setText(null); + setGraphic(null); + } else if (person != null) { + setText(null); + setGraphic(new CheckBox(person.getFirstName() + " " + person.getLastName())); + } else { + setText("null"); + setGraphic(null); + } + } + }; + } +} diff --git a/javafx/src/main/java/com/baeldung/listview/cellfactory/PersonCellFactory.java b/javafx/src/main/java/com/baeldung/listview/cellfactory/PersonCellFactory.java new file mode 100644 index 0000000000..57866b9ead --- /dev/null +++ b/javafx/src/main/java/com/baeldung/listview/cellfactory/PersonCellFactory.java @@ -0,0 +1,23 @@ +package com.baeldung.listview.cellfactory; + +import com.baeldung.listview.Person; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.util.Callback; + +public class PersonCellFactory implements Callback, ListCell> { + @Override + public ListCell call(ListView param) { + return new ListCell(){ + @Override + public void updateItem(Person person, boolean empty) { + super.updateItem(person, empty); + if (empty || person == null) { + setText(null); + } else { + setText(person.getFirstName() + " " + person.getLastName()); + } + } + }; + } +} diff --git a/javafx/src/main/resources/example.fxml b/javafx/src/main/resources/example.fxml new file mode 100644 index 0000000000..c68df076d0 --- /dev/null +++ b/javafx/src/main/resources/example.fxml @@ -0,0 +1,14 @@ + + + + + + + + + +