/* Entity.c generated by valac 0.56.19, the Vala compiler
 * generated from Entity.vala, do not modify */

#include <glib-object.h>
#include <gtk/gtk.h>
#include <json-glib/json-glib.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TUBA_TYPE_WIDGETIZABLE (tuba_widgetizable_get_type ())
#define TUBA_WIDGETIZABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_WIDGETIZABLE, TubaWidgetizable))
#define TUBA_IS_WIDGETIZABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_WIDGETIZABLE))
#define TUBA_WIDGETIZABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TUBA_TYPE_WIDGETIZABLE, TubaWidgetizableIface))

typedef struct _TubaWidgetizable TubaWidgetizable;
typedef struct _TubaWidgetizableIface TubaWidgetizableIface;

#define TUBA_TYPE_ENTITY (tuba_entity_get_type ())
#define TUBA_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_ENTITY, TubaEntity))
#define TUBA_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_ENTITY, TubaEntityClass))
#define TUBA_IS_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_ENTITY))
#define TUBA_IS_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_ENTITY))
#define TUBA_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_ENTITY, TubaEntityClass))

typedef struct _TubaEntity TubaEntity;
typedef struct _TubaEntityClass TubaEntityClass;

#define TUBA_API_TYPE_ACCOUNT (tuba_api_account_get_type ())
#define TUBA_API_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_API_TYPE_ACCOUNT, TubaAPIAccount))
#define TUBA_API_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_API_TYPE_ACCOUNT, TubaAPIAccountClass))
#define TUBA_API_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_API_TYPE_ACCOUNT))
#define TUBA_API_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_API_TYPE_ACCOUNT))
#define TUBA_API_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_API_TYPE_ACCOUNT, TubaAPIAccountClass))

typedef struct _TubaAPIAccount TubaAPIAccount;
typedef struct _TubaAPIAccountClass TubaAPIAccountClass;

#define TUBA_TYPE_INSTANCE_ACCOUNT (tuba_instance_account_get_type ())
#define TUBA_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_INSTANCE_ACCOUNT, TubaInstanceAccount))
#define TUBA_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_INSTANCE_ACCOUNT, TubaInstanceAccountClass))
#define TUBA_IS_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_INSTANCE_ACCOUNT))
#define TUBA_IS_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_INSTANCE_ACCOUNT))
#define TUBA_INSTANCE_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_INSTANCE_ACCOUNT, TubaInstanceAccountClass))

typedef struct _TubaInstanceAccount TubaInstanceAccount;
typedef struct _TubaInstanceAccountClass TubaInstanceAccountClass;
typedef struct _TubaEntityPrivate TubaEntityPrivate;
enum  {
	TUBA_ENTITY_0_PROPERTY,
	TUBA_ENTITY_NUM_PROPERTIES
};
static GParamSpec* tuba_entity_properties[TUBA_ENTITY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_param_spec_unref0(var) ((var == NULL) ? NULL : (var = (g_param_spec_unref (var), NULL)))

#define TUBA_TYPE_OOPSIE (tuba_oopsie_get_type ())
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
typedef struct _Block8Data Block8Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block9Data Block9Data;
typedef struct _Block10Data Block10Data;
typedef struct _Block11Data Block11Data;
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))

struct _TubaWidgetizableIface {
	GTypeInterface parent_iface;
	GtkWidget* (*to_widget) (TubaWidgetizable* self);
	void (*open) (TubaWidgetizable* self);
	void (*resolve_open) (TubaWidgetizable* self, TubaInstanceAccount* account);
};

struct _TubaEntity {
	GObject parent_instance;
	TubaEntityPrivate * priv;
};

struct _TubaEntityClass {
	GObjectClass parent_class;
	gboolean (*is_local) (TubaEntity* self, TubaInstanceAccount* account);
	GType (*deserialize_array_type) (TubaEntity* self, const gchar* prop);
};

typedef enum  {
	TUBA_OOPSIE_USER,
	TUBA_OOPSIE_PARSING,
	TUBA_OOPSIE_INSTANCE,
	TUBA_OOPSIE_INTERNAL,
	TUBA_OOPSIE_HTTP_401 = 401,
	TUBA_OOPSIE_HTTP_403 = 403,
	TUBA_OOPSIE_HTTP_404 = 404,
	TUBA_OOPSIE_HTTP_410 = 410,
	TUBA_OOPSIE_HTTP_422 = 422,
	TUBA_OOPSIE_HTTP_429 = 429,
	TUBA_OOPSIE_HTTP_500 = 500,
	TUBA_OOPSIE_HTTP_503 = 503
} TubaOopsie;
#define TUBA_OOPSIE tuba_oopsie_quark ()

