All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.jalokim.propertiestojson.path.PathMetadataBuilder Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
package pl.jalokim.propertiestojson.path;

import static pl.jalokim.propertiestojson.Constants.REGEX_DOT;

public class PathMetadataBuilder {

    public static PathMetadata createRootPathMetaData(String propertyKey) {
        String[] fields = propertyKey.split(REGEX_DOT);
        PathMetadata currentPathMetadata = null;

        for(int index = 0; index < fields.length; index++) {
            String field = fields[index];

            PathMetadata nextPathMetadata = new PathMetadata(propertyKey);
            nextPathMetadata.setParent(currentPathMetadata);
            nextPathMetadata.setFieldName(field);
            nextPathMetadata.setOriginalFieldName(field);

            if (currentPathMetadata != null) {
                currentPathMetadata.setChild(nextPathMetadata);
            }
            currentPathMetadata = nextPathMetadata;

        }
        return currentPathMetadata.getRoot();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy