Most voted "generic" questions
Generics are a parametric form of polymorphism that allows instantiating classes where one or more of its attributes will have their types defined during the instantiation of this class.
Learn more…127 questions
Sort by count of
-
1
votes1
answer38
viewsdoubts generic class Asp.net mvc
Good night, In my project I have an application layer where the class is structured as follows: namespace ProjetoTreino.Aplicacao { public class PessoaAplicacao { private readonly…
-
1
votes1
answer121
viewsPassing a type created in Runtime for a statistical method
EDIT My problem is this. I need to generate a lambda expression that is of a type that I will only know at the time of execution, IE, the type to be used will be passed in the parameter classType of…
-
1
votes2
answers517
viewsUnderstanding the use of Generics in an abstract DAO Hibernate class
Hello, I am starting to develop a web application with spring+Hibernate framework, I started for an example that contained following class: import org.hibernate.Criteria; import…
-
1
votes1
answer79
viewsJava: Problems using lambda expressions in generic Listing method
The problem would be that I cannot multiply the variables that return from Listing using lambda (e*e), it keeps asking to create a Listing method using Object, but using Generics. I appreciate any…
-
1
votes0
answers99
viewshow does a function "const void *foo( param, param) work"?
bool cmp(const void * a, const void * b) { return static_cast < /*type?*/ * > a < static_cast < /*type?*/ * > b; } const void * min(const void * first, const void * last, size_t size,…
-
1
votes1
answer456
viewsCreating a new Object, and populating its properties, using Java Reflection
Hello, I need to invoke a method via reflection, Method.invoke(Objeto, arg); Object -> Object created from Class.newInstance() Arg -> is the value I want to pass. And I know it’s a String. But…
-
1
votes0
answers121
viewsHow to create a Generic method that takes any entity class, and starts a session in Hibernate?
Good night, I am trying to create a method that receives any entity class and an ID to start a session on Hibernate. The idea is to make a Generic DAO to take only the ID of the entities I want.…
-
1
votes1
answer68
viewsHow not to repeat the same code on an overload?
What would be correct technique not to repeat the same code for these two overloads or maybe not to have the overloads? It happens that sometimes I have to pass a parameter that is a string array…
-
1
votes1
answer50
viewsIs it possible to create a Java superclass for basic CRUD functions using spring framework?
While working recently on a project, I noticed that we have several classes with basic CRUD and repeating functions, their only differences, would be some parameters, responses and function calls in…
-
1
votes1
answer38
viewsI cannot create an iterator class with Ienumerable<T>
I’m creating an iterator class - has support for foreach - implementing the interface IEnumerable<T> package System.Collections.Generic, as in the code below: public class MyList<T> :…
-
0
votes1
answer42
viewsHow to implement generic data in this case?
I am using Ormlite in my application and want to implement a generic type in the following: public interface AdminDao extends Dao<T, Integer> { ... } where "T" would be the generic. Error:…
-
0
votes1
answer166
viewsProblem adding an element to a collection at runtime
In this my method I must fill a Collection, regardless of its type public void loadBeanCollectionItems(B bean, Collection collection, JSONArray collectionJson) { for(int index = 0; index <…
-
0
votes2
answers98
viewsHow to avoid code redundancy in these two methods, one having a Ienumerable<> parameter and the other not?
How can I simplify these two methods in order to prevent code repetition? Method 1, with the first expression having a generic property of type Ienumerable<>: public GenericDAO<TModel>…
-
0
votes1
answer256
viewsIs Generic stabbing possible?
Good afternoon I’m studying by object orientation, and in the middle of the studies appeared various patterns and with them a lot of confusion My doubt is it’s possible to have a generic FACADE. or…
-
0
votes0
answers34
viewsDoubt with Generics in Java
I have a class that uses generic type public abstract class AbstractDAO <T extends Entidade>{ //corpo da classe } At some point I need to know the class of T, the compiler does not accept to…
-
0
votes1
answer382
viewsTake a class that has a certain interface implemented in Generics
Hello. I want to do something like metodo(Class<? extends ClasseAbstrata> classe), only that of an abstract class, I want to use a interface, but I’ve moved on from extends for implements the…
-
0
votes1
answer88
viewsModify generic method to merge information into classes
I’m a first-time sailor with the Entityframework and I’m working with a class USUARIO who inherits from PESSOA. There are other classes like PESSOATIPO, PESSOAFISICA, PESSOAJURIDICA, etc., the…
-
0
votes1
answer60
viewsGeneric method for locating a specific value in several types of similar structures
public enum EXEMPLOENUMERADOR1 { blablabla1, blablabla2 } public enum EXEMPLOENUMERADOR2 { blablabla3, blablabla4, blablabla5} public enum EXEMPLOENUMERADOR3 { blablabla6, blablabla7, blablabla8,…
-
0
votes1
answer159
viewsVirtual method with Generic C#
I am creating a Base Form where I am not using it of type "Generic" due to problem with inheritance of forms in C# with the same. In this base form, I had the need to create a virtual method with…
-
0
votes2
answers127
viewsConvert class to generic
I need to convert the code class below into a generic implementation using a Arraylist. Can anyone suggest a better way to do this? Code: public class ArrayStack { private int maxsize; Retirar essas…
-
0
votes0
answers137
viewsHow to convert a JSON to a generic class
In a project with multiple client-server applications, I have a number of configuration files in JSON, which contain the connection port, host, etc. For each application, the information in JSON is…
-
0
votes1
answer121
viewsHow to make Generic with 2 C#classes
Good night, I’m having trouble using Generics in C#, I’m a programmer Java and I’m learning to use C#. I want to use Generics in a class in the package Service, I am implementing the class referring…
-
0
votes1
answer176
views -
0
votes2
answers263
viewsHow can I pass a parameter of any type to a generic vector? - C
I have a structure like TTabelaX, which is basically a table that I will store elements of any kind, ie I can create a table to store a type element TCarro, with plate and color, then I can use the…
-
0
votes0
answers56
viewsMethod inheritance Generic class comparet
I’m implementing a Node class where I wanted the equals and compareTo method to be inherited from type T, but I’m not getting it. If you make a statement like this public class Node<T extends…
-
-1
votes1
answer52
viewsProblem accessing concrete class methods using reference this in C#
I implemented a class Service abstract using Generics and another using EmpresaService being concrete. Every project structure for every concrete class has an abstract. My doubt seeing from the…
-
-2
votes0
answers27
viewsHow to create an interface or generic type for an object where all its properties are functions with different arguments in Typescript?
Let’s say I have these objects: const actionsPost = { likePost: (id: number) => dispatch({type: Actions.like, payload: {id}}), addPost: (title: string, body: string) => dispatch({type:…