Friday, 4 October 2019

How to change intellij idea theme to white

How to IntelliJ change background color to white

Steps are:-
1  go to File Menu
2  Select on Settings as shown in the image
3  then Search for Appearance and then
4 Use the Scheme list to select a color scheme.


Wednesday, 2 October 2019

Java 8 predicate test method example

for this
https://stackoverflow.com/questions/1128723/how-do-i-determine-whether-an-array-contains-a-particular-value-in-java/1128728#1128728                 

I have a String[] with values like so:
public static final String[] VALUES = new String[] {"AB","BC","CD","AE"};
Given String s, is there a good way of testing whether VALUES contains s?
ANS:
Java 8 predicate test method is best for it.
test(T t) : Evaluates this predicate on the given argument.boolean test(T t)
test(T t) Parameters: t - the input argument Returns: true if the input argument matches the predicate, otherwise false
Here is a full example of it.

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class Test {

public static final List<String> VALUES = Arrays.asList("AA", "AB", "BC", "CD", "AE");

public static void main(String args[]) {

Predicate<String> containsLetterA = VALUES -> VALUES.contains("AB");
for (String i : VALUES) {
System.out.println(containsLetterA.test(i));
}
}

}


Wednesday, 4 September 2019

docker commands

Here is a list of docker commands.

Child commands
CommandDescription
docker attachAttach local standard input, output, and error streams to a running container
docker buildBuild an image from a Dockerfile
docker builderManage builds
docker checkpointManage checkpoints
docker commitCreate a new image from a container’s changes
docker configManage Docker configs
docker containerManage containers
docker contextManage contexts
docker cpCopy files/folders between a container and the local filesystem
docker createCreate a new container
docker deployDeploy a new stack or update an existing stack
docker diffInspect changes to files or directories on a container’s filesystem
docker engineManage the docker engine
docker eventsGet real time events from the server
docker execRun a command in a running container
docker exportExport a container’s filesystem as a tar archive
docker historyShow the history of an image
docker imageManage images
docker imagesList images
docker importImport the contents from a tarball to create a filesystem image
docker infoDisplay system-wide information
docker inspectReturn low-level information on Docker objects
docker killKill one or more running containers
docker loadLoad an image from a tar archive or STDIN
docker loginLog in to a Docker registry
docker logoutLog out from a Docker registry
docker logsFetch the logs of a container
docker manifestManage Docker image manifests and manifest lists
docker networkManage networks
docker nodeManage Swarm nodes
docker pausePause all processes within one or more containers
docker pluginManage plugins
docker portList port mappings or a specific mapping for the container
docker psList containers
docker pullPull an image or a repository from a registry
docker pushPush an image or a repository to a registry
docker renameRename a container
docker restartRestart one or more containers
docker rmRemove one or more containers
docker rmiRemove one or more images
docker runRun a command in a new container
docker saveSave one or more images to a tar archive (streamed to STDOUT by default)
docker searchSearch the Docker Hub for images
docker secretManage Docker secrets
docker serviceManage services
docker stackManage Docker stacks
docker startStart one or more stopped containers
docker statsDisplay a live stream of container(s) resource usage statistics
docker stopStop one or more running containers
docker swarmManage Swarm
docker systemManage Docker
docker tagCreate a tag TARGET_IMAGE that refers to SOURCE_IMAGE
docker topDisplay the running processes of a container
docker trustManage trust on Docker images
docker unpauseUnpause all processes within one or more containers
docker updateUpdate configuration of one or more containers
docker versionShow the Docker version information
docker volumeManage volumes
docker waitBlock until one or more containers stop, then print their exit codes

Sunday, 26 August 2018

return list of json spring boot rest controller

Let Say we have list of CarDetails Pojo and we want to return them back
@RestController
public class CarDetailController {
  @GetMapping("/viewAllCarDetailList")
    public List<CarDetail> retrieveAllCarDetails() {
        List<CarDetail> contacts = new ArrayList<CarDetail>();

        CarDetail objt = new CarDetail();
        objt.setCarModel("hyundai");
        objt.setSubModel("I10");
        CarDetail objt2 = new CarDetail();
        objt2.setCarModel("hyundai");
        objt2.setSubModel("I20");        
        contacts.add(objt);
        contacts.add(objt2);
        return contacts;
    }
}
    public class CarDetails {

            private String carModel;
            private String subModel;
// Will haave Setter getter and hash code equls method
//and constructor
    }
This JSON will be output:-
[
    {
        "carModel": "hyundai",
        "subModel": "I10"
    },
    {
        "carModel": "hyundai",
        "subModel": "I20"
    }
]

output in Postman

https://stackoverflow.com/questions/41719142/how-to-return-a-set-of-objects-with-spring-boot