static SelMap of()

in netflix-sel/src/main/java/com/netflix/sel/type/SelMap.java [38:77]


  static SelMap of(Map<String, Object> input) {
    if (input == null) {
      return new SelMap(null);
    }
    SelMap map = new SelMap(new HashMap<>());
    for (Map.Entry<String, Object> entry : input.entrySet()) {
      if (entry.getValue() instanceof String) {
        map.val.put(SelString.of(entry.getKey()), SelString.of((String) entry.getValue()));
      } else if (entry.getValue() instanceof Long || entry.getValue() instanceof Integer) {
        map.val.put(
            SelString.of(entry.getKey()), SelLong.of(((Number) entry.getValue()).longValue()));
      } else if (entry.getValue() instanceof Double || entry.getValue() instanceof Float) {
        map.val.put(
            SelString.of(entry.getKey()), SelDouble.of(((Number) entry.getValue()).doubleValue()));
      } else if (entry.getValue() instanceof Boolean) {
        map.val.put(SelString.of(entry.getKey()), SelBoolean.of((Boolean) entry.getValue()));
      } else if (entry.getValue() instanceof Map) {
        map.val.put(
            SelString.of(entry.getKey()), SelMap.of((Map<String, Object>) entry.getValue()));
      } else if (entry.getValue() instanceof String[]) {
        map.val.put(
            SelString.of(entry.getKey()), SelArray.of(entry.getValue(), SelTypes.STRING_ARRAY));
      } else if (entry.getValue() instanceof long[]) {
        map.val.put(
            SelString.of(entry.getKey()), SelArray.of(entry.getValue(), SelTypes.LONG_ARRAY));
      } else if (entry.getValue() instanceof double[]) {
        map.val.put(
            SelString.of(entry.getKey()), SelArray.of(entry.getValue(), SelTypes.DOUBLE_ARRAY));
      } else if (entry.getValue() instanceof boolean[]) {
        map.val.put(
            SelString.of(entry.getKey()), SelArray.of(entry.getValue(), SelTypes.BOOLEAN_ARRAY));
      } else {
        throw new IllegalArgumentException(
            "Invalid map entry type ("
                + (entry.getValue() == null ? "null" : entry.getValue().getClass().getName())
                + ") for Map constructor");
      }
    }
    return map;
  }