Gets an instance implementing type <_type>
486203
def _get_a(self, _type):
        
        tmp = self._get_all(_type)
        ret = pick(tmp)
        if len(tmp) != 1:
            self.l.warn(("get_a: %s all implement %s; " +
                         "picking %s") % (tmp, _type, ret))
        return ret
1025093
def _get_by_type(self, key, operation, create, type_, default, return_default=True):
        
        key = self._encode(key)
        if self.type(key) in [type_, b'none']:
            if create:
                return self.redis.setdefault(key, default)
            else:
                return self.redis.get(key, default if return_default else None)

        raise TypeError("{} requires a {}".format(operation, type_))
1252941
private <T> T getInstance(DatastoreType datastoreType, TransactionalCache.Mode cacheMode) {
        DatastoreId id = getDatastoreId(datastoreType);
        Object instance = cache.get(id, cacheMode);
        if (instance == null) {
            DynamicType<?> types = getTypes(datastoreType);
            instance = newInstance(id, datastoreType, types, cacheMode);
            if (TransactionalCache.Mode.READ.equals(cacheMode)) {
                instanceListenerService.postLoad(instance);
            }
        }
        return (T) instance;
    }
96084
private <T> Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> prepareExample(Example<T> example, Class<?> type, Class<?>... types) {
        Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> exampleEntity = new HashMap<>();
        ExampleProxyMethodService<T> proxyMethodService = (ExampleProxyMethodService<T>) exampleProxyMethodServices.get(type);
        if (proxyMethodService == null) {
            proxyMethodService = new ExampleProxyMethodService(type, sessionContext);
            exampleProxyMethodServices.put(type, proxyMethodService);
        }
        InstanceInvocationHandler invocationHandler = new InstanceInvocationHandler(exampleEntity, proxyMethodService);
        List<Class<?>> effectiveTypes = new ArrayList<>(types.length + 1);
        effectiveTypes.add(type);
        effectiveTypes.addAll(Arrays.asList(types));
        CompositeType compositeType = CompositeTypeBuilder.create(CompositeObject.class, type, types);
        T instance = sessionContext.getProxyFactory().createInstance(invocationHandler, compositeType);
        example.prepare(instance);
        return exampleEntity;
    }
387680
@SuppressWarnings("unchecked")
  public static <T> TypeLiteral<T> get(Class<T> type, Type... parameters) {
    return (TypeLiteral<T>) TypeLiteral.get(new ParameterizedTypeImpl(type, parameters));
  }
1313666
public static TupleTypeEnum getInstance(String type) {
        if (type.equals(ITEM.type))
            return ITEM;
        else if (type.equals(ITEM_REFERENCE.type))
            return ITEM_REFERENCE;
        else if (type.equals(ITEM_STREAM.type))
            return ITEM_STREAM;
        else if (type.equals(REFERENCE_STREAM.type))
            return REFERENCE_STREAM;
        else if (type.equals(ROOT.type))
            return ROOT;
        else
            throw new IllegalArgumentException(nls.getFormattedMessage("INVALID_TUPLE_TYPE_SIMS1502",
                                                                       new Object[] {type},
                                                                       null));
    }
1261426
def of_type(cls, iterable, types):
    

    return cls(x for x in iterable if isinstance(x, types))
702751
def got_a(self, _type):
        
        if _type not in self.modules:
            raise ValueError("No such module, %s" % _type)
        return (_type in self.insts_implementing and
                self.insts_implementing[_type])
618652
public Object getInstance() {
        try {
            if (prototype) {
                return doGetInstance();
                
            } else {
                synchronized (cache) {
                    if (!cache.containsKey(type)) {
                        cache.put(type, doGetInstance());
                    }
                    
                    return cache.get(type);
                }
            }
            
        } catch (IrohException e) {
            throw e;
            
        } catch (Exception e) {
            throw new FailedConstructionException(e);
        }
    }
483213
def type
      if indirect_type
        ret = indirect_type.clone
        ret.direct_type = declaration.type.clone
        return ret
      else
        declaration.type.clone
      end
    end
