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

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

#define TOOTLE_TYPE_WIDGETIZABLE (tootle_widgetizable_get_type ())
#define TOOTLE_WIDGETIZABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_WIDGETIZABLE, TootleWidgetizable))
#define TOOTLE_IS_WIDGETIZABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_WIDGETIZABLE))
#define TOOTLE_WIDGETIZABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TOOTLE_TYPE_WIDGETIZABLE, TootleWidgetizableIface))

typedef struct _TootleWidgetizable TootleWidgetizable;
typedef struct _TootleWidgetizableIface TootleWidgetizableIface;

#define TOOTLE_TYPE_ENTITY (tootle_entity_get_type ())
#define TOOTLE_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_ENTITY, TootleEntity))
#define TOOTLE_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_ENTITY, TootleEntityClass))
#define TOOTLE_IS_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_ENTITY))
#define TOOTLE_IS_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_ENTITY))
#define TOOTLE_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_ENTITY, TootleEntityClass))

typedef struct _TootleEntity TootleEntity;
typedef struct _TootleEntityClass TootleEntityClass;

#define TOOTLE_API_TYPE_ACCOUNT (tootle_api_account_get_type ())
#define TOOTLE_API_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccount))
#define TOOTLE_API_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccountClass))
#define TOOTLE_API_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_ACCOUNT))
#define TOOTLE_API_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_ACCOUNT))
#define TOOTLE_API_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccountClass))

typedef struct _TootleAPIAccount TootleAPIAccount;
typedef struct _TootleAPIAccountClass TootleAPIAccountClass;

#define TOOTLE_TYPE_INSTANCE_ACCOUNT (tootle_instance_account_get_type ())
#define TOOTLE_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccount))
#define TOOTLE_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccountClass))
#define TOOTLE_IS_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT))
#define TOOTLE_IS_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_INSTANCE_ACCOUNT))
#define TOOTLE_INSTANCE_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccountClass))

typedef struct _TootleInstanceAccount TootleInstanceAccount;
typedef struct _TootleInstanceAccountClass TootleInstanceAccountClass;
typedef struct _TootleEntityPrivate TootleEntityPrivate;
enum  {
	TOOTLE_ENTITY_0_PROPERTY,
	TOOTLE_ENTITY_NUM_PROPERTIES
};
static GParamSpec* tootle_entity_properties[TOOTLE_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 _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 TOOTLE_API_TYPE_ATTACHMENT (tootle_api_attachment_get_type ())
#define TOOTLE_API_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachment))
#define TOOTLE_API_ATTACHMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachmentClass))
#define TOOTLE_API_IS_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_ATTACHMENT))
#define TOOTLE_API_IS_ATTACHMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_ATTACHMENT))
#define TOOTLE_API_ATTACHMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachmentClass))

typedef struct _TootleAPIAttachment TootleAPIAttachment;
typedef struct _TootleAPIAttachmentClass TootleAPIAttachmentClass;

#define TOOTLE_API_TYPE_MENTION (tootle_api_mention_get_type ())
#define TOOTLE_API_MENTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_MENTION, TootleAPIMention))
#define TOOTLE_API_MENTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_MENTION, TootleAPIMentionClass))
#define TOOTLE_API_IS_MENTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_MENTION))
#define TOOTLE_API_IS_MENTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_MENTION))
#define TOOTLE_API_MENTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_MENTION, TootleAPIMentionClass))

typedef struct _TootleAPIMention TootleAPIMention;
typedef struct _TootleAPIMentionClass TootleAPIMentionClass;

#define TOOTLE_API_TYPE_ACCOUNT_FIELD (tootle_api_account_field_get_type ())
#define TOOTLE_API_ACCOUNT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_ACCOUNT_FIELD, TootleAPIAccountField))
#define TOOTLE_API_ACCOUNT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_ACCOUNT_FIELD, TootleAPIAccountFieldClass))
#define TOOTLE_API_IS_ACCOUNT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_ACCOUNT_FIELD))
#define TOOTLE_API_IS_ACCOUNT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_ACCOUNT_FIELD))
#define TOOTLE_API_ACCOUNT_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_ACCOUNT_FIELD, TootleAPIAccountFieldClass))

typedef struct _TootleAPIAccountField TootleAPIAccountField;
typedef struct _TootleAPIAccountFieldClass TootleAPIAccountFieldClass;

#define TOOTLE_API_TYPE_STATUS (tootle_api_status_get_type ())
#define TOOTLE_API_STATUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_STATUS, TootleAPIStatus))
#define TOOTLE_API_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_STATUS, TootleAPIStatusClass))
#define TOOTLE_API_IS_STATUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_STATUS))
#define TOOTLE_API_IS_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_STATUS))
#define TOOTLE_API_STATUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_STATUS, TootleAPIStatusClass))

typedef struct _TootleAPIStatus TootleAPIStatus;
typedef struct _TootleAPIStatusClass TootleAPIStatusClass;

#define TOOTLE_API_TYPE_TAG (tootle_api_tag_get_type ())
#define TOOTLE_API_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_TAG, TootleAPITag))
#define TOOTLE_API_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_TAG, TootleAPITagClass))
#define TOOTLE_API_IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_TAG))
#define TOOTLE_API_IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_TAG))
#define TOOTLE_API_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_TAG, TootleAPITagClass))

typedef struct _TootleAPITag TootleAPITag;
typedef struct _TootleAPITagClass TootleAPITagClass;
typedef struct _Block20Data Block20Data;
typedef struct _Block21Data Block21Data;
typedef struct _Block22Data Block22Data;
#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)))

typedef enum  {
	TOOTLE_OOPSIE_USER,
	TOOTLE_OOPSIE_PARSING,
	TOOTLE_OOPSIE_INSTANCE,
	TOOTLE_OOPSIE_INTERNAL
} TootleOopsie;
#define TOOTLE_OOPSIE tootle_oopsie_quark ()
struct _TootleWidgetizableIface {
	GTypeInterface parent_iface;
	GtkWidget* (*to_widget) (TootleWidgetizable* self, GError** error);
	void (*open) (TootleWidgetizable* self);
	void (*resolve_open) (TootleWidgetizable* self, TootleInstanceAccount* account);
};

struct _TootleEntity {
	GObject parent_instance;
	TootleEntityPrivate * priv;
};

struct _TootleEntityClass {
	GObjectClass parent_class;
	gboolean (*is_local) (TootleEntity* self, TootleInstanceAccount* account);
};

struct _Block20Data {
	int _ref_count_;
	GType type;
};

struct _Block21Data {
	int _ref_count_;
	Block20Data * _data20_;
	GeeArrayList* arr;
};

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

static gpointer tootle_entity_parent_class = NULL;
static TootleWidgetizableIface * tootle_entity_tootle_widgetizable_parent_iface = NULL;
static JsonSerializableIface * tootle_entity_json_serializable_parent_iface = NULL;

GQuark tootle_oopsie_quark (void);
GType tootle_entity_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleEntity, g_object_unref)
GType tootle_api_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIAccount, g_object_unref)
GType tootle_instance_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleInstanceAccount, g_object_unref)
GType tootle_widgetizable_get_type (void) G_GNUC_CONST ;
gboolean tootle_entity_is_local (TootleEntity* self,
                                 TootleInstanceAccount* account);
static gboolean tootle_entity_real_is_local (TootleEntity* self,
                                      TootleInstanceAccount* account);
static gboolean tootle_entity_is_spec_valid (GParamSpec* * spec);
static GParamSpec* tootle_entity_real_find_property (JsonSerializable* base,
                                              const gchar* name);
void tootle_entity_patch (TootleEntity* self,
                          GObject* with);
void tootle_entity_patch_specs (TootleEntity* self,
                                GObject* with,
                                GParamSpec** specs,
                                gint specs_length1);
TootleEntity* tootle_entity_from_json (GType type,
                                       JsonNode* node,
                                       GError** error);
JsonNode* tootle_entity_to_json (TootleEntity* self);
gchar* tootle_entity_to_json_data (TootleEntity* self);
static gboolean tootle_entity_real_deserialize_property (JsonSerializable* base,
                                                  const gchar* prop,
                                                  GValue* val,
                                                  GParamSpec* spec,
                                                  JsonNode* node);
GType tootle_api_attachment_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIAttachment, g_object_unref)
GType tootle_api_mention_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIMention, g_object_unref)
GType tootle_api_account_field_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIAccountField, g_object_unref)
GType tootle_api_status_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIStatus, g_object_unref)
GType tootle_api_tag_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPITag, g_object_unref)
static gboolean tootle_entity_des_list (GValue* val,
                                 JsonNode* node,
                                 GType type);
static Block20Data* block20_data_ref (Block20Data* _data20_);
static void block20_data_unref (void * _userdata_);
static Block21Data* block21_data_ref (Block21Data* _data21_);
static void block21_data_unref (void * _userdata_);
static void ___lambda98_ (Block21Data* _data21_,
                   JsonArray* array,
                   guint i,
                   JsonNode* elem);
static void ____lambda98__json_array_foreach (JsonArray* array,
                                       guint index_,
                                       JsonNode* element_node,
                                       gpointer self);
static JsonNode* tootle_entity_real_serialize_property (JsonSerializable* base,
                                                 const gchar* prop,
                                                 GValue* val,
                                                 GParamSpec* spec);
static JsonNode* tootle_entity_ser_list (const gchar* prop,
                                  GValue* val,
                                  GParamSpec* spec);
static Block22Data* block22_data_ref (Block22Data* _data22_);
static void block22_data_unref (void * _userdata_);
static gboolean __lambda99_ (Block22Data* _data22_,
                      TootleEntity* e);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void _vala_JsonNode_free (JsonNode* self);
static gboolean ___lambda99__gee_forall_func (gpointer g,
                                       gpointer self);
TootleEntity* tootle_entity_new (void);
TootleEntity* tootle_entity_construct (GType object_type);
static GType tootle_entity_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gboolean
tootle_entity_real_is_local (TootleEntity* self,
                             TootleInstanceAccount* account)
{
	gboolean result = FALSE;
	g_return_val_if_fail (account != NULL, FALSE);
	result = TRUE;
	return result;
}

gboolean
tootle_entity_is_local (TootleEntity* self,
                        TootleInstanceAccount* account)
{
	TootleEntityClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = TOOTLE_ENTITY_GET_CLASS (self);
	if (_klass_->is_local) {
		return _klass_->is_local (self, account);
	}
	return FALSE;
}

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

static GParamSpec*
tootle_entity_real_find_property (JsonSerializable* base,
                                  const gchar* name)
{
	TootleEntity * self;
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	GParamSpec* result = NULL;
	self = (TootleEntity*) 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 {
		switch (0) {
			default:
			{
				GObjectClass* _tmp7_;
				GParamSpec* _tmp8_;
				_tmp7_ = G_OBJECT_GET_CLASS ((GObject*) self);
				_tmp8_ = g_object_class_find_property (_tmp7_, name);
				result = _tmp8_;
				return result;
			}
		}
	}
}

void
tootle_entity_patch (TootleEntity* 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_;
	tootle_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
tootle_entity_patch_specs (TootleEntity* self,
                           GObject* with,
                           GParamSpec** specs,
                           gint specs_length1)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (with != NULL);
	{
		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;
				GObjectClass* _tmp4_;
				const gchar* _tmp5_;
				GParamSpec* _tmp6_;
				gboolean _tmp7_ = FALSE;
				_tmp1_ = spec;
				_tmp2_ = g_param_spec_get_name (_tmp1_);
				_tmp3_ = g_strdup (_tmp2_);
				name = _tmp3_;
				_tmp4_ = G_OBJECT_GET_CLASS ((GObject*) self);
				_tmp5_ = name;
				_tmp6_ = g_object_class_find_property (_tmp4_, _tmp5_);
				defined = _tmp6_ != NULL;
				if (defined) {
					gboolean _tmp8_;
					_tmp8_ = tootle_entity_is_spec_valid (&spec);
					_tmp7_ = _tmp8_;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					GValue val = {0};
					GParamSpec* _tmp9_;
					GValue _tmp10_ = {0};
					const gchar* _tmp11_;
					const gchar* _tmp12_;
					GValue _tmp13_;
					_tmp9_ = spec;
					g_value_init (&_tmp10_, _tmp9_->value_type);
					val = _tmp10_;
					_tmp11_ = name;
					g_object_get_property (with, _tmp11_, &val);
					_tmp12_ = name;
					_tmp13_ = val;
					g_object_set_property (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject), _tmp12_, &_tmp13_);
					G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
				}
				_g_free0 (name);
				_g_param_spec_unref0 (spec);
			}
		}
	}
}

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

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

TootleEntity*
tootle_entity_from_json (GType type,
                         JsonNode* node,
                         GError** error)
{
	JsonObject* obj = NULL;
	JsonObject* _tmp6_;
	JsonObject* _tmp7_;
	JsonObject* _tmp8_;
	GObject* _tmp15_;
	TootleEntity* _tmp16_;
	GError* _inner_error0_ = NULL;
	TootleEntity* result = NULL;
	if (node == NULL) {
		const gchar* _tmp0_;
		const gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		GError* _tmp4_;
		GError* _tmp5_;
		_tmp0_ = g_type_name (type);
		_tmp1_ = string_to_string (_tmp0_);
		_tmp2_ = g_strconcat ("Received Json.Node for ", _tmp1_, " is null!", NULL);
		_tmp3_ = _tmp2_;
		_tmp4_ = g_error_new_literal (TOOTLE_OOPSIE, TOOTLE_OOPSIE_PARSING, _tmp3_);
		_tmp5_ = _tmp4_;
		_g_free0 (_tmp3_);
		_inner_error0_ = _tmp5_;
		if (_inner_error0_->domain == TOOTLE_OOPSIE) {
			g_propagate_error (error, _inner_error0_);
			return NULL;
		} else {
			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 NULL;
		}
	}
	_tmp6_ = json_node_get_object (node);
	_tmp7_ = _json_object_ref0 (_tmp6_);
	obj = _tmp7_;
	_tmp8_ = obj;
	if (_tmp8_ == NULL) {
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		GError* _tmp13_;
		GError* _tmp14_;
		_tmp9_ = g_type_name (type);
		_tmp10_ = string_to_string (_tmp9_);
		_tmp11_ = g_strconcat ("Received Json.Node for ", _tmp10_, " is not a Json.Object!", NULL);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_error_new_literal (TOOTLE_OOPSIE, TOOTLE_OOPSIE_PARSING, _tmp12_);
		_tmp14_ = _tmp13_;
		_g_free0 (_tmp12_);
		_inner_error0_ = _tmp14_;
		if (_inner_error0_->domain == TOOTLE_OOPSIE) {
			g_propagate_error (error, _inner_error0_);
			_json_object_unref0 (obj);
			return NULL;
		} else {
			_json_object_unref0 (obj);
			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 NULL;
		}
	}
	_tmp15_ = json_gobject_deserialize (type, node);
	_tmp16_ = TOOTLE_IS_ENTITY (_tmp15_) ? ((TootleEntity*) _tmp15_) : NULL;
	if (_tmp16_ == NULL) {
		_g_object_unref0 (_tmp15_);
	}
	result = _tmp16_;
	_json_object_unref0 (obj);
	return result;
}

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

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

static gboolean
tootle_entity_real_deserialize_property (JsonSerializable* base,
                                         const gchar* prop,
                                         GValue* val,
                                         GParamSpec* spec,
                                         JsonNode* node)
{
	TootleEntity * self;
	GValue _vala_val = {0};
	gboolean success = FALSE;
	GValue _tmp0_ = {0};
	gboolean _tmp1_;
	GType type = 0UL;
	gboolean result = FALSE;
	self = (TootleEntity*) 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 = 0UL;
		const gchar* _tmp2_;
		GQuark _tmp4_ = 0U;
		static GQuark _tmp3_label0 = 0;
		static GQuark _tmp3_label1 = 0;
		static GQuark _tmp3_label2 = 0;
		static GQuark _tmp3_label3 = 0;
		static GQuark _tmp3_label4 = 0;
		static GQuark _tmp3_label5 = 0;
		GValue _tmp5_ = {0};
		gboolean _tmp6_;
		_tmp2_ = prop;
		_tmp4_ = (NULL == _tmp2_) ? 0 : g_quark_from_string (_tmp2_);
		if (_tmp4_ == ((0 != _tmp3_label0) ? _tmp3_label0 : (_tmp3_label0 = g_quark_from_static_string ("media-attachments")))) {
			switch (0) {
				default:
				{
					contains = TOOTLE_API_TYPE_ATTACHMENT;
					break;
				}
			}
		} else if (_tmp4_ == ((0 != _tmp3_label1) ? _tmp3_label1 : (_tmp3_label1 = g_quark_from_static_string ("mentions")))) {
			switch (0) {
				default:
				{
					contains = TOOTLE_API_TYPE_MENTION;
					break;
				}
			}
		} else if (_tmp4_ == ((0 != _tmp3_label2) ? _tmp3_label2 : (_tmp3_label2 = g_quark_from_static_string ("fields")))) {
			switch (0) {
				default:
				{
					contains = TOOTLE_API_TYPE_ACCOUNT_FIELD;
					break;
				}
			}
		} else if (_tmp4_ == ((0 != _tmp3_label3) ? _tmp3_label3 : (_tmp3_label3 = g_quark_from_static_string ("accounts")))) {
			switch (0) {
				default:
				{
					contains = TOOTLE_API_TYPE_ACCOUNT;
					break;
				}
			}
		} else if (_tmp4_ == ((0 != _tmp3_label4) ? _tmp3_label4 : (_tmp3_label4 = g_quark_from_static_string ("statuses")))) {
			switch (0) {
				default:
				{
					contains = TOOTLE_API_TYPE_STATUS;
					break;
				}
			}
		} else if (_tmp4_ == ((0 != _tmp3_label5) ? _tmp3_label5 : (_tmp3_label5 = g_quark_from_static_string ("hashtags")))) {
			switch (0) {
				default:
				{
					contains = TOOTLE_API_TYPE_TAG;
					break;
				}
			}
		} else {
			switch (0) {
				default:
				{
					contains = TOOTLE_TYPE_ENTITY;
					break;
				}
			}
		}
		_tmp6_ = tootle_entity_des_list (&_tmp5_, node, contains);
		G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
		_vala_val = _tmp5_;
		result = _tmp6_;
		if (val) {
			*val = _vala_val;
		} else {
			G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
		}
		return result;
	}
	result = success;
	if (val) {
		*val = _vala_val;
	} else {
		G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	}
	return result;
}

static Block20Data*
block20_data_ref (Block20Data* _data20_)
{
	g_atomic_int_inc (&_data20_->_ref_count_);
	return _data20_;
}

static void
block20_data_unref (void * _userdata_)
{
	Block20Data* _data20_;
	_data20_ = (Block20Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data20_->_ref_count_)) {
		g_slice_free (Block20Data, _data20_);
	}
}

static Block21Data*
block21_data_ref (Block21Data* _data21_)
{
	g_atomic_int_inc (&_data21_->_ref_count_);
	return _data21_;
}

static void
block21_data_unref (void * _userdata_)
{
	Block21Data* _data21_;
	_data21_ = (Block21Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data21_->_ref_count_)) {
		_g_object_unref0 (_data21_->arr);
		block20_data_unref (_data21_->_data20_);
		_data21_->_data20_ = NULL;
		g_slice_free (Block21Data, _data21_);
	}
}

static void
___lambda98_ (Block21Data* _data21_,
              JsonArray* array,
              guint i,
              JsonNode* elem)
{
	Block20Data* _data20_;
	TootleEntity* obj = NULL;
	TootleEntity* _tmp0_;
	GeeArrayList* _tmp1_;
	GError* _inner_error0_ = NULL;
	_data20_ = _data21_->_data20_;
	g_return_if_fail (array != NULL);
	g_return_if_fail (elem != NULL);
	_tmp0_ = tootle_entity_from_json (_data20_->type, elem, &_inner_error0_);
	obj = _tmp0_;
	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;
	}
	_tmp1_ = _data21_->arr;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, obj);
	_g_object_unref0 (obj);
}

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

static gboolean
tootle_entity_des_list (GValue* val,
                        JsonNode* node,
                        GType type)
{
	GValue _vala_val = {0};
	Block20Data* _data20_;
	gboolean result = FALSE;
	g_return_val_if_fail (node != NULL, FALSE);
	_data20_ = g_slice_new0 (Block20Data);
	_data20_->_ref_count_ = 1;
	_data20_->type = type;
	if (!json_node_is_null (node)) {
		Block21Data* _data21_;
		GeeArrayList* _tmp0_;
		JsonArray* _tmp1_;
		GeeArrayList* _tmp2_;
		GValue _tmp3_ = {0};
		_data21_ = g_slice_new0 (Block21Data);
		_data21_->_ref_count_ = 1;
		_data21_->_data20_ = block20_data_ref (_data20_);
		_tmp0_ = gee_array_list_new (TOOTLE_TYPE_ENTITY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_data21_->arr = _tmp0_;
		_tmp1_ = json_node_get_array (node);
		json_array_foreach_element (_tmp1_, ____lambda98__json_array_foreach, _data21_);
		_tmp2_ = _data21_->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_;
		block21_data_unref (_data21_);
		_data21_ = NULL;
	}
	result = TRUE;
	block20_data_unref (_data20_);
	_data20_ = NULL;
	if (val) {
		*val = _vala_val;
	} else {
		G_IS_VALUE (&_vala_val) ? (g_value_unset (&_vala_val), NULL) : NULL;
	}
	return result;
}

static JsonNode*
tootle_entity_real_serialize_property (JsonSerializable* base,
                                       const gchar* prop,
                                       GValue* val,
                                       GParamSpec* spec)
{
	TootleEntity * self;
	GType type = 0UL;
	GValue _tmp2_;
	JsonNode* _tmp3_;
	JsonNode* result = NULL;
	self = (TootleEntity*) 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_ = tootle_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 Block22Data*
block22_data_ref (Block22Data* _data22_)
{
	g_atomic_int_inc (&_data22_->_ref_count_);
	return _data22_;
}

static void
block22_data_unref (void * _userdata_)
{
	Block22Data* _data22_;
	_data22_ = (Block22Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data22_->_ref_count_)) {
		_json_array_unref0 (_data22_->arr);
		g_slice_free (Block22Data, _data22_);
	}
}

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
__lambda99_ (Block22Data* _data22_,
             TootleEntity* e)
{
	JsonNode* enode = NULL;
	JsonNode* _tmp0_;
	JsonArray* _tmp1_;
	JsonNode* _tmp2_;
	gboolean result = FALSE;
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = tootle_entity_to_json (e);
	enode = _tmp0_;
	_tmp1_ = _data22_->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
___lambda99__gee_forall_func (gpointer g,
                              gpointer self)
{
	gboolean result;
	result = __lambda99_ (self, (TootleEntity*) g);
	return result;
}

static JsonNode*
tootle_entity_ser_list (const gchar* prop,
                        GValue* val,
                        GParamSpec* spec)
{
	Block22Data* _data22_;
	GeeArrayList* list = NULL;
	GValue _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	JsonArray* _tmp4_;
	GeeArrayList* _tmp5_;
	JsonNode* node = NULL;
	JsonNode* _tmp6_;
	JsonNode* _tmp7_;
	JsonArray* _tmp8_;
	JsonNode* result = NULL;
	g_return_val_if_fail (prop != NULL, NULL);
	g_return_val_if_fail (val != NULL, NULL);
	g_return_val_if_fail (spec != NULL, NULL);
	_data22_ = g_slice_new0 (Block22Data);
	_data22_->_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);
		block22_data_unref (_data22_);
		_data22_ = NULL;
		return result;
	}
	_tmp4_ = json_array_new ();
	_data22_->arr = _tmp4_;
	_tmp5_ = list;
	gee_abstract_collection_foreach ((GeeAbstractCollection*) _tmp5_, ___lambda99__gee_forall_func, _data22_);
	_tmp6_ = json_node_new (JSON_NODE_ARRAY);
	node = _tmp6_;
	_tmp7_ = node;
	_tmp8_ = _data22_->arr;
	json_node_set_array (_tmp7_, _tmp8_);
	result = node;
	_g_object_unref0 (list);
	block22_data_unref (_data22_);
	_data22_ = NULL;
	return result;
}

