This descriptor acts as a Field, as far as the serializer is concerned.
965373
def value_to_string(self, obj):
        """"""
        try:
            return force_unicode(self.__get__(obj))
        except TypeError:
            return str(self.__get__(obj))
1161448
@Override
    public R visitSerialField(SerialFieldTree node, P p) {
        R r = scan(node.getName(), p);
        r = scanAndReduce(node.getType(), p, r);
        r = scanAndReduce(node.getDescription(), p, r);
        return r;
    }
130864
def visit_field_class(self, item, descriptor=None, fields=None):
        """"""
        discovered_fields = collections.OrderedDict()
        field_groups = {}
        for node in item.body:
            if isinstance(node, ast.ClassDef):
                field_groups[node.name] = self.visit_field_class(node)
                continue

            if not isinstance(node, ast.Assign):
                continue
            if not isinstance(node.value, ast.Call):
                continue
            if not isinstance(node.targets[0], ast.Name):
                continue

            # Build accessible symbols table.
            symtable = {}
            # All field types.
            symtable.update({
                field.__name__: field
                for field in get_available_fields()
            })
            # Field group classes.
            symtable.update(field_groups)

            evaluator = SafeEvaluator(symtable=symtable)

            name = node.targets[0].id
            try:
                field = evaluator.run(node.value)
            except Exception as ex:
                # TODO: Handle errors.
                raise ex

            if descriptor is not None:
                field.contribute_to_class(descriptor, fields, name)
            else:
                discovered_fields[name] = field

        if descriptor is None:
            class Fields:
                """Fields wrapper."""

            for name, field in discovered_fields.items():
                setattr(Fields, name, field)

            return Fields
1017114
private void evaluateObject() {
        if (evaluatedClasses.contains(clazz)) {
            return;
        }

        Field[] fields = clazz.getDeclaredFields();

        for (Field field : fields) {
            if (field.isAnnotationPresent(ModelField.class)
            && !isAllowed(field)) {
                throw new RuntimeException("Field '"
                        + field.getName()
                        + "' has type '" + field.getType().getSimpleName()
                        + "' that is not allowed!");
            }
        }

        evaluatedClasses.add(clazz);
    }
1230612
private void handleSerialFactory()
    {

        String serialProvider = _externalContext.getInitParameter(StateUtils.SERIAL_FACTORY);
        SerialFactory serialFactory = null;

        if (serialProvider == null)
        {
            serialFactory = new DefaultSerialFactory();
        }
        else
        {
            try
            {
                serialFactory = (SerialFactory) ClassUtils.newInstance(serialProvider);

            }
            catch (ClassCastException e)
            {
                log.log(Level.SEVERE, "Make sure '" + serialProvider + "' implements the correct interface", e);
            }
            catch (Exception e)
            {
                log.log(Level.SEVERE, "", e);
            }
            finally
            {
                if (serialFactory == null)
                {
                    serialFactory = new DefaultSerialFactory();
                    log.severe("Using default serialization provider");
                }
            }

        }

        log.info("Serialization provider : " + serialFactory.getClass());
        _externalContext.getApplicationMap().put(StateUtils.SERIAL_FACTORY, serialFactory);
    }
14295
def serialize(self, *fields):
        
        if fields:
            if not set(fields).issubset(self.data_nodes):
                raise SchemaError('Invalid field for serialization: {}'.format(set(fields).difference(self.data_nodes)))

            return OrderedDict([(k, getattr(self, k)) for k in fields])

        return OrderedDict([(k, getattr(self, k)) for k in self.data_nodes])
658657
def serialize(self, obj, fields):
        

        data = {}
        remaining_fields = []
        for field in fields:
            if callable(field):  # Callable
                data[field.__name__] = field(obj)
            elif hasattr(self, field) and callable(getattr(self, field)):  # Method on the view
                data[field] = getattr(self, field)(obj)
            elif hasattr(obj, field):  # Callable/property/field on the model
                attr = getattr(obj, field)
                if isinstance(attr, Model):
                    data[field] = attr.pk
                elif isinstance(attr, Manager):
                    data[field] = [item['pk'] for item in attr.values('pk')]
                elif callable(attr):  # Callable on the model
                    data[field] = attr()
                else:
                    remaining_fields.append(field)
            else:
                raise AttributeError('Invalid field: %s' % field)

        # Add on db fields
        serializer = Serializer()
        serializer.serialize([obj], fields=list(remaining_fields))
        data.update(serializer.getvalue()[0]['fields'])

        # Any remaining fields should be properties on the model
        remaining_fields = set(remaining_fields) - set(data.keys())

        for field in remaining_fields:
            data[field] = getattr(obj, field)

        return data
1227699
private final void serializeObjectNoSCO(Object v, ZooFieldDef def) {
        // Write class/null info
        if (v == null) {
            writeClassInfo(null, null);
            out.skipWrite(def.getLength()-1);
            if (def.isString()) {
            	scos.add(null);
                return;
            }
            return;
        }
        
        //Persistent capable objects do not need to be serialized here.
        //If they should be serialized, then it will happen in serializeFields()
        Class<? extends Object> cls = v.getClass();
        writeClassInfo(cls, v);

        if (isPersistentCapable(cls)) {
            serializeOid((ZooPC) v);
            return;
        } else if (String.class == cls) {
        	scos.add(v);
        	String s = (String)v; 
        	out.writeLong(BitTools.toSortableLong(s));
            return;
        } else if (Date.class == cls) {
            out.writeLong(((Date) v).getTime());
            return;
        } else if (GenericObject.class.isAssignableFrom(cls)) {
        	serializeOid((GenericObject)v);
        	return;
        } else if (GOProxy.class.isAssignableFrom(cls)) {
        	serializeOid(((GOProxy)v).getGenericObject());
        	return;
        }
        
        throw new IllegalArgumentException("Illegal class: " + cls + " from " + def);
    }
