Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create java pojo

I want to read a properties file and create a pojo from it. where the property key is the instance variable with getters and setters. and property value is the data type of the instance variable. input would be something like this

className=Temp
packageName=com.temp
name=java.lang.String

output would be

package com.temp;
import java.lang.String;
class Temp{
  private String name

  //getters and setters
}

what is the easiest way to do this. Should I create a file and write to it .or is there a better way.

like image 341
user373201 Avatar asked Dec 04 '25 10:12

user373201


1 Answers

I once generated Java file using Apache Velocity , you may want to take a look into it.

In short you template a file then use it to generate what you want.

like image 107
Michael Laffargue Avatar answered Dec 05 '25 22:12

Michael Laffargue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!