class DomainJsonPathHelper {

    public static PresentationPath getPresentationPath(ClientDomain domain, String propertyPath){
        final Matcher matcher = ROOT_PRESENTATION_ELEMENT_PATTERN.matcher(propertyPath);
        if(!matcher.find()){
            throw new IllegalArgumentException("JSON Path " + propertyPath +
                    " should start from schema.presentation[{dataIslandIndex}]. Where {dataIslandIndex} is a number");
        }
        final List<PresentationGroupElement> presentation = domain.getSchema() != null && domain.getSchema().getPresentation() != null ?
                domain.getSchema().getPresentation() : new ArrayList<PresentationGroupElement>();
        Integer dataIslandIndex = Integer.valueOf(matcher.group(1));
        final PresentationGroupElement dataIsland = presentation.get(dataIslandIndex);
        return new PresentationPath(dataIsland.getName(), getElementsPath((List) dataIsland.getElements(), propertyPath));
    }

}