struct _Block8Data {
	int _ref_count_;
	GeeArrayList* arr;
	GType type;
};

struct _Block9Data {
	int _ref_count_;
	GeeArrayList* arr;
};

struct _Block10Data {
	int _ref_count_;
	GeeArrayList* arr;
};

struct _Block11Data {
	int _ref_count_;
	JsonArray* arr;
};

static gpointer tuba_entity_parent_class = NULL;
static TubaWidgetizableIface * tuba_entity_tuba_widgetizable_parent_iface = NULL;
static JsonSerializableIface * tuba_entity_json_serializable_parent_iface = NULL;

VALA_EXTERN GType tuba_entity_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaEntity, g_object_unref)
VALA_EXTERN GType tuba_api_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaAPIAccount, g_object_unref)
VALA_EXTERN GType tuba_instance_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaInstanceAccount, g_object_unref)
VALA_EXTERN GType tuba_widgetizable_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaWidgetizable, g_object_unref)
VALA_EXTERN gboolean tuba_entity_is_local (TubaEntity* self,
                               TubaInstanceAccount* account);
VALA_EXTERN GType tuba_entity_deserialize_array_type (TubaEntity* self,
                                          const gchar* prop);
static gboolean tuba_entity_real_is_local (TubaEntity* self,
                                    TubaInstanceAccount* account);
static gboolean tuba_entity_is_spec_valid (GParamSpec** spec);
static GParamSpec* tuba_entity_real_find_property (JsonSerializable* base,
                                            const gchar* name);
VALA_EXTERN void tuba_entity_patch (TubaEntity* self,
                        GObject* with);
VALA_EXTERN void tuba_entity_patch_specs (TubaEntity* self,
                              GObject* obj,
                              GParamSpec** specs,
                              gint specs_length1);
VALA_EXTERN TubaEntity* tuba_entity_from_json (GType type,
                                   JsonNode* node,
                                   GError** error);
VALA_EXTERN GQuark tuba_oopsie_quark (void);
VALA_EXTERN GType tuba_oopsie_get_type (void) G_GNUC_CONST ;
VALA_EXTERN JsonNode* tuba_entity_to_json (TubaEntity* self);
VALA_EXTERN gchar* tuba_entity_to_json_data (TubaEntity* self);
static GType tuba_entity_real_deserialize_array_type (TubaEntity* self,
                                               const gchar* prop);
static gboolean tuba_entity_real_deserialize_property (JsonSerializable* base,
                                                const gchar* prop,
                                                GValue* val,
                                                GParamSpec* spec,
                                                JsonNode* node);
VALA_EXTERN gboolean tuba_entity_des_list_string (GValue* val,
                                      JsonNode* node);
VALA_EXTERN gboolean tuba_entity_des_list_int (GValue* val,
                                   JsonNode* node);
VALA_EXTERN gboolean tuba_entity_des_list (GValue* val,
                               JsonNode* node,
                               GType type);
static GValue* _g_value_dup (GValue* self);
static void _vala_GValue_free (GValue* self);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void ___lambda6_ (Block8Data* _data8_,
                  JsonArray* array,
                  guint i,
                  JsonNode* elem);
static void ____lambda6__json_array_foreach (JsonArray* array,
                                      guint index_,
                                      JsonNode* element_node,
                                      gpointer self);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static void ___lambda4_ (Block9Data* _data9_,
                  JsonArray* array,
                  guint i,
                  JsonNode* elem);
static void ____lambda4__json_array_foreach (JsonArray* array,
                                      guint index_,
                                      JsonNode* element_node,
                                      gpointer self);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
static void ___lambda5_ (Block10Data* _data10_,
                  JsonArray* array,
                  guint i,
                  JsonNode* elem);
static void ____lambda5__json_array_foreach (JsonArray* array,
                                      guint index_,
                                      JsonNode* element_node,
                                      gpointer self);
static JsonNode* tuba_entity_real_serialize_property (JsonSerializable* base,
                                               const gchar* prop,
                                               GValue* val,
                                               GParamSpec* spec);
static JsonNode* tuba_entity_ser_list (const gchar* prop,
                                GValue* val,
                                GParamSpec* spec);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static gboolean __lambda7_ (Block11Data* _data11_,
                     TubaEntity* e);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void _vala_JsonNode_free (JsonNode* self);
