Archives de catégorie : Non classé

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

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

JMX command line

jmxterm tool (command line tool) Run the command line program : java -jar jmxterm-1.0.0-uber.jar Useful args : -l  host:port to specify a remote jmx connection -u foo -p pass  to specify the jmx user/password Commands :  Open a JMX session : open … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Design Pattern : visitor implementation in Java

The source code of design patterns can be viewed and downloaded here : https://github.com/ebundy/java-examples/tree/master/design-patternsWhat is it ?The visitor design pattern is a behavioral pattern.The pattern splits the model data and its operations in distinct structures.When using it ?Multiple reasons :1) … Continuer la lecture

Publié dans Non classé | Laisser un commentaire