Find a field of any of the specified types.
343774
def find_any_field(browser, field_types, field_name):
    

    return reduce(
        operator.add,
        (find_field(browser, field_type, field_name)
         for field_type in field_types)
    )
167923
def validate_field_matches_type(field, value, field_type, select_items=None, _min=None, _max=None):
    """"""
    if (field_type == defs.TEXT_TYPE and not isinstance(value, six.string_types)) or \
       (field_type == defs.STRING_TYPE and not isinstance(value, six.string_types)) or \
       (field_type == defs.BOOLEAN_TYPE and not isinstance(value, bool)) or \
       (field_type == defs.INTEGER_TYPE and not isinstance(value, int)):
        raise exceptions.ConfigFieldTypeMismatch(field, value, field_type)

    if field_type == defs.INTEGER_TYPE:
        if _min and value < _min:
            raise exceptions.ConfigFieldTypeMismatch(field, value, "must be higher than {}".format(_min))
        if _max and value > _max:
            raise exceptions.ConfigFieldTypeMismatch(field, value, "must be lower than {}".format(_max))

    if field_type == defs.SELECT_TYPE:
        from honeycomb.utils.plugin_utils import get_select_items
        items = get_select_items(select_items)
        if value not in items:
            raise exceptions.ConfigFieldTypeMismatch(field, value, "one of: {}".format(", ".join(items)))
46552
def selector(self, fieldname):
        """"""
        finder = self._finders[fieldname]
        return (finder._by, finder._selector)
854096
def field_type(field):
    
    if hasattr(field, 'field') and field.field:
        return field.field.__class__.__name__.lower()
    return ''
722590
def _build_field_type_map(base_class):
    """"""
    mapping = {}

    for cls in _get_recursive_subclasses(base_class):
        if cls.field_type:
            if isinstance(cls.field_type, tuple):
                for field_type in cls.field_type:
                    mapping[field_type] = cls
            elif isinstance(cls.field_type, _string_types):
                mapping[cls.field_type] = cls
            else:
                raise ValueError('Field type must be str or tuple, cannot understand type "{}" on class "{}"'.format(
                    type(cls.field_type),
                    cls
                ))

    return mapping
160025
public static Optional<Field> getField(Class<?> type, final String fieldName) {
        Optional<Field> field = Iterables.tryFind(newArrayList(type.getDeclaredFields()), havingFieldName(fieldName));

        if (!field.isPresent() && type.getSuperclass() != null){
            field = getField(type.getSuperclass(), fieldName);
        }

        return field;
    }
328930
def get_field_def(
    schema,  # type: GraphQLSchema
    parent_type,  # type: Union[GraphQLInterfaceType, GraphQLObjectType]
    field_ast,  # type: Field
):
    # type: (...) -> Optional[GraphQLField]
    """"""
    name = field_ast.name.value
    if name == "__schema" and schema.get_query_type() == parent_type:
        return SchemaMetaFieldDef

    elif name == "__type" and schema.get_query_type() == parent_type:
        return TypeMetaFieldDef

    elif name == "__typename" and isinstance(
        parent_type, (GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType)
    ):
        return TypeNameMetaFieldDef

    elif isinstance(parent_type, (GraphQLObjectType, GraphQLInterfaceType)):
        return parent_type.fields.get(name)
193429
def _read_field(self):
        '''
        
        '''
        ftype = self._input[self._pos]
        self._pos += 1

        reader = self.field_type_map.get(ftype)
        if reader:
            return reader(self)

        raise Reader.FieldError('Unknown field type %s', ftype)
1251159
def type(self):
        """"""
        if self.__type is None:
            found_type = find_definition(
                self.__type_name, self.message_definition())
            if not (found_type is not Enum and
                    isinstance(found_type, type) and
                    issubclass(found_type, Enum)):
                raise FieldDefinitionError(
                    'Invalid enum type: %s' % found_type)

            self.__type = found_type
        return self.__type
311825
public T findOne(DBObject query, DBObject fields) {
        return findOne(query, fields, getReadPreference());
    }
1232556
def match_type?(object)
            result = object.kind_of_any? self.type_classes
            if not result
                result = object.type_of_any? self.type_types
            end
            
            return result
        end
368758
private Function findField(String name) {
        Selection slkt;
        Function f;

        if (name.indexOf('.') == -1) {
            name = type.getName() + "." + name;
        }
        slkt = Method.forName(name);
        if (slkt.size() == 0) {
            f = Field.forName(name);
            if (f != null) {
                slkt = slkt.add(new Selection(f));
            }
        }
        slkt = slkt.restrictArgumentCount(1);
        slkt = slkt.restrictArgumentType(0, type);
        switch (slkt.size()) {
        case 0:
            throw new RuntimeException("no such field: " + name);
        case 1:
            return slkt.getFunction();
        default:
            throw new RuntimeException("ambiguous field: " + name);
        }
    }
48352
def parse_field(cls: Type[DocumentType], field_name: str, line: str) -> Any:
        
        try:
            match = cls.fields_parsers[field_name].match(line)
            if match is None:
                raise AttributeError
            value = match.group(1)
        except AttributeError:
            raise MalformedDocumentError(field_name)
        return value
617231
public static Class<?> getGenericTypeOfCollectionField(Field field) {
        Type genericType = field.getGenericType();

        if (!(genericType instanceof ParameterizedType)) {
            throw new IllegalArgumentException("Field is not a ParameterizedType.");
        }

        Type[] genericTypes = ((ParameterizedType) genericType).getActualTypeArguments();


        if (genericTypes.length != 1) {
            throw new IllegalArgumentException("Field does not have a single generic type.");
        }

        if (!(genericTypes[0] instanceof Class)) {
            throw new IllegalArgumentException("Field's generic type is not a class?");
        }

        return (Class<?>) genericTypes[0];
    }
576572
Optional<ExecutableElement> findSetterMethodFor(Element field) {
        String name = field.getSimpleName().toString();
        if (field.asType().getKind() == TypeKind.BOOLEAN) {
            if (name.length() > 2 && Character.isUpperCase(name.charAt(2))) {
                name = name.replaceFirst("^(is)(.+)", "$2");
            }
        }
        String setterName = setterNameFor(name);
        // FIXME refine this to discover one of possible overloaded methods with correct signature (i.e. single arg of field type)
        TypeElement typeElement = classElementFor(field);
        if (typeElement == null) {
            return Optional.empty();
        }

        List<? extends Element> elements = typeElement.getEnclosedElements();
        List<ExecutableElement> methods = ElementFilter.methodsIn(elements);
        return methods.stream()
            .filter(method -> {
                String methodName = method.getSimpleName().toString();
                if (setterName.equals(methodName)) {
                    Set<Modifier> modifiers = method.getModifiers();
                    return
                        // it's not static
                        !modifiers.contains(STATIC)
                            // it's either public or package visibility
                            && modifiers.contains(PUBLIC)
                            || !(modifiers.contains(PRIVATE) || modifiers.contains(PROTECTED));
                }
                return false;
            })
            .findFirst();
    }
1203738
def try_fields(cls, *names) -> t.Optional[t.Any]:
        """"""
        for name in names:
            if hasattr(cls, name):
                return getattr(cls, name)
        raise AttributeError((cls, names))
1255942
def datatype(dbtype, description, cursor):
    """"""
    dt = cursor.db.introspection.get_field_type(dbtype, description)
    if type(dt) is tuple:
        return dt[0]
    else:
        return dt