static gboolean ___lambda7__gee_forall_func (gpointer g,
                                      gpointer self);
VALA_EXTERN TubaEntity* tuba_entity_new (void);
VALA_EXTERN TubaEntity* tuba_entity_construct (GType object_type);
static GType tuba_entity_get_type_once (void);

static gboolean
tuba_entity_real_is_local (TubaEntity* self,
                           TubaInstanceAccount* account)
{
	gboolean result;
	g_return_val_if_fail (account != NULL, FALSE);
	result = TRUE;
	return result;
}

gboolean
tuba_entity_is_local (TubaEntity* self,
                      TubaInstanceAccount* account)
{
	TubaEntityClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = TUBA_ENTITY_GET_CLASS (self);
	if (_klass_->is_local) {
		return _klass_->is_local (self, account);
	}
	return FALSE;
}

static gboolean
tuba_entity_is_spec_valid (GParamSpec** spec)
{
	gboolean result;
	g_return_val_if_fail (*spec != NULL, FALSE);
	result = ((*spec)->flags & G_PARAM_WRITABLE) == G_PARAM_WRITABLE;
	return result;
}

static GParamSpec*
tuba_entity_real_find_property (JsonSerializable* base,
                                const gchar* name)
{
	TubaEntity * self;
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	GParamSpec* result;
	self = (TubaEntity*) base;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = name;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("type")))) {
		switch (0) {
			default:
			{
				GObjectClass* _tmp3_;
				GParamSpec* _tmp4_;
				_tmp3_ = G_OBJECT_GET_CLASS ((GObject*) self);
				_tmp4_ = g_object_class_find_property (_tmp3_, "kind");
				result = _tmp4_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("value")))) {
		switch (0) {
			default:
			{
				GObjectClass* _tmp5_;
				GParamSpec* _tmp6_;
				_tmp5_ = G_OBJECT_GET_CLASS ((GObject*) self);
				_tmp6_ = g_object_class_find_property (_tmp5_, "val");
				result = _tmp6_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("params")))) {
		switch (0) {
			default:
			{
				GObjectClass* _tmp7_;
				GParamSpec* _tmp8_;
				_tmp7_ = G_OBJECT_GET_CLASS ((GObject*) self);
				_tmp8_ = g_object_class_find_property (_tmp7_, "props");
				result = _tmp8_;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				GObjectClass* _tmp9_;
				GParamSpec* _tmp10_;
				if (g_str_has_prefix (name, "tuba-")) {
					result = NULL;
					return result;
				}
				_tmp9_ = G_OBJECT_GET_CLASS ((GObject*) self);
				_tmp10_ = g_object_class_find_property (_tmp9_, name);
				result = _tmp10_;
				return result;
			}
		}
	}
}

void
tuba_entity_patch (TubaEntity* self,
                   GObject* with)
{
	GObjectClass* _tmp0_;
	guint _tmp1_ = 0;
	GParamSpec** _tmp2_;
	GParamSpec** _tmp3_;
	gint _tmp3__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (with != NULL);
	_tmp0_ = G_OBJECT_GET_CLASS (with);
	_tmp2_ = g_object_class_list_properties (_tmp0_, &_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = _tmp1_;
	tuba_entity_patch_specs (self, with, _tmp3_, (gint) _tmp1_);
	_tmp3_ = (g_free (_tmp3_), NULL);
}

static gpointer
_g_param_spec_ref0 (gpointer self)
{
	return self ? g_param_spec_ref (self) : NULL;
}

void
tuba_entity_patch_specs (TubaEntity* self,
                         GObject* obj,
                         GParamSpec** specs,
                         gint specs_length1)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (obj != NULL);
	g_object_freeze_notify ((GObject*) self);
	{
		GParamSpec** spec_collection = NULL;
		gint spec_collection_length1 = 0;
		gint _spec_collection_size_ = 0;
		gint spec_it = 0;
		spec_collection = specs;
		spec_collection_length1 = specs_length1;
		for (spec_it = 0; spec_it < spec_collection_length1; spec_it = spec_it + 1) {
			GParamSpec* _tmp0_;
			GParamSpec* spec = NULL;
			_tmp0_ = _g_param_spec_ref0 (spec_collection[spec_it]);
			spec = _tmp0_;
			{
				gchar* name = NULL;
				GParamSpec* _tmp1_;
				const gchar* _tmp2_;
				gchar* _tmp3_;
				gboolean defined = FALSE;
				const gchar* _tmp4_;
				GParamSpec* _tmp5_;
				gboolean _tmp6_ = FALSE;
				_tmp1_ = spec;
				_tmp2_ = g_param_spec_get_name (_tmp1_);
				_tmp3_ = g_strdup (_tmp2_);
				name = _tmp3_;
				_tmp4_ = name;
				_tmp5_ = json_serializable_find_property ((JsonSerializable*) self, _tmp4_);
				defined = _tmp5_ != NULL;
				if (defined) {
					gboolean _tmp7_;
					_tmp7_ = tuba_entity_is_spec_valid (&spec);
					_tmp6_ = _tmp7_;
				} else {
					_tmp6_ = FALSE;
				}
				if (_tmp6_) {
					GValue val = {0};
					GParamSpec* _tmp8_;
					GValue _tmp9_ = {0};
					const gchar* _tmp10_;
					const gchar* _tmp11_;
					GValue _tmp12_;
					_tmp8_ = spec;
					g_value_init (&_tmp9_, _tmp8_->value_type);
					val = _tmp9_;
					_tmp10_ = name;
					g_object_get_property (obj, _tmp10_, &val);
					_tmp11_ = name;
					_tmp12_ = val;
					g_object_set_property (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject), _tmp11_, &_tmp12_);
					G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
				}
				_g_free0 (name);
				_g_param_spec_unref0 (spec);
			}
		}
	}
	g_object_thaw_notify ((GObject*) self);
}

static gpointer
_json_object_ref0 (gpointer self)
{
	return self ? json_object_ref (self) : NULL;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

TubaEntity*
tuba_entity_from_json (GType type,
                       JsonNode* node,
                       GError** error)
{
	JsonObject* obj = NULL;
	JsonObject* _tmp0_;
	JsonObject* _tmp1_;
	JsonObject* _tmp2_;
	GObject* _tmp9_;
	TubaEntity* _tmp10_;
	GError* _inner_error0_ = NULL;
	TubaEntity* result;
	g_return_val_if_fail (node != NULL, NULL);
	_tmp0_ = json_node_get_object (node);
	_tmp1_ = _json_object_ref0 (_tmp0_);
	obj = _tmp1_;
	_tmp2_ = obj;
	if (_tmp2_ == NULL) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		GError* _tmp7_;
		GError* _tmp8_;
		_tmp3_ = g_type_name (type);
		_tmp4_ = string_to_string (_tmp3_);
		_tmp5_ = g_strconcat ("Received Json.Node for ", _tmp4_, " is not a Json.Object!", NULL);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_PARSING, _tmp6_);
		_tmp8_ = _tmp7_;
		_g_free0 (_tmp6_);
		_inner_error0_ = _tmp8_;
		g_propagate_error (error, _inner_error0_);
		_json_object_unref0 (obj);
		return NULL;
	}
	_tmp9_ = json_gobject_deserialize (type, node);
	_tmp10_ = TUBA_IS_ENTITY (_tmp9_) ? ((TubaEntity*) _tmp9_) : NULL;
	if (_tmp10_ == NULL) {
		_g_object_unref0 (_tmp9_);
	}
	result = _tmp10_;
	_json_object_unref0 (obj);
	return result;
}

JsonNode*
tuba_entity_to_json (TubaEntity* self)
{
	JsonNode* _tmp0_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = json_gobject_serialize ((GObject*) self);
	result = _tmp0_;
	return result;
}

gchar*
tuba_entity_to_json_data (TubaEntity* self)
{
	gsize len = 0UL;
	gsize _tmp0_ = 0UL;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = json_gobject_to_data ((GObject*) self, &_tmp0_);
	len = _tmp0_;
	result = _tmp1_;
	return result;
}

static GType
tuba_entity_real_deserialize_array_type (TubaEntity* self,
                                         const gchar* prop)
{
	GType result;
	g_return_val_if_fail (prop != NULL, G_TYPE_INVALID);
	result = TUBA_TYPE_ENTITY;
	return result;
}

GType
tuba_entity_deserialize_array_type (TubaEntity* self,
                                    const gchar* prop)
{
	TubaEntityClass* _klass_;
	g_return_val_if_fail (self != NULL, G_TYPE_INVALID);
	_klass_ = TUBA_ENTITY_GET_CLASS (self);
	if (_klass_->deserialize_array_type) {
		return _klass_->deserialize_array_type (self, prop);
	}
	return G_TYPE_INVALID;
}

static GValue*
_g_value_dup (GValue* self)
{
	return g_boxed_copy (G_TYPE_VALUE, self);
}

static gpointer
__g_value_dup0 (gpointer self)
{
	return self ? _g_value_dup (self) : NULL;
}

static void
_vala_GValue_free (GValue* self)
{
	g_boxed_free (G_TYPE_VALUE, self);
}

static gboolean
tuba_entity_real_deserialize_property (JsonSerializable* base,
                                       const gchar* prop,
                                       GValue* val,
                                       GParamSpec* spec,
                                       JsonNode* node)
{
	TubaEntity * self;
	GValue _vala_val = {0};
	gboolean success = FALSE;
	GValue _tmp0_ = {0};
	gboolean _tmp1_;
	GType type = G_TYPE_NONE;
	gboolean _tmp8_ = FALSE;
	gboolean result;
	self = (TubaEntity*) base;
	g_return_val_if_fail (prop != NULL, FALSE);
	g_return_val_if_fail (spec != NULL, FALSE);
	g_return_val_if_fail (node != NULL, FALSE);
	_tmp1_ = json_serializable_default_deserialize_property ((JsonSerializable*) self, prop, &_tmp0_, spec, node);
	G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	_vala_val = _tmp0_;
	success = _tmp1_;
	type = spec->value_type;
	if (G_VALUE_TYPE (&_vala_val) == G_TYPE_INVALID) {
		g_value_init (&_vala_val, type);
		g_param_value_set_default (spec, &_vala_val);
		type = spec->value_type;
	}
	if (g_type_is_a (type, GEE_TYPE_ARRAY_LIST)) {
		GType contains = G_TYPE_NONE;
		GValue _tmp6_ = {0};
		gboolean _tmp7_;
		contains = tuba_entity_deserialize_array_type (self, prop);
		switch (contains) {
			case G_TYPE_STRING:
			{
				GValue _tmp2_ = {0};
				gboolean _tmp3_;
				_tmp3_ = tuba_entity_des_list_string (&_tmp2_, node);
				G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
				_vala_val = _tmp2_;
				result = _tmp3_;
				if (val) {
					*val = _vala_val;
				} else {
					G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
				}
				return result;
			}
			case G_TYPE_INT:
			{
				GValue _tmp4_ = {0};
				gboolean _tmp5_;
				_tmp5_ = tuba_entity_des_list_int (&_tmp4_, node);
				G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
				_vala_val = _tmp4_;
				result = _tmp5_;
				if (val) {
					*val = _vala_val;
				} else {
					G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
				}
				return result;
			}
			default:
			break;
		}
		_tmp7_ = tuba_entity_des_list (&_tmp6_, node, contains);
		G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
		_vala_val = _tmp6_;
		result = _tmp7_;
		if (val) {
			*val = _vala_val;
		} else {
			G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
		}
		return result;
	}
	if (!success) {
		gboolean _tmp9_ = FALSE;
		gboolean _tmp10_ = FALSE;
		if (type == G_TYPE_BOOLEAN) {
			_tmp10_ = TRUE;
		} else {
			_tmp10_ = type == G_TYPE_INT;
		}
		if (_tmp10_) {
			_tmp9_ = TRUE;
		} else {
			_tmp9_ = type == G_TYPE_INT64;
		}
		_tmp8_ = _tmp9_;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		GValue* default_val = NULL;
		GValue* _tmp11_;
		GValue* _tmp12_;
		_tmp11_ = __g_value_dup0 (g_param_spec_get_default_value (spec));
		default_val = _tmp11_;
		_tmp12_ = default_val;
		if (((gpointer) _tmp12_) != NULL) {
			GValue* _tmp13_;
			GValue _tmp14_;
			GValue _tmp15_ = {0};
			_tmp13_ = default_val;
			_tmp14_ = *_tmp13_;
			if (G_IS_VALUE (&_tmp14_)) {
				g_value_init (&_tmp15_, G_VALUE_TYPE (&_tmp14_));
				g_value_copy (&_tmp14_, &_tmp15_);
			} else {
				_tmp15_ = _tmp14_;
			}
			G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
			_vala_val = _tmp15_;
			result = TRUE;
			__vala_GValue_free0 (default_val);
			if (val) {
				*val = _vala_val;
			} else {
				G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
			}
			return result;
		}
		__vala_GValue_free0 (default_val);
	}
	result = success;
	if (val) {
		*val = _vala_val;
	} else {
		G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	}
	return result;
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		_g_object_unref0 (_data8_->arr);
		g_slice_free (Block8Data, _data8_);
	}
}

static void
___lambda6_ (Block8Data* _data8_,
             JsonArray* array,
             guint i,
             JsonNode* elem)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (array != NULL);
	g_return_if_fail (elem != NULL);
	{
		TubaEntity* obj = NULL;
		TubaEntity* _tmp0_;
		GeeArrayList* _tmp1_;
		_tmp0_ = tuba_entity_from_json (_data8_->type, elem, &_inner_error0_);
		obj = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp1_ = _data8_->arr;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, obj);
		_g_object_unref0 (obj);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		_tmp4_ = string_to_string (_tmp3_);
		_tmp5_ = g_strconcat ("Error getting Entity from json: ", _tmp4_, NULL);
		_tmp6_ = _tmp5_;
		g_warning ("Entity.vala:107: %s", _tmp6_);
		_g_free0 (_tmp6_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
____lambda6__json_array_foreach (JsonArray* array,
                                 guint index_,
                                 JsonNode* element_node,
                                 gpointer self)
{
	___lambda6_ (self, array, index_, element_node);
}

gboolean
tuba_entity_des_list (GValue* val,
                      JsonNode* node,
                      GType type)
{
	GValue _vala_val = {0};
	Block8Data* _data8_;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp2_;
	GValue _tmp3_ = {0};
	gboolean result;
	g_return_val_if_fail (node != NULL, FALSE);
	_data8_ = g_slice_new0 (Block8Data);
	_data8_->_ref_count_ = 1;
	_data8_->type = type;
	_tmp0_ = gee_array_list_new (TUBA_TYPE_ENTITY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data8_->arr = _tmp0_;
	if (!json_node_is_null (node)) {
		JsonArray* _tmp1_;
		_tmp1_ = json_node_get_array (node);
		json_array_foreach_element (_tmp1_, ____lambda6__json_array_foreach, _data8_);
	}
	_tmp2_ = _data8_->arr;
	g_value_init (&_tmp3_, GEE_TYPE_ARRAY_LIST);
	g_value_set_object (&_tmp3_, _tmp2_);
	G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	_vala_val = _tmp3_;
	result = TRUE;
	block8_data_unref (_data8_);
	_data8_ = NULL;
	if (val) {
		*val = _vala_val;
	} else {
		G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	}
	return result;
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		_g_object_unref0 (_data9_->arr);
		g_slice_free (Block9Data, _data9_);
	}
}

static void
___lambda4_ (Block9Data* _data9_,
             JsonArray* array,
             guint i,
             JsonNode* elem)
{
	GeeArrayList* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (array != NULL);
	g_return_if_fail (elem != NULL);
	_tmp0_ = _data9_->arr;
	_tmp1_ = json_node_get_string (elem);
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, (const gchar*) _tmp1_);
}

static void
____lambda4__json_array_foreach (JsonArray* array,
                                 guint index_,
                                 JsonNode* element_node,
                                 gpointer self)
{
	___lambda4_ (self, array, index_, element_node);
}

gboolean
tuba_entity_des_list_string (GValue* val,
                             JsonNode* node)
{
	GValue _vala_val = {0};
	Block9Data* _data9_;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp2_;
	GValue _tmp3_ = {0};
	gboolean result;
	g_return_val_if_fail (node != NULL, FALSE);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_data9_->arr = _tmp0_;
	if (!json_node_is_null (node)) {
		JsonArray* _tmp1_;
		_tmp1_ = json_node_get_array (node);
		json_array_foreach_element (_tmp1_, ____lambda4__json_array_foreach, _data9_);
	}
	_tmp2_ = _data9_->arr;
	g_value_init (&_tmp3_, GEE_TYPE_ARRAY_LIST);
	g_value_set_object (&_tmp3_, _tmp2_);
	G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	_vala_val = _tmp3_;
	result = TRUE;
	block9_data_unref (_data9_);
	_data9_ = NULL;
	if (val) {
		*val = _vala_val;
	} else {
		G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	}
	return result;
}

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		_g_object_unref0 (_data10_->arr);
		g_slice_free (Block10Data, _data10_);
	}
}

