Skip to content
Supports to interact with properties file
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Build Status Dependency Status Coverage Status Maven Central Javadocs


This project support for interact with properties file

Code Example

1. Get all classes're mapped to keys in properties file

	try {
		Map<Object, Class<?>> classes = new ClassFetcher.Builder()
			.reader(new BaseFileReader()) //or Base64FileReader
	} catch (PropertiesFileException e) {

2. Get class mapped to key in properites file

	try {
		Class<User> = new ClassFetcher.Builder()
			.reader(new BaseFileReader()) //or Base64FileReader
			.fetch("key name");
	} catch (PropertiesFileException e) {

3. Create a factory and use this factory for creating a new instance

Let's say you have a properties file that save pairs of interface and implementation class, example:


and you want to create an instance of interface, you can do: Step 1: Init a factory, example:

	InstanceFactory.defaultInstance().initialize("array of properties files");

Step 2: Use the factory to create interface's instance from implementation class, example:

	IClassA instance = InstanceFactory.defaultInstance().getPrototype(IClassA.class);

Step 3: (Optional) If you want to create singleton instance of interface, you can do, example:

	IClassA instance = InstanceFactory.defaultInstance().getSingleton(IClassA.class);

4. Map properties file to object

Let's say you have a properties file "":

capacity = 1000 id = 1001 maxRoomVariablesAllowed = 30 maxSpectators = 50

and you want to map it to RoomConfig object, you can do:

	RoomConfig room = new PropertiesMapper()
		.reader(new BaseFileReader())

and if you encode properties file with base64 you can do:

	RoomConfig room = new PropertiesMapper()
		.reader(new Base64FileReader())

4. Convert an object to a map

Sometimes you want to convert an object to a map, you can do:

	PropertiesBean map = new PropertiesBean(ClassA.class);


	PropertiesBean map = new PropertiesBean(new ClassA());

5. Use annotation to map properties file to object or convert an object to a map

Sometimes you have properties files with list of key and value, but key name is not same with field name, to map them, you can do:

public class RoomConfig {
    @Setter @Getter
    protected int variablesCount;
    @Setter @Getter
    protected boolean isPublic;
    // your code


Because sometimes we want to make loose coupling source code, we want to use factory design pattern, we want to map a properties file to object, convert an object to map, so I make this project for that mean



API Reference


mvn test




  • Apache License, Version 2.0
You can’t perform that action at this time.