Category "generics"

Nestjs create Generic CRUD service

I want to create a base service using a generic class which I wrote below: import { BaseEntity } from './base.entity'; import { Repository } from 'typeorm'; e

Dart, Can't call Generic's method

I am trying to create an abstract data model where i pass data and type a and then is return list, but when i can't call T.fromJson() method, note that passes t

failed to produce diagnostic for expression, Xcode 11.4, Moya

After updating to Xcode 11.4, I started to get this error Failed to produce diagnostic for expression please file a bug report On: let provider = MoyaProvider

Java get generic type of static method at runtime

So I was reading through the source code of Collections.java, there is a generic method copy(). I simplified it to this: public static <T> void copy(List&

Unable to assign the result returned by the Method that receives a generic List and returns a List<?>

I'm trying to filter a List of objects that implements an interface. And I'm trying to create a generic method for all the classes. Something like: interface So

Avoiding generic class with many type parameters, when the consumer of those types are tightly coupled

I am trying to come up with a way to do this where I can have type safety but also loose coupling of a couple of different components in my class. I am running

Enforce providing <T> in Dart generic method

How can I enforce providing the generic type of a generic method in dart. By default, dart allows us to not provide a generic type at all. And this should be a

How to iterate over a union of slices passed in a generic function? (T has no core type)

I am testing out generics in go 1.18 and took a look at this example. I would like to recreate that example but instead be able to pass in a slice of int or sli

Go with Generics: type *T is pointer to type parameter, not type parameter

Probably a golang beginner's question :) I'm facing following compiler error when trying to compile the code below. I want to implement an object store for diff

How to add an entry with an Integer value into Map<String, ?>

I have to place an integer value into the map below. Map<String,?> map map.put("key",2000); When I run the above code I'm getting the following error: in

Dart Generics - type is not a subtype

I'm getting a runtime error from a Dart generic function: Widget card = widget.cardBuilder(item); Which generates: type '(Contact) => Widget' is not a

Jackson deserializer for generic type

I need to write a custom deserializer for a class with generics. I couldn't find a way to do this, however I cannot imagine I'm the only one with this problem.

C# check object type against multiple types

IS there a way to pass an array of types to the "is" operator? I am trying to simplify the syntax of checking an object against multiple types. Something like

Does Java have a similar post method diamond operator that C# has?

The Unity project makes frequent use of C# functions that supply a type in a diamond operator after the method name. In the Unity source code it's defined like

MapStruct - Map Generic List to Non-Generic List containing different types

I am attempting to use MapStruct to convert between 2 internal models. These models are generated from the same specification and represent a large tree-like st

Is it possible to inherit from class with Generic in Python?

Since Python 3.5 you can use Generics and other interesting stuff described in PEP-0484. I tried that and here's a code I have: from typing import TypeVar, Ge

Use generic in type alias

My type annotations I currently have look similar to the following, and I want to use an typing alias to not repeat myself so much: A class has class variables,

incompatible types: Myclass cannot be converted to CAP#1 where CAP#1 is a fresh type-variable:CAP#1 extends Myclass from capture of ? extends Myclass

In code I created user defined class Myclass and Myclass2 which extends Myclass and then used in ArrayList<? extends Myclass> as a arguments that means no

Generic function that returns different types based on the value of an argument

I have a struct which holds registers. I want my read_register function to return a u8 for Register::V0 and Register::V1 but a u16 for Register::V2 and Register

.Error CS1061 'Task<IEnumerable>' does not contain a definition for 'Where' and no accessible extension method 'Where'

My generic repository is as follows ( I have similar in synchronious and it works) public virtual async Task<IEnumerable<TEntity>> GetAsyn( Expr