354903
def type
            name = (self.class.name or self.class.superclass.name or self.native_type.name)

            name.split("::").last.to_sym
        end
527932
@SuppressWarnings("unchecked")
	public static <T> List<T> getInstanceList(Class<T> type) {
		if (type == null) {
			throw new IllegalArgumentException("Type should not be empty");
		}

		List<T> loader = (List<T>) EXTENSION_LOCATOR.get(type);
		if (loader == null) {
			try {
				lock.lock();
				List<T> instanceList = new ArrayList<T>();
				ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
				for (T service : serviceLoader) {
					instanceList.add(service);
				}
				loader = instanceList;
				if (EXTENSION_LOCATOR.putIfAbsent(type, instanceList) != instanceList) {
					loader = (List<T>) EXTENSION_LOCATOR.get(type);
				}
			} catch (Exception e) {
				LOG.error("Error to load SPI instances from META-INF/services/" + type, e);
			} finally {
				lock.unlock();
			}
		}
		return loader;
	}
281811
public static ContentType getInstance(String type)
    {
        if(type.equals(TEST.toString()))
        {
            return TEST;
        }
        else if(type.equals(REQUIREMENT.toString()))
        {
            return REQUIREMENT;
        }
        else if(type.equals(BOTH.toString()))
        {
            return BOTH;
        }

        return UNKNOWN;
    }
188964
def _get_types(func, clsm, slf, clss = None, prop_getter = False,
            unspecified_type = Any, infer_defaults = None):
    
    func0 = util._actualfunc(func, prop_getter)
    # check consistency regarding special case with 'self'-keyword
    if not slf:
        argNames = util.getargnames(util.getargspecs(func0))
        if len(argNames) > 0:
            if clsm:
                if argNames[0] != 'cls':
                    util._warn_argname('classmethod using non-idiomatic cls argname',
                            func0, slf, clsm, clss)
    if clss is None and (slf or clsm):
        if slf:
            assert util.is_method(func) or isinstance(func, property)
        if clsm:
            assert util.is_classmethod(func)
        clss = util.get_class_that_defined_method(func)
        assert hasattr(clss, func.__name__)
    args, res = _funcsigtypes(func, slf or clsm, clss, None, prop_getter,
            unspecified_type = unspecified_type, infer_defaults = infer_defaults)
    return _match_stub_type(args), _match_stub_type(res)
339948
@SuppressWarnings({"ConstantConditions"})
    private Pair<Class<?>, Class<?>[]> getGenericTypePair(Type type) {
        if (ParameterizedType.class.isAssignableFrom(type.getClass())) {
            Class<?>[] optionalValueTypes = null;

            @SuppressWarnings({"ConstantConditions"})
            ParameterizedType ptype = (ParameterizedType) type;

            if (Map.class.isAssignableFrom((Class<?>) ptype.getRawType())) {
                optionalValueTypes = new Class<?>[] { (Class<?>) ptype.getActualTypeArguments()[0],
                                                      (Class<?>) ptype.getActualTypeArguments()[1] };
            } else if (Iterable.class.isAssignableFrom((Class<?>) ptype.getRawType())) {
                optionalValueTypes = new Class<?>[] { (Class<?>) ptype.getActualTypeArguments()[0] };
            }

            return new Pair<Class<?>, Class<?>[]>((Class<?>) ptype.getRawType(), optionalValueTypes);
        } else {
            return new Pair<Class<?>, Class<?>[]>((Class<?>) type, new Class<?>[]{});
        }
    }
542346
def instanceOf(cls, expected_instance): #pylint: disable=no-self-argument,invalid-name,no-self-use
        
        if not inspect.isclass(expected_instance):
            options = {}
            options["target_type"] = expected_instance
            return Matcher("__INSTANCE__", options)
        ErrorHandler.matcher_instance_error(expected_instance)
604512
def get_types(func):
    
    return _get_types(func, util.is_classmethod(func), util.is_method(func))