public static EventProperty getEventProperty()

in streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/parser/util/JsonEventProperty.java [41:92]


  public static EventProperty getEventProperty(String key, Object o) {
    EventProperty resultProperty = null;

    if (o == null) {
      resultProperty = makePrimitiveProperty(key, XSD.STRING.toString());
    } else if (o.getClass().equals(Boolean.class)) {
      resultProperty = makePrimitiveProperty(key, XSD.BOOLEAN.toString());
    } else if (o.getClass().equals(String.class)) {
      resultProperty = makePrimitiveProperty(key, XSD.STRING.toString());
    } else if (o.getClass().equals(Integer.class) || o.getClass().equals(Double.class)
               || o.getClass().equals(Float.class) || o.getClass().equals(Long.class)
               || o.getClass().equals(BigDecimal.class)) {
      resultProperty = makePrimitiveProperty(key, XSD.FLOAT.toString());
    } else if (o.getClass().equals(LinkedHashMap.class)) {
      resultProperty = new EventPropertyNested();
      resultProperty.setRuntimeName(key);
      List<EventProperty> all = new ArrayList<>();
      for (Map.Entry<String, Object> entry : ((Map<String, Object>) o).entrySet()) {
        all.add(getEventProperty(entry.getKey(), entry.getValue()));
      }

      ((EventPropertyNested) resultProperty).setEventProperties(all);

    } else if (o.getClass().equals(ArrayList.class)) {
      resultProperty = new EventPropertyList();
      ArrayList content = (ArrayList) o;

      EventPropertyPrimitive arrayContent = new EventPropertyPrimitive();
      if (content.size() == 0) {
        arrayContent.setRuntimeType(XSD.STRING.toString());
      } else if (content.get(0) instanceof Integer || content.get(0) instanceof Double
                 || content.get(0) instanceof Long) {
        arrayContent.setRuntimeType(XSD.FLOAT.toString());
      } else if (content.get(0) instanceof Boolean) {
        arrayContent.setRuntimeType(XSD.BOOLEAN.toString());
      } else {
        arrayContent.setRuntimeType(XSD.STRING.toString());
      }

      ((EventPropertyList) resultProperty).setEventProperty(arrayContent);
      resultProperty.setRuntimeName(key);

    }

    if (resultProperty == null) {
      LOG.error("Property Type was not detected in JsonParser for the schema detection. "
                + "This should never happen!");
    }

    resultProperty.setDescription("");
    return resultProperty;
  }