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

org.vertexium.cypher.utils.MapUtils Maven / Gradle / Ivy

There is a newer version: 4.10.0
Show newest version
package org.vertexium.cypher.utils;

import org.vertexium.VertexiumException;
import org.vertexium.cypher.ast.model.CypherMapLiteral;

import java.util.Map;

public class MapUtils {
    public static Object getByExpression(Map map, String property) {
        String[] path = property.split("\\.");
        Object value = null;
        for (String key : path) {
            if (map == null) {
                throw new VertexiumException("cannot get nested item from map: " + property);
            }
            value = map.get(key);
            if (value instanceof CypherMapLiteral) {
                map = ((CypherMapLiteral) value).toMap();
            } else if (value instanceof Map) {
                map = (Map) value;
            } else {
                map = null;
            }
        }
        return value;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy