Questions tagged [parameterized-types]

72 questions
3
votes
2 answers

java stream return array of parameterized class

Situation: public class P { public static Predicate isEqual(double value) { return p -> (Math.abs(p - value) <= 0.000001); } } public class Entity { private double[] values; public double getValue(int index) { …
evgenii ershenko
  • 427
  • 5
  • 13
3
votes
3 answers

Why Java has so many parse methods?

For example the Math.max( .. .. ) method is overloaded to support different types of Number. One name for all of them because, no mather the type of Number, it does the same thing. So does the parseNumberType methods defined for each class…
3
votes
1 answer

Android's List View. Parameterized type in AdapterView.OnItemClickListener

I have a ListView with a hypothetical SquirrelAdapter. Something like this: public class SquirrelAdapter extends ArrayAdapter { private LayoutInflater layoutInflater; private Context context; private int resource; public…
Valerio Bozz
  • 607
  • 7
  • 23
3
votes
1 answer

Can Apache Avro framework handle parameterized types during serialization?

Can Apache Avro handle parameterized types during serialization? I see this exception thrown from Avro framework when I try to serialize an instance that uses generics - org.apache.avro.AvroTypeException: Unknown type: T at…
Rajiv
  • 1,825
  • 1
  • 8
  • 6
2
votes
1 answer

Parameterizing superclass method and non-parameterized (concrete type) method in subclass

I have an abstract superclass ValueType and two non-abstract subclasses IntType and DoubleType. How can define types in the superclass method like following public abstract class ValueType { public abstract T add(T…
2
votes
1 answer

flow optional type parameter

How can I use an optional type parameter in a type constructor? In the following, I want the Fruit type constructor to return different types based on whether C is passed or not: type Color = | 'yellow' | 'orange' | 'red'; type Fruit
Sam R.
  • 14,850
  • 9
  • 56
  • 106
2
votes
2 answers

In systemverilog is there a way to condition on a type?

So I am using a parameterized type in a common module. Is there a way to say: if( type == TYPE1 ) assign the struct one way else if( type == TYPE2 ) assign another way I was picturing this in a generate block.
2
votes
1 answer

How to pass a List in JSF composite component?

I have to create a JSF composite component where, I have to pass a attribute like below: what should I pass in type attribute if it is a List of type Note …
notescrew
  • 3,072
  • 4
  • 21
  • 36
2
votes
1 answer

Instantiate Parameterized Type class with Class variable

(Note: I have searched multiple questions on SO in this similar domain, but I never encountered an answer specific to my idea). Consider if I have a class or enum Foo where each instance has a Class type field: public enum Foo { A…
aaroncarsonart
  • 832
  • 7
  • 23
2
votes
1 answer

How to describe and fix this Scala type mismatch error?

Below is a specific instance of a kind of situation that I sometimes encounter with parameterized types. Basically, there are type parameters that I know are compatible, but I don't know how to prove that to some parts of the code. I'm writing a…
Rob N
  • 11,371
  • 11
  • 72
  • 126
2
votes
1 answer

Scala Def Macros - How do I get the parameterized type member of a symbol?

I'm trying to get the parameterized type of a member on a symbol in a MACRO context. I only have a symbol available (can't use weakTypeOf[List[Blah]]) because I am iterating over a bunch of classes. val meWantArg = classSymbol.member("paramList":…
Daniel Macias
  • 242
  • 3
  • 10
2
votes
1 answer

Parameterized types and return values in D why does this not work?

OK, it seems my prior problem is now resolved (I've left it below for reference). However, yet another one crops up - again, seemingly something I'm missing. Further up in this code, I declared the following: private: T _data; BinaryTree!(T) _left;…
Koz Ross
  • 2,714
  • 1
  • 19
  • 40
1
vote
2 answers

Is the return Object of getConstructors() method not array of parameterized type?

in this Link, it is declared that we can not create an array of parameterzide type. Create an Array of Arraylists but in java reflect, we can call getConstructors() method and save it's returned objects as below. Constructor[] constructors =…
pail
  • 45
  • 4
1
vote
2 answers

Idiomatic vector-like type parameterized over index and value types

Is there an idiomatic C++ type for a contiguous container that lets you specify both the value type (as std::vector and std::array do) and the index/size type? I've writing some code that going to manipulate a lot of arrays of data, but the indexes…
rampion
  • 82,104
  • 41
  • 185
  • 301
1
vote
0 answers

Cannot understand parameterized type

i am studying scala and have been trying to learn as much as i can. After reading the scala programming book i am reading the source code of several projects while trying some examples myself. I am really struggling to understand what this method…
Rafael Saraiva
  • 848
  • 1
  • 10
  • 22