Archives de l’auteur : davidhxxx

Comparator : how to implement it

Plan Model to illustrate Way to never use  Way acceptable only for Java 6 and below Favor methods of built-in basic type Comparable implementations in Java 7 Favor Comparator construction methods in Java 8 This post is inspired by the … Continuer la lecture

Publié dans java, java 8 | Laisser un commentaire

Defining a custom Collector in Java 8

Plan Reasons to write its own collector The requirement to illustrate : a collect that cannot be done straightly with built-in Stream/Collector methods Implementing it with built-in collectors but without extracted functions is terrible Implementing it with built-in collectors and … Continuer la lecture

Publié dans Non classé | 3 commentaires

The builder pattern (not the builder design pattern) in Java

Plan Builder pattern, builder design pattern, fluent API. Are these the same thing ? When do we want to consider the builder pattern? A simple builder The same builder with consistency checks Builder with inheritance Disclaimer : Sure that we … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Java 8 collecting inside a FlatMap : some limitations

Stream.map() and Stream.flatMap() methods are very close methods as discussed here. Here we will discuss about Stream.flatMap() limitations . We can broadly identify two usages of Stream.flatMap(): – flattening a nested stream within the initial stream to perform the main collect operation on … Continuer la lecture

Publié dans java, java 8, java 9, Non classé | Laisser un commentaire

Java 8 flatMap or how to « flat mapped » a stream to another stream

Stream.map() and Stream.flatMap() methods are very close methods. These map a stream to another one by applying the function passed as argument for each element of the initial stream. But these are not applied in the same context. map() expects any … Continuer la lecture

Publié dans flatmap, java, java8, lambda | Laisser un commentaire

From Java to Scala : some examples

Here is little article discussing about how to turn a Java code into a Scala code. Java code : import java.util.List;   public class Bob {   private final List<String> preferedMatters; private final List<String> neutralMatters; private final List<String> hatedMatters;   … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Install Minishift on Windows 10 with Hyper-V

1) Setting Up the Hyper-V Driver – Install Hyper-V in Windows 10. See Windows instructions. – Add the user to the local Hyper-V Administrators group. PS command : ([adsi] »WinNT://./Administrateurs Hyper-V,group »).Add(« WinNT://$env:UserDomain/$env:Username,user ») – Add an External Virtual Switch. Identify first the net … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Redis

redis-cli Debian based installation sudo apt-get install redis-tools Helpful flags –help : the help -p PORT : specify the port (default: 6379) -h HOST : specify the host (default: 127.0.0.1) redis and Docker Run Redis with Docker : $ docker … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Spring Boot – passing application arguments and JVM arguments with Maven

Passing application and JVM arguments to a Spring Boot application is not always an obvious thing. For example, as you run from the source code (Maven or Gradle), you have to use a specific way .  And as you run the application from … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Docker basic commands

Start containers Start the Jenkins container by specifying the port (outside:inside) and the volume associated : docker run -p 8080:8080 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts Run a container by specifying the in:out port, the volume src:dest, the working directory on the container … Continuer la lecture

Publié dans Non classé | Laisser un commentaire