Hi,
I am quite new to Java ...
I wrote a class called DLPFile
which is basically a container of other objects like Strings, ints, floats, etc.
When putting my files into a List and then saving it in my session (which is from Map class) variable is easy;
DLPFile file = new DLPFile();
List <DLPFile >fileList = new ArrayList <DLPFile>...
Is there a way in Boo to express some constaints on generic types as we can do using the where clause in C#?
In short, how to write?:
class MyClass<T>
where T:Icomparable<T>
{...}
Thank you
...
Hi,
I am trying to create a generic class with generic type being subclass of Numeric (to ensure that I am dealing with numbers.)
and I tried "class NuVector[T<:Numeric[T])" as class def and it compiling fine.
Now I want to add PartiallyOrdered[T] to it. so I did the following:
class NuVector[T<:Numeric[T]) extends PartiallyOrdered[T]...
I've recently started learning Scala and was disappointed (but not surprised) that their generics are also implemented via type erasure.
My question is, is it possible for Scala to have reified generics, or would the JVM need to be changed in some way? If the JVM does need to be changed, what exactly would need to be changed?
...
I don't think that this could be done in C#, but posting this just to make sure. Here's my problem. I would like to do something like this in C#:
var x = 10;
var l = new List<typeof(x)>();
or
var x = 10;
var t = typeof(x);
var l = new List<t>();
But of course this doesn't work. Although this shouldn't be a problem as the type t is...
I have an application where client and server share types, and interoperability is not one of our concerns. I am planning to have a single repository for all web enabled objects, and i was thinking of a generic interface for my exposed service.
something like T GetObject(int id)
but wcf doesnt like it since its trying to expose its sch...
How would I get this to work? Looking to have result updated with the 100 using generic typing. Any ideas? Of course this function isn't complete, I just need to get the result functionality working so I can continue.
public static bool ReadMemory<T>(Process process, IntPtr address, ref T result)
{
Type objType = resu...
My question is eerily similar to "Writing a generic class to handle built-in types" including being inspired by the fact of working on a class to handle operations on matrices.
Although that question was asked using C# and pointed to an article on Generic Operators.
I don't get it. Java Number does not have an add method so you can hav...
Hello, I have the following situation in code, which I suspect may be a bit dodgey:
I have a class:
abstract class DataAccessBase<T> : IDataAccess where T : AnotherAbstractClass
This class DataAccessBase also has a static factory method which creates instances of derived classes of itself using an enum value in a which statement to d...
I need to use the SharePoint API in the following way in a PowerShell script:
C# Code:
var service = farm.Services.GetValue<SPWebService>();
How does one specify the generics parameter in PowerShell?
At the moment I get an Exception stating that "Late bound operations cannot be performed on types or methods for which ContainsGenerei...
Basically i don't want to compare elements, but elements that thy contain. It would be cool if following would work, but it does not.
public boolean equals(Ie<T> that) {
T This = this.value;
T That = that.value;
boolean x = That.compareTo(This) == 0;
return x;
}
What i have done is :
public boolean equals(Object obj) {
if (obj =...
I'm working on a method that will accept a StreamWriter, either a string or a nullable value, and a length, and write the value to the StreamWriter, padded to the length. If the value is null, I want to write spaces. I want to do something like the following oversimplified example, which is just for demonstration purposes.
public void F...
Hello, I have a question concerning a generic type parameter.
Let's say I have the following definitions in my domain model:
abstract class Entity<TId>
{
public TId Id { get; private set; }
/* ... */
}
class Person : Entity<long>
{
public string Name { get; set; }
/* ... */
}
Let's say now I want to create a method t...
I have a function which returns a one-sided intersection of values between two input maps:
Map<Key, Value> mergeMaps(Map aKeys<CompositeKey, Key>,
Map <CompositeKey, Value> aValues) {
Map<Key, Value> myResult = Maps.newHashMap();
for (CompositeKey myKey : aKeys.keySet()) {
if (aValues.containsKey(myKey)) {
...
Because of how generics are implemented in Java (eventually compiling down to objects and casts), what are the benefits of using them?
Should I still use them for the compile time type safety? I'm used to the significant speed boost of generics in C# and I'm curious if people who work with Java still frequently use generics despite the...
Hi,
I need to be able to access a property via reflection, and, knowing that this property is an IEnumerable, append an object to it.
Something like this:
Object o;
MemberInfo m;
Array arr; // Except use IEnumerable, may have to take account of value/ref types
arr = (Array)((PropertyInfo)m).GetValue(o, null); }
List<o.GetType()> new...
I have a generic class that needs to limit an enum depending on the type defined:
public enum ConditionOperatorsString { None, Like, Equal }
public enum ConditionOperatorsDate { None, Equal, BeforeThan, AfterThan }
public class Condition<T>
{
public T Value { get; set; }
public ConditionOperatorsString Operator { get; set; }
publi...
I'm working on an EventRegistry that lets register some event handlers. Every time an event is raised it will check to see if there's any subscriber for that event and invoke them.
interface IEventRegistry
{
void Subscribe<TEventArgs>(Type eventType,EventHandler<TEventArgs> subscriber) where TEventArgs:EventArgs
void Publish<TEventArgs>...
I wonder if you could explain to me what is a difference between: <? super E> and <?extends E>.
For instance when you take a look at class java.util.concurrent.LinkedBlockingQueue there is a following signature for constructor: public LinkedBlockingQueue(Collection<? extends E> c) and for one for the method: public int drainTo(Collectio...
I must be doing something wrong here (because really, what are the chances of me tripping over another bug in the Vb.net compiler?)
I have a static generic function in .net 2.0 Vb code, I thought it was time to "upgrade" it to be an extension method, but the compiler complains with
Extension method 'AddIfUnqiue' has
type constrai...