Changing default configurations common to both YamlWriter and YamlReader

In this post under YamlBeans, I will explain with example how to change default configurations common to both YamlWriter and YamlReader. The YamlConfig class has getter and setters that can be used to change default configurations. For this example, we will use the below Employee1 class structure. Employee1 class import java.util.List; public class Employee1 {…… Continue reading Changing default configurations common to both YamlWriter and YamlReader

Advertisements

ExclusionStrategy example during deserialization of object

In this post under Gson, I will explain how we can exclude certain fields of a json data from being deserialized with an example. Below is the Employee class structure that will be used to create an instance and its field are set with the values obtained from Employee.json file. Employee class public class Employee…… Continue reading ExclusionStrategy example during deserialization of object

Listening to Skip events using SkipListener

In this post under Spring Batch, I will explain with an example of how to listen to skip events. The skip events are generated during reading, writing, and processing of records. We can listen to these skip events with the help of org.springframework.batch.core.SkipListener interface. The SkipListener interface has three methods 1) onSkipInProcess purpose –> provide…… Continue reading Listening to Skip events using SkipListener

ExclusionStrategy example during serialization of object

In this post under Gson, I will explain how we can exclude certain fields of a class from being serialized with an example. Below is the Employee class structure that we want to serialize Employee public class Employee { private int id; private String name; private int ssn; private boolean terminated; public int getId() {…… Continue reading ExclusionStrategy example during serialization of object

Deserializing YAML data to Java object

In this post under YamlBeans, I will show with an example of how to deserialize a YAML data to Java object. Main Code 1 import java.io.File; 2 import java.io.FileReader; 3 import java.io.IOException; 4 5 import com.esotericsoftware.yamlbeans.YamlReader; 6 7 public class YamlDemo2 { 8 public static void main(String[] args) { 9 File file = new File(“input1.yml”);…… Continue reading Deserializing YAML data to Java object

Skipping records during record reading, processing or writing

While reading a record from a file, processing already read record, or writing a record to a file, exceptions happens. They are two ways to handle the exceptions 1) skip it and continue with the next record. 2) Stop the processing of entire file. Sometimes the exceptions are not so serious and we can skip…… Continue reading Skipping records during record reading, processing or writing

JCache EternalExpiryPolicy Example

This post explains EternalExpiryPolicy with simple example. EternalExpiryPolicy is an expiry policy used to inform cache to never remove entries in the cache. Below is an example of how to use it. Main Code 1 import java.util.Iterator; 2 3 import javax.cache.Cache; 4 import javax.cache.Cache.Entry; 5 import javax.cache.CacheManager; 6 import javax.cache.Caching; 7 import javax.cache.configuration.Factory; 8 import…… Continue reading JCache EternalExpiryPolicy Example

Serializing Java object to YAML format

In this post under YamlBeans, I will show with an example of how to serialize a Java object to YAML format. Below is the complete code Main Code 1 import java.io.File; 2 import java.io.FileWriter; 3 import java.io.IOException; 4 import java.util.ArrayList; 5 import java.util.List; 6 7 import com.esotericsoftware.yamlbeans.YamlWriter; 8 9 public class YamlDemo1 { 10 public…… Continue reading Serializing Java object to YAML format

Annotation Since and setVersion method

In this post under Gson, I will explain with an example how to use @Since annotation. The @Since annotation is used in combination with “GsonBuilder.setVersion” method. The annotation has no effect if it is not used along with “GsonBuilder.setVersion” method. The @Since annotation is used for the fields of the class and it accepts a…… Continue reading Annotation Since and setVersion method