Returns default value of field if it has one.

    Args:
      field: A simple field.

    Returns:
      The default value of the field, if any exists, with the exception of an
          enum field, which will have its value cast to a string.
177974
def __parameter_default(self, field):
    
    if field.default:
      if isinstance(field, messages.EnumField):
        return field.default.name
      elif isinstance(field, messages.BooleanField):
        # The Python standard representation of a boolean value causes problems
        # when generating client code.
        return 'true' if field.default else 'false'
      else:
        return str(field.default)
462596
def initial_value(self, field_name: str = None):
        
        if self._meta.get_field(field_name).get_internal_type() == 'ForeignKey':
            if not field_name.endswith('_id'):
                field_name = field_name+'_id'

        attribute = self._diff_with_initial.get(field_name, None)

        if not attribute:
            return None

        return attribute[0]
1322134
def field_value(self, value):
        
        if not self.is_array:
            return self.field_type(value)

        if isinstance(value, (list, tuple, set)):
            return [self.field_type(item) for item in value]
        return self.field_type(value)
498095
def get_field_value(obj, field):
    
    if isinstance(field, DateTimeField):
        # DateTimeFields are timezone-aware, so we need to convert the field
        # to its naive form before we can accuratly compare them for changes.
        try:
            value = field.to_python(getattr(obj, field.name, None))
            if value is not None and settings.USE_TZ and not timezone.is_naive(value):
                value = timezone.make_naive(value, timezone=timezone.utc)
        except ObjectDoesNotExist:
            value = field.default if field.default is not NOT_PROVIDED else None
    else:
        try:
            value = smart_text(getattr(obj, field.name, None))
        except ObjectDoesNotExist:
            value = field.default if field.default is not NOT_PROVIDED else None

    return value
1227709
private static Fields toFieldEnum(Field field) {
        Class<?> clazz = field.getType();
        String name = clazz.getSimpleName().toLowerCase();

        if (name.equals("int") || name.equals("integer")) {
            return Fields.INT;
        } else if (name.equals("long")) {
            return Fields.LONG;
        } else if (name.equals("float")) {
            return Fields.FLOAT;
        } else if (name.equals("double")) {
            return Fields.DOUBLE;
        } else if (CharSequence.class.isAssignableFrom(clazz)) {
            return Fields.STRING;
        } else if (name.equals("boolean")) {
            return Fields.BOOLEAN;
        } else if (clazz.isAssignableFrom(List.class)) {
            ParameterizedType listType = (ParameterizedType) field.getGenericType();
            Class<?> listClass = (Class<?>) listType.getActualTypeArguments()[0];

            if (listClass.toString().equals("class java.lang.String")) {
                return Fields.LIST;
            }
        }

        throw new RuntimeException("Field not found!");
    }
419825
def _get_default_value(self, value):
        
        if isinstance(value, QueryExpression):
            return value

        if isinstance(value, bool):
            return "'%s'" % int(value)

        return "'%s'" % value
1055792
def get_field_info(self, field):
        
        field_info = collections.OrderedDict()
        field_info['type'] = self.label_lookup[field]
        field_info['required'] = getattr(field, 'required', False)

        attrs = [
            'read_only', 'label', 'help_text', 'allow_null',
            'min_length', 'max_length',
            'min_value', 'max_value',
        ]

        # Handle default attribute
        default_value = getattr(field, 'default')
        if (default_value is not empty):
            field_info['default'] = force_text(
                default_value, strings_only=True)

        for attr in attrs:
            value = getattr(field, attr, None)
            if value is not None and value != '':
                field_info[attr] = force_text(value, strings_only=True)

        if hasattr(field, 'choices'):
            field_info['choices'] = [
                {
                    'value': choice_value,
                    'display_name': force_text(choice_name, strings_only=True)
                }
                for choice_value, choice_name in field.choices.items()
            ]

        # handle RegexField
        if isinstance(field, serializers.RegexField):
            pattern = None
            for validator in field.validators:
                if isinstance(validator, RegexValidator):
                    pattern = validator.regex.pattern
                    break
            field_info['pattern'] = force_text(pattern, strings_only=True)

        # handle DecimalField
        if isinstance(field, serializers.DecimalField):
            for attr in ('max_digits', 'decimal_places'):
                field_info[attr] = force_text(
                    getattr(field, attr), strings_only=True)

        return field_info
187291
def getheader(self, field, default=''):
        
        if self.headers:
            for header in self.headers:
                if field.lower() == header.lower():
                    return self.headers[header]

        return default
637292
def normalize_field(self, value):
        
        if self.default is not None:
            if value is None or value == '':
                value = self.default
        return value
928092
def get_default_value(self):
        
        if ('default_value' in self.attributes and
                bool(self.attributes['default_value'].strip())):
            return self.attributes['default_value']
        else:
            return None
985274
def default(self, value):
        
        if isinstance(value, uuid.UUID):
            return str(value)
        elif isinstance(value, datetime.datetime):
            return value.isoformat()
        elif callable(value):
            return str(value)
        return json.JSONEncoder.default(self, value)
205032
def default(self):
        
        if isinstance(self.__default, (str, unicode)):
            return self.valueFromString(self.__default)
        else:
            return self.__default
700779
public boolean retrieveField(BaseField field)
    {
        String strFieldName = field.getFieldName();   // Fieldname only
        String strData = (String)this.getProperty(strFieldName);
        boolean bFound = false;
        if (strData != null)
        {
            field.setString(strData, DBConstants.DISPLAY, DBConstants.INIT_MOVE);
            bFound = true;
        }
        return bFound;
    }
563133
def default_value(self):
        
        if self.has_default:
            if hasattr(self.default, '__call__'):
                return self.default()
            else:
                return self.default
        else:
            raise Exception("No default value specified")
1088031
def values(self, *fields):
        
        if not fields:
            fields = self._get_simple_fields()

        fields = self._coerce_fields_parameters(fields)

        self._instances = False
        self._values = {'fields': fields, 'mode': 'dicts'}
        return self
446265
def get_value(self, field):
        '''
        
        '''
        if field not in self._field_generators:
            self._field_generators[field] = self.get_generator(field)
        generator = self._field_generators[field]
        if generator is None:
            return self.IGNORE_FIELD
        value = generator()
        return value
28423
def __parameter_default(self, field):
    
    if field.default:
      if isinstance(field, messages.EnumField):
        return field.default.name
      else:
        return field.default