Java SortedMap Usage generatePropertiesFilter(SortedMap propertiesMap)

Here you can find the source of generatePropertiesFilter(SortedMap propertiesMap)

Description

Generate a Filter as a String given a Map of property/value pairs.

License

Open Source License

Parameter

Parameter Description
propertiesMap Map of properties

Return

Filter as a String

Declaration

public static String generatePropertiesFilter(SortedMap<String, String> propertiesMap) 

Method Source Code

//package com.java2s;

import java.util.SortedMap;

public class Main {
    /**//from w w w  .ja  v  a  2  s  .c o m
     * Generate a Filter as a String given a Map of property/value pairs.
     * (& (prop1=value1) (& (prop2=value1)))
     * 
     * @param propertiesMap Map of properties
     * @return Filter as a String
     */
    public static String generatePropertiesFilter(SortedMap<String, String> propertiesMap) {
        if (propertiesMap.size() == 1) {
            return "(" + propertiesMap.firstKey() + "=" + propertiesMap.get(propertiesMap.firstKey()) + ")";
        } else if (propertiesMap.size() > 1) {
            return "(&"
                    + generatePropertiesFilter(
                            propertiesMap.subMap(propertiesMap.firstKey(), propertiesMap.firstKey() + "\0"))
                    + generatePropertiesFilter(propertiesMap.tailMap(propertiesMap.firstKey() + "\0")) + ")";
        }
        return "";
    }
}

Related

  1. computePathCauselessLms( List>> depCausesByNameList)
  2. filterPrefix( SortedMap baseMap, String prefix)
  3. find(SortedMap map, String baseName)
  4. firstElement(Collection c)
  5. firstElement(Collection c)
  6. getAll(SortedMap map)
  7. getObjectSortedMap(SortedMap map, T key)
  8. isCollectionClass(Class clazz)
  9. lastElement(List c)