899690
public <T> void serialize(SerializerContext serializerContext, ElementDescriptor<T> descriptor, T rootObject) throws SerializerException, IOException
	{
		serializerContext.serializer.startDocument(null, null);
		useNamespace(serializerContext, descriptor.qualifiedName);
		bindNamespaces(serializerContext);
		mChildWriter.writeChild(descriptor, rootObject, serializerContext);
		serializerContext.serializer.endDocument();
	}
688380
def field(self, name, fieldType="C", size="50", decimal=0):
        """"""
        if fieldType == "D":
            size = "8"
            decimal = 0
        elif fieldType == "L":
            size = "1"
            decimal = 0
        if len(self.fields) >= 2046:
            raise ShapefileException(
                "Shapefile Writer reached maximum number of fields: 2046.")
        self.fields.append((name, fieldType, size, decimal))
22772
def serialize(self, obj, fields=None, exclude=None, **options):
        
        options = _merge({}, self.options, options)

        # Handle model instances
        if isinstance(obj, models.Model):
            fields = parse_selectors(obj.__class__, fields, exclude, **options)
            return model_to_dict(obj, fields=fields, **options)

        # Handle querysets
        if isinstance(obj, QuerySet):
            fields = parse_selectors(obj.model, fields, exclude, **options)
            return queryset_to_list(obj, fields=fields, **options)

        # Handle dict instances
        if isinstance(obj, dict):
            exclude = exclude or []
            if not fields:
                fields = iter(obj.keys())
            fields = [x for x in fields if x not in exclude]
            return model_to_dict(obj, fields=fields, **options)

        # Handle other iterables
        if hasattr(obj, '__iter__'):
            return [self.serialize(x, fields, exclude, **options) for x in obj]

        return obj
634590
def _fields_to_object(descriptor, fields):
    ''
    # pylint: disable=protected-access
    obj = descriptor._concrete_class()

    for name, value in fields:
        if isinstance(value, tuple):
            subtype = descriptor.fields_by_name[name].message_type
            value = _fields_to_object(subtype, value)
        _assign_to_field(obj, name, value)

    return obj
565684
private final void serializeObjectNoSCO(Object v, ZooFieldDef def) {
        // Write class/null info
        if (v == null) {
            writeClassInfo(null, null);
            return;
        }
        
        //Persistent capable objects do not need to be serialized here.
        //If they should be serialized, then it will happen in serializeFields()
        Class<? extends Object> cls = v.getClass();
        writeClassInfo(cls, v);

        if (isPersistentCapable(cls)) {
            serializeOid(v);
            return;
        } else if (String.class == cls) {
        	String s = (String)v; 
        	out.writeString(s);
            return;
        } else if (Date.class == cls) {
            out.writeLong(((Date) v).getTime());
            return;
        } else if (GenericObject.class == cls) {
        	serializeOidGo((GenericObject) v);
        	return;
        }
        
        throw new IllegalArgumentException("Illegal class: " + cls + " from " + def);
    }
66635
@SuppressWarnings("unchecked") // bla bla, we know what we are doing here...
    @JsonProperty("definitions")
    private void deserializeDefinitionsField(Map<String, Object> defs) {
        definitionsBean = new JsonGouldiDefinitionsBean();
        LinkedList<JsonGouldiIdentifierDefinienBean> list = new LinkedList<>();
        definitionsBean.setIdentifierDefiniens(list);

        for (String key : defs.keySet()) {
            JsonGouldiIdentifierDefinienBean bean = new JsonGouldiIdentifierDefinienBean();
            ArrayList<JsonGouldiWikidataDefinienBean> arrList = new ArrayList<>();
            bean.setName(key);

            ArrayList<Object> identifierList = (ArrayList<Object>) defs.get(key);
            for (Object obj : identifierList) {
                if (obj instanceof String) {
                    JsonGouldiTextDefinienBean textBean = new JsonGouldiTextDefinienBean();
                    textBean.setDiscription((String) obj);
                    arrList.add(textBean);
                } else {
                    Map<String, String> qidMappings = (Map<String, String>) obj;
                    for (String qID : qidMappings.keySet()) {
                        JsonGouldiWikidataDefinienBean wikidefbean = new JsonGouldiWikidataDefinienBean();
                        wikidefbean.setWikiID(qID);
                        wikidefbean.setDiscription(qidMappings.get(qID));
                        arrList.add(wikidefbean);
                    }
                }
            }

            JsonGouldiWikidataDefinienBean[] arr = new JsonGouldiWikidataDefinienBean[arrList.size()];
            arr = arrList.toArray(arr);
            bean.setDefiniens(arr);
            list.add(bean);
        }
    }
958153
def _assign_to_field(obj, name, val):
    ''
    target = getattr(obj, name)

    if isinstance(target, containers.RepeatedScalarFieldContainer):
        target.append(val)
    elif isinstance(target, containers.RepeatedCompositeFieldContainer):
        target = target.add()
        target.CopyFrom(val)
    elif isinstance(target, (int, float, bool, str, bytes)):
        setattr(obj, name, val)
    elif isinstance(target, message.Message):
        target.CopyFrom(val)
    else:
        raise RuntimeError("Unsupported type: {}".format(type(target)))
1081582
def serialised( self ):
        """"""
        klass = self.__class__
        return ((klass.__module__, klass.__name__), tuple( (name, field.serialise( self._field_data[name], parent=self ) ) for name, field in klass._fields.items()))
1084022
def _deserialize(cls, key, value, fields):
        
        converter = cls._get_converter_for_field(key, None, fields)
        return converter.deserialize(value)