TootleEntity*
tootle_entity_construct (GType object_type)
{
	TootleEntity * self = NULL;
	self = (TootleEntity*) g_object_new (object_type, NULL);
	return self;
}

TootleEntity*
tootle_entity_new (void)
{
	return tootle_entity_construct (TOOTLE_TYPE_ENTITY);
}

static void
tootle_entity_class_init (TootleEntityClass * klass,
                          gpointer klass_data)
{
	tootle_entity_parent_class = g_type_class_peek_parent (klass);
	((TootleEntityClass *) klass)->is_local = (gboolean (*) (TootleEntity*, TootleInstanceAccount*)) tootle_entity_real_is_local;
}

static void
tootle_entity_tootle_widgetizable_interface_init (TootleWidgetizableIface * iface,
                                                  gpointer iface_data)
{
	tootle_entity_tootle_widgetizable_parent_iface = g_type_interface_peek_parent (iface);
}

static void
tootle_entity_json_serializable_interface_init (JsonSerializableIface * iface,
                                                gpointer iface_data)
{
	tootle_entity_json_serializable_parent_iface = g_type_interface_peek_parent (iface);
	iface->find_property = (GParamSpec* (*) (JsonSerializable*, const gchar*)) tootle_entity_real_find_property;
	iface->deserialize_property = (gboolean (*) (JsonSerializable*, const gchar*, GValue*, GParamSpec*, JsonNode*)) tootle_entity_real_deserialize_property;
	iface->serialize_property = (JsonNode* (*) (JsonSerializable*, const gchar*, GValue*, GParamSpec*)) tootle_entity_real_serialize_property;
}

static void
tootle_entity_instance_init (TootleEntity * self,
                             gpointer klass)
{
}

static GType
tootle_entity_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleEntityClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_entity_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleEntity), 0, (GInstanceInitFunc) tootle_entity_instance_init, NULL };
	static const GInterfaceInfo tootle_widgetizable_info = { (GInterfaceInitFunc) tootle_entity_tootle_widgetizable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo json_serializable_info = { (GInterfaceInitFunc) tootle_entity_json_serializable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType tootle_entity_type_id;
	tootle_entity_type_id = g_type_register_static (G_TYPE_OBJECT, "TootleEntity", &g_define_type_info, 0);
	g_type_add_interface_static (tootle_entity_type_id, TOOTLE_TYPE_WIDGETIZABLE, &tootle_widgetizable_info);
	g_type_add_interface_static (tootle_entity_type_id, json_serializable_get_type (), &json_serializable_info);
	return tootle_entity_type_id;
}

GType
tootle_entity_get_type (void)
{
	static volatile gsize tootle_entity_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_entity_type_id__volatile)) {
		GType tootle_entity_type_id;
		tootle_entity_type_id = tootle_entity_get_type_once ();
		g_once_init_leave (&tootle_entity_type_id__volatile, tootle_entity_type_id);
	}
	return tootle_entity_type_id__volatile;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

