Given a (FieldDescriptor, value) tuple from _fields, return true if the
  value should be included in the list returned by ListFields().
779840
def _IsPresent(item):
  """"""

  if item[0].label == _FieldDescriptor.LABEL_REPEATED:
    return bool(item[1])
  elif item[0].cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
    return item[1]._is_present_in_parent
  else:
    return True
349698
public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case TOPOLOGY:
      return is_set_topology();
    case COMPONENTS:
      return is_set_components();
    case TASKS:
      return is_set_tasks();
    case METRICS:
      return is_set_metrics();
    }
    throw new IllegalStateException();
  }
329448
public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case SERIALIZED_PARTS:
      return is_set_serialized_parts();
    }
    throw new IllegalStateException();
  }
910704
def values_list(self, *fields, **kwargs):
        
        flat = kwargs.pop('flat', False)
        if kwargs:
            raise TypeError('Unexpected keyword arguments to values_list: %s'
                            % (kwargs.keys(),))
        if flat and len(fields) > 1:
            raise TypeError("'flat' is not valid when values_list is called with more than one field.")
        clone = self.only(fields)
        clone._values_list = True
        clone._flat_values_list = flat
        return clone
548486
public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case VALUES:
      return isSetValues();
    case NULLS:
      return isSetNulls();
    }
    throw new IllegalStateException();
  }
827517
def _contains(expr, value):
    
    return composite_op(expr, ListContains, df_types.boolean, _value=_scalar(value))
1009246
protected function isFieldValueBeDerivableFromListParent($field)
    {
        if ( ! $this->hasActiveListParent()) {
            return false;
        }

        $listParentData = $this->getListParentDataForRelation($this->listParentRelation);

        if ( ! $listParentData) {
            return false;
        }

        return $field == $listParentData->field();
    }
864342
def _make_it_list(dict_, field_name, value):
    '''
    
    '''
    prev_value = []
    # firsly we'll collect the prev value
    if field_name in dict_:
        prev_value = dict_[field_name]
    if value is None:
        return prev_value
    elif isinstance(value, (tuple, list)):
        # other type of iterables
        if field_name in ('source_port', 'destination_port'):
            # port fields are more special
            # they can either be a list of integers, either a list of tuples
            # list of integers = a list of ports
            # list of tuples = a list of ranges,
            # e.g.: [(1000, 2000), (3000, 4000)] means the 1000-2000 and 3000-4000 ranges
            portval = []
            for port in value:
                if not isinstance(port, (tuple, list)):
                    # to make sure everything is consistent,
                    # we'll transform indivitual ports into tuples
                    # thus an individual port e.g. 1000 will be transormed into the port range 1000-1000
                    # which is the equivalent
                    # but assures consistency for the Capirca parser
                    portval.append((port, port))
                else:
                    portval.append(port)
            translated_portval = []
            # and the ports sent as string, e.g. ntp instead of 123
            # needs to be translated
            # again, using the same /etc/services
            for port_start, port_end in portval:
                if not isinstance(port_start, int):
                    port_start = _translate_port(port_start)
                if not isinstance(port_end, int):
                    port_end = _translate_port(port_end)
                translated_portval.append(
                    (port_start, port_end)
                )
            return list(set(prev_value + translated_portval))
        return list(set(prev_value + list(value)))
    if field_name in ('source_port', 'destination_port'):
        if not isinstance(value, int):
            value = _translate_port(value)
        return list(set(prev_value + [(value, value)]))  # a list of tuples
    # anything else will be enclosed in a list-type
    return list(set(prev_value + [value]))
367214
public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case KEY_TYPE_PTR:
      return isSetKeyTypePtr();
    case VALUE_TYPE_PTR:
      return isSetValueTypePtr();
    }
    throw new IllegalStateException();
  }
700017
private boolean isViewElementFindableOrList(Field field) {
        Class<?> fieldType = field.getType();
        return View.class.isAssignableFrom(fieldType)
                || Element.class.isAssignableFrom(fieldType)
                || Findable.class.isAssignableFrom(fieldType)
                || List.class.isAssignableFrom(fieldType);
    }
1223297
def hasField(cls, fieldName) :
        """"""
        path = fieldName.split(".")
        v = cls._fields
        for k in path :
            try :
                v = v[k]
            except KeyError :
                return False
        return True
829842
def is_named_tuple(cls):
    """"""
    b = cls.__bases__
    if len(b) != 1 or b[0] != tuple:
        return False
    f = getattr(cls, "_fields", None)
    if not isinstance(f, tuple):
        return False
    return all(type(n) == str for n in f)
1099000
private boolean appendList(StringBuilder builder, Object value)
    {
        boolean isPresent = false;
        if (value instanceof Collection)
        {
            Collection collection = ((Collection) value);
            isPresent = true;
            builder.append(Constants.OPEN_SQUARE_BRACKET);
            for (Object o : collection)
            {
                // Allowing null values.
                appendValue(builder, o != null ? o.getClass() : null, o, false);
                builder.append(Constants.COMMA);
            }
            if (!collection.isEmpty())
            {
                builder.deleteCharAt(builder.length() - 1);
            }
            builder.append(Constants.CLOSE_SQUARE_BRACKET);

        }
        else
        {
            appendValue(builder, value.getClass(), value, false);
        }
        return isPresent;
    }
475226
def validateField(cls, fieldName, value) :
        
        try :
            valValue = Collection.validateField(fieldName, value)
        except SchemaViolation as e:
            if fieldName == "_from" or fieldName == "_to" :
                return True
            else :
                raise e
        return valValue
927950
public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case TYPE:
      return isSetType();
    case TYPE_QUALIFIERS:
      return isSetTypeQualifiers();
    }
    throw new IllegalStateException();
  }
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
723201
def in_field(self, field_name, *field_vals, **field_kwargs):
        
        field_name = self._normalize_field_name(field_name)
        fv = make_list(field_vals[0]) if field_vals else None
        if field_kwargs:
            for k in field_kwargs:
                if not field_kwargs[k]:
                    raise ValueError("Cannot IN an empty list")

                field_kwargs[k] = make_list(field_kwargs[k])

        else:
            if not fv: self.can_get = False

        self.fields_where.append(field_name, ["in", field_name, fv, field_kwargs])
        return self