Skip to content

A simple Java code generator, that takes YAML as an input to generate data classes.

License

Notifications You must be signed in to change notification settings

bertilmuth/javadataclass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Javadataclass

Build Status Gitter

A simple Java source file generator, that takes a YAML file as an input. You find a description in this article. Additionally, have a look at the Main class to see how to use this library.

Getting started

Javadataclass is available on Maven Central.

If you are using Maven, include the following in your POM, to use the core:

<dependency>
	<groupId>org.requirementsascode</groupId>
	<artifactId>javadataclass</artifactId>
	<version>0.1</version>
</dependency>

If you are using Gradle, include the following in your build.gradle, to use the core:

implementation 'org.requirementsascode:javadataclass:0.1'

At least Java 8 is required to use the library.

Example output

Here's the content of an example YAML file:

User:
    name: Name
    age: Integer
    
Name:
    firstName: String
    lastName: String

From this file, 2 Java source files will be generated, User.java and Name.java.

For the sake of simplicity, the Java source files will be generated in the same directory as the YAML file.

The contents of these two files are:

User.java:

public class User{
	private Name name;
	private Integer age;

	public User(){
	}
	
	public Name getName(){
		return name;
	}
	public void setName(Name name){
		this.name = name;
	}
	public Integer getAge(){
		return age;
	}
	public void setAge(Integer age){
		this.age = age;
	}
}

Name.java:

public class Name{
	private String firstName;
	private String lastName;

	public Name(){
	}
	
	public String getFirstName(){
		return firstName;
	}
	public void setFirstName(String firstName){
		this.firstName = firstName;
	}
	public String getLastName(){
		return lastName;
	}
	public void setLastName(String lastName){
		this.lastName = lastName;
	}
}

About

A simple Java code generator, that takes YAML as an input to generate data classes.

Topics

Resources

License

Stars

Watchers

Forks