JNIEXPORT jobject JNICALL
Java_org_oic_simulator_SimulatorResourceModel_getAttributes
(JNIEnv *env, jobject thiz)
{
    SimulatorResourceModel resourceModel;
    bool result = JSimulatorResourceModel::getResourceModel(env, thiz, resourceModel);
    if (!result)
    {
        throwSimulatorException(env, SIMULATOR_BAD_OBJECT, "Resource model not found!");
        return nullptr;
    }

    map<string, SimulatorResourceModel::Attribute> attributesMap = resourceModel.getAttributes();

    // Create Java HashMap object
    jobject jHashMap = NULL;
    jHashMap = createHashMap(env);
    if (!jHashMap)
    {
        throwSimulatorException(env, SIMULATOR_ERROR, "Java map creation failed!");
        return nullptr;
    }

    for (auto & attributeEntry : attributesMap)
    {
        SimulatorResourceModel::Attribute attribute(attributeEntry.second);

        // Create a object of ResourceAttribute java class
        JResourceAttributeConverter converter(attribute);
        jobject jAttribute = converter.toJava(env);

        // Add an entry with attribute.first and javaSimualatorResourceAttribute to the HashMap
        jstring jAttrName = env->NewStringUTF((attributeEntry.first).c_str());
        addEntryToHashMap(env, jHashMap, static_cast<jobject>(jAttrName), jAttribute);
        env->DeleteLocalRef(jAttrName);
    }

    return jHashMap;
}
jobject simulatorResourceModelToJava(JNIEnv *env, SimulatorResourceModel &resModel)
{
    jobject attributesMap = createHashMap(env);
    jobject propertiesMap = createHashMap(env);
    if (!attributesMap || !propertiesMap)
        return nullptr;

    for (auto &attributeEntry : resModel.getAttributes())
    {
        jstring jAttrName = env->NewStringUTF((attributeEntry.first).c_str());
        jobject jAttributeValue = JniAttributeValue::toJava(env, attributeEntry.second);
        addEntryToHashMap(env, attributesMap, jAttrName, jAttributeValue);

        jobject jAttributeProperty = JniAttributeProperty::toJava(env, attributeEntry.second.getProperty());
        if (jAttributeProperty)
            addEntryToHashMap(env, propertiesMap, jAttrName, jAttributeProperty);
    }

    static jmethodID simulatorResourceModelCtor = env->GetMethodID(
                gSimulatorClassRefs.simulatorResourceModelCls, "<init>", "(Ljava/util/Map;Ljava/util/Map;)V");

    return env->NewObject(gSimulatorClassRefs.simulatorResourceModelCls,
                          simulatorResourceModelCtor, attributesMap, propertiesMap);
}