fn tuple_deserializer(&self,
                          fields: &Vec<m::JavaField>,
                          class_type: &ClassType)
                          -> Result<ClassSpec> {
        let mut deserializer = ClassSpec::new(mods![Modifier::Public, Modifier::Static],
                                              "Deserializer");

        deserializer.extends(self.deserializer.with_arguments(vec![&class_type]));

        let parser = ArgumentSpec::new(mods![Modifier::Final], &self.parser, "parser");
        let ctxt = ArgumentSpec::new(mods![Modifier::Final],
                                     &self.deserialization_context,
                                     "ctxt");

        let mut deserialize = MethodSpec::new(mods![Modifier::Public], "deserialize");
        deserialize.throws(&self.io_exception);
        deserialize.push_argument(&parser);
        deserialize.push_argument(&ctxt);
        deserialize.push_annotation(&self.override_);
        deserialize.returns(&class_type);

        let current_token = stmt![&parser, ".getCurrentToken()"];

        let mut start_array = Elements::new();
        start_array.push(stmt!["if (", &current_token, " != ", &self.token, ".START_ARRAY) {"]);
        start_array.push_nested(self.wrong_token_exception(&ctxt, &parser, "START_ARRAY"));
        start_array.push("}");
        deserialize.push(start_array);

        let mut arguments = Statement::new();

        for field in fields {
            let (token, reader) = self.deserialize_method_for_type(&field.ty, &parser)?;

            if let Some((test, expected)) = token {
                let mut field_check = Elements::new();
                field_check.push(stmt!["if (", &test, ") {"]);
                field_check.push_nested(self.wrong_token_exception(&ctxt, &parser, expected));
                field_check.push("}");
                deserialize.push(field_check);
            }

            let variable = stmt!["v_", &field.spec.name];
            let assign = stmt!["final ", &field.spec.ty, " ", &variable, " = ", reader, ";"];
            deserialize.push(assign);
            arguments.push(variable);
        }

        let next_token = stmt![&parser, ".nextToken()"];

        let mut end_array = Elements::new();
        end_array.push(stmt!["if (", &next_token, " != ", &self.token, ".END_ARRAY) {"]);
        end_array.push_nested(self.wrong_token_exception(&ctxt, &parser, "END_ARRAY"));
        end_array.push("}");
        deserialize.push(end_array);

        deserialize.push(stmt!["return new ", &class_type, "(", arguments.join(", "), ");"]);

        deserializer.push(deserialize);
        Ok(deserializer)
    }
/// Custom deserialize implementation for tuples.
Custom deserialize implementation for tuples.
Custom deserialize implementation for tuples .
fn tuple_deserializer(&self,
                          fields: &Vec<m::JavaField>,
                          class_type: &ClassType)
                          -> Result<ClassSpec> {
        let mut deserializer = ClassSpec::new(mods![Modifier::Public, Modifier::Static],
                                              "Deserializer");
        deserializer.extends(self.deserializer.with_arguments(vec![&class_type]));
        let parser = ArgumentSpec::new(mods![Modifier::Final], &self.parser, "parser");
        let ctxt = ArgumentSpec::new(mods![Modifier::Final],
                                     &self.deserialization_context,
                                     "ctxt");
        let mut deserialize = MethodSpec::new(mods![Modifier::Public], "deserialize");
        deserialize.throws(&self.io_exception);
        deserialize.push_argument(&parser);
        deserialize.push_argument(&ctxt);
        deserialize.push_annotation(&self.override_);
        deserialize.returns(&class_type);
        let current_token = stmt![&parser, ".getCurrentToken()"];
        let mut start_array = Elements::new();
        start_array.push(stmt!["if (", &current_token, " != ", &self.token, ".START_ARRAY) {"]);
        start_array.push_nested(self.wrong_token_exception(&ctxt, &parser, "START_ARRAY"));
        start_array.push("}");
        deserialize.push(start_array);
        let mut arguments = Statement::new();
        for field in fields {
            let (token, reader) = self.deserialize_method_for_type(&field.ty, &parser)?;
            if let Some((test, expected)) = token {
                let mut field_check = Elements::new();
                field_check.push(stmt!["if (", &test, ") {"]);
                field_check.push_nested(self.wrong_token_exception(&ctxt, &parser, expected));
                field_check.push("}");
                deserialize.push(field_check);
            }
            let variable = stmt!["v_", &field.spec.name];
            let assign = stmt!["final ", &field.spec.ty, " ", &variable, " = ", reader, ";"];
            deserialize.push(assign);
            arguments.push(variable);
        }
        let next_token = stmt![&parser, ".nextToken()"];
        let mut end_array = Elements::new();
        end_array.push(stmt!["if (", &next_token, " != ", &self.token, ".END_ARRAY) {"]);
        end_array.push_nested(self.wrong_token_exception(&ctxt, &parser, "END_ARRAY"));
        end_array.push("}");
        deserialize.push(end_array);
        deserialize.push(stmt!["return new ", &class_type, "(", arguments.join(", "), ");"]);
        deserializer.push(deserialize);
        Ok(deserializer)
    }