static void
___lambda5_ (Block10Data* _data10_,
             JsonArray* array,
             guint i,
             JsonNode* elem)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (array != NULL);
	g_return_if_fail (elem != NULL);
	_tmp0_ = _data10_->arr;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, (gpointer) ((gintptr) json_node_get_int (elem)));
}

static void
____lambda5__json_array_foreach (JsonArray* array,
                                 guint index_,
                                 JsonNode* element_node,
                                 gpointer self)
{
	___lambda5_ (self, array, index_, element_node);
}

gboolean
tuba_entity_des_list_int (GValue* val,
                          JsonNode* node)
{
	GValue _vala_val = {0};
	Block10Data* _data10_;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp2_;
	GValue _tmp3_ = {0};
	gboolean result;
	g_return_val_if_fail (node != NULL, FALSE);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_tmp0_ = gee_array_list_new (G_TYPE_INT, NULL, NULL, NULL, NULL, NULL);
	_data10_->arr = _tmp0_;
	if (!json_node_is_null (node)) {
		JsonArray* _tmp1_;
		_tmp1_ = json_node_get_array (node);
		json_array_foreach_element (_tmp1_, ____lambda5__json_array_foreach, _data10_);
	}
	_tmp2_ = _data10_->arr;
	g_value_init (&_tmp3_, GEE_TYPE_ARRAY_LIST);
	g_value_set_object (&_tmp3_, _tmp2_);
	G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	_vala_val = _tmp3_;
	result = TRUE;
	block10_data_unref (_data10_);
	_data10_ = NULL;
	if (val) {
		*val = _vala_val;
	} else {
		G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	}
	return result;
}

static JsonNode*
tuba_entity_real_serialize_property (JsonSerializable* base,
                                     const gchar* prop,
                                     GValue* val,
                                     GParamSpec* spec)
{
	TubaEntity * self;
	GType type = G_TYPE_NONE;
	GValue _tmp2_;
	JsonNode* _tmp3_;
	JsonNode* result;
	self = (TubaEntity*) base;
	g_return_val_if_fail (prop != NULL, NULL);
	g_return_val_if_fail (val != NULL, NULL);
	g_return_val_if_fail (spec != NULL, NULL);
	type = spec->value_type;
	if (g_type_is_a (type, GEE_TYPE_ARRAY_LIST)) {
		GValue _tmp0_;
		JsonNode* _tmp1_;
		_tmp0_ = *val;
		_tmp1_ = tuba_entity_ser_list (prop, &_tmp0_, spec);
		result = _tmp1_;
		return result;
	}
	_tmp2_ = *val;
	_tmp3_ = json_serializable_default_serialize_property ((JsonSerializable*) self, prop, &_tmp2_, spec);
	result = _tmp3_;
	return result;
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		_json_array_unref0 (_data11_->arr);
		g_slice_free (Block11Data, _data11_);
	}
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static JsonNode*
_vala_JsonNode_copy (JsonNode* self)
{
	return g_boxed_copy (json_node_get_type (), self);
}

static gpointer
__vala_JsonNode_copy0 (gpointer self)
{
	return self ? _vala_JsonNode_copy (self) : NULL;
}

static void
_vala_JsonNode_free (JsonNode* self)
{
	g_boxed_free (json_node_get_type (), self);
}

static gboolean
__lambda7_ (Block11Data* _data11_,
            TubaEntity* e)
{
	JsonNode* enode = NULL;
	JsonNode* _tmp0_;
	JsonArray* _tmp1_;
	JsonNode* _tmp2_;
	gboolean result;
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = tuba_entity_to_json (e);
	enode = _tmp0_;
	_tmp1_ = _data11_->arr;
	_tmp2_ = __vala_JsonNode_copy0 (enode);
	json_array_add_element (_tmp1_, _tmp2_);
	result = TRUE;
	__vala_JsonNode_free0 (enode);
	_g_object_unref0 (e);
	return result;
}

static gboolean
___lambda7__gee_forall_func (gpointer g,
                             gpointer self)
{
	gboolean result;
	result = __lambda7_ (self, (TubaEntity*) g);
	return result;
}

