Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Iterable support for contains/query methods.

Darn Hunk
Joined
Mar 16, 2015
Messages
11
Hello.

I've noticed that a few methods could benefit from the usage of iterable data types. Name ones such as:
Just to name a few. This could work quite well with the changes to collections from Java 8.

I don't see this being particularly useful in simpler, more commonly run scripts; but, it could very well have its niche.

Haven't been here long, so I wouldn't know if/when this was discussed before.


For further clarification, what I am suggesting is like such:

Code:
List<Integer> userDefinedIDs = ...;
// ...
LocatableEntityQueryResults<GroundItem> query = GroundItems.getLoaded(userDefinedIDs);


Set<String> userDefinedNames = ...;
// ...
LocatableEntityQueryResults<Npc> query = Npcs.getLoaded(userDefinedNames);

And the such.

Just a quick look shows that the following could benefit from this:

  1. Bank
  2. GroundItems
  3. Inventory
  4. Npcs
  5. Players


Thanks,

~T
 
Last edited:
Darn Hunk
Joined
Mar 16, 2015
Messages
11
So just overloads for collections?

Effectively.

Saves the hassle of having to convert it to an array before calling one of these methods.

This is also Java 8 where the collections have far more usage.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
I'll go ahead and add the overloads in a few frequently used places.
 
I began to do this with Collection overloads but I've began to run into a few signature erasure issues so I'll have to look into it and be a bit more selective.
 
Darn Hunk
Joined
Mar 16, 2015
Messages
11
I'll go ahead and add the overloads in a few frequently used places.
 
I began to do this with Collection overloads but I've began to run into a few signature erasure issues so I'll have to look into it and be a bit more selective.

That was definitely a downside to this. The way this has been circumvented before was just to do

Code:
containsAllOfNames(Iterable<String>)
containsAllOfIds(Iterable<Integer>)

I understand if you wouldn't feel comfortable compromising the integrity of the names. I'd sooner tear my own hairs out than drop my linearity. This was merely a suggestion of opportunity and not requirement.

Most of these also pertain to items. So maybe some trickery with the ItemDefinition's could be had. Although, at that point, it would almost become more efficient just to drop the notion and call forth an array.
 
Top