fn tuple_deserializer ( & self , fields : & Vec < m :: JavaField > , class_type : & ClassType ) -> Result < ClassSpec > { let mut deserializer = ClassSpec :: new ( mods ! [ Modifier Public Modifier Static ] , " " ) ; deserializer . extends ( self . deserializer . with_arguments ( vec ! [ class_type ] ) ) ; let parser = ArgumentSpec :: new ( mods ! [ Modifier Final ] , & self . parser , " " ) ; let ctxt = ArgumentSpec :: new ( mods ! [ Modifier Final ] , & self . deserialization_context , " " ) ; let mut deserialize = MethodSpec :: new ( mods ! [ Modifier Public ] , " " ) ; deserialize . throws ( & self . io_exception ) ; deserialize . push_argument ( & parser ) ; deserialize . push_argument ( & ctxt ) ; deserialize . push_annotation ( & self . override_ ) ; deserialize . returns ( & class_type ) ; let current_token = stmt ! [ parser " " ] ; let mut start_array = Elements :: new ( ) ; start_array . push ( stmt ! [ " " current_token " " self token " " ] ) ; start_array . push_nested ( self . wrong_token_exception ( & ctxt , & parser , " " ) ) ; start_array . push ( " " ) ; deserialize . push ( start_array ) ; let mut arguments = Statement :: new ( ) ; for field in fields { let ( token , reader ) = self . deserialize_method_for_type ( & field . ty , & parser ) ? ; if let Some ( ( test , expected ) ) = token { let mut field_check = Elements :: new ( ) ; field_check . push ( stmt ! [ " " test " " ] ) ; field_check . push_nested ( self . wrong_token_exception ( & ctxt , & parser , expected ) ) ; field_check . push ( " " ) ; deserialize . push ( field_check ) ; } let variable = stmt ! [ " " field spec name ] ; let assign = stmt ! [ " " field spec ty " " variable " " reader " " ] ; deserialize . push ( assign ) ; arguments . push ( variable ) ; } let next_token = stmt ! [ parser " " ] ; let mut end_array = Elements :: new ( ) ; end_array . push ( stmt ! [ " " next_token " " self token " " ] ) ; end_array . push_nested ( self . wrong_token_exception ( & ctxt , & parser , " " ) ) ; end_array . push ( " " ) ; deserialize . push ( end_array ) ; deserialize . push ( stmt ! [ " " class_type " " arguments join ( " " ) " " ] ) ; deserializer . push ( deserialize ) ; Ok ( deserializer ) }
Custom deserialize implementation for tuples.
Custom deserialize implementation for tuples .
&self
fields
&Vec<m::JavaField>
class_type
&ClassType
&self
fields
&Vec<m::JavaField>
class_type
&ClassType