static JsonNode*
tuba_entity_ser_list (const gchar* prop,
                      GValue* val,
                      GParamSpec* spec)
{
	Block11Data* _data11_;
	GeeArrayList* list = NULL;
	GValue _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	JsonArray* _tmp4_;
	GeeArrayList* _tmp5_;
	JsonNode* node = NULL;
	JsonNode* _tmp6_;
	JsonNode* _tmp7_;
	JsonArray* _tmp8_;
	JsonNode* result;
	g_return_val_if_fail (prop != NULL, NULL);
	g_return_val_if_fail (val != NULL, NULL);
	g_return_val_if_fail (spec != NULL, NULL);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_tmp0_ = *val;
	_tmp1_ = _g_object_ref0 (g_value_get_object (&_tmp0_));
	list = _tmp1_;
	_tmp2_ = list;
	if (_tmp2_ == NULL) {
		JsonNode* _tmp3_;
		_tmp3_ = json_node_new (JSON_NODE_NULL);
		result = _tmp3_;
		_g_object_unref0 (list);
		block11_data_unref (_data11_);
		_data11_ = NULL;
		return result;
	}
	_tmp4_ = json_array_new ();
	_data11_->arr = _tmp4_;
	_tmp5_ = list;
	gee_abstract_collection_foreach ((GeeAbstractCollection*) _tmp5_, ___lambda7__gee_forall_func, _data11_);
	_tmp6_ = json_node_new (JSON_NODE_ARRAY);
	node = _tmp6_;
	_tmp7_ = node;
	_tmp8_ = _data11_->arr;
	json_node_set_array (_tmp7_, _tmp8_);
	result = node;
	_g_object_unref0 (list);
	block11_data_unref (_data11_);
	_data11_ = NULL;
	return result;
}

TubaEntity*
tuba_entity_construct (GType object_type)
{
	TubaEntity * self = NULL;
	self = (TubaEntity*) g_object_new (object_type, NULL);
	return self;
}

TubaEntity*
tuba_entity_new (void)
{
	return tuba_entity_construct (TUBA_TYPE_ENTITY);
}

static void
tuba_entity_class_init (TubaEntityClass * klass,
                        gpointer klass_data)
{
	tuba_entity_parent_class = g_type_class_peek_parent (klass);
	((TubaEntityClass *) klass)->is_local = (gboolean (*) (TubaEntity*, TubaInstanceAccount*)) tuba_entity_real_is_local;
	((TubaEntityClass *) klass)->deserialize_array_type = (GType (*) (TubaEntity*, const gchar*)) tuba_entity_real_deserialize_array_type;
}

static void
tuba_entity_tuba_widgetizable_interface_init (TubaWidgetizableIface * iface,
                                              gpointer iface_data)
{
	tuba_entity_tuba_widgetizable_parent_iface = g_type_interface_peek_parent (iface);
}

static void
tuba_entity_json_serializable_interface_init (JsonSerializableIface * iface,
                                              gpointer iface_data)
{
	tuba_entity_json_serializable_parent_iface = g_type_interface_peek_parent (iface);
	iface->find_property = (GParamSpec* (*) (JsonSerializable*, const gchar*)) tuba_entity_real_find_property;
	iface->deserialize_property = (gboolean (*) (JsonSerializable*, const gchar*, GValue*, GParamSpec*, JsonNode*)) tuba_entity_real_deserialize_property;
	iface->serialize_property = (JsonNode* (*) (JsonSerializable*, const gchar*, GValue*, GParamSpec*)) tuba_entity_real_serialize_property;
}

static void
tuba_entity_instance_init (TubaEntity * self,
                           gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
tuba_entity_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TubaEntityClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_entity_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaEntity), 0, (GInstanceInitFunc) tuba_entity_instance_init, NULL };
	static const GInterfaceInfo tuba_widgetizable_info = { (GInterfaceInitFunc) tuba_entity_tuba_widgetizable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo json_serializable_info = { (GInterfaceInitFunc) tuba_entity_json_serializable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType tuba_entity_type_id;
	tuba_entity_type_id = g_type_register_static (G_TYPE_OBJECT, "TubaEntity", &g_define_type_info, G_TYPE_FLAG_NONE);
	g_type_add_interface_static (tuba_entity_type_id, TUBA_TYPE_WIDGETIZABLE, &tuba_widgetizable_info);
	g_type_add_interface_static (tuba_entity_type_id, json_serializable_get_type (), &json_serializable_info);
	return tuba_entity_type_id;
}

GType
tuba_entity_get_type (void)
{
	static GType tuba_entity_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_entity_type_id__once)) {
		GType tuba_entity_type_id;
		tuba_entity_type_id = tuba_entity_get_type_once ();
		g_once_init_leave_pointer (&tuba_entity_type_id__once, tuba_entity_type_id);
	}
	return tuba_entity_type_id__once;
}

