1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-11 09:42:54 +00:00

Character Friend implementation

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-13 15:46:33 -03:00
parent 632aaac548
commit bb3f24e8f4
23 changed files with 404 additions and 72 deletions

View File

@@ -0,0 +1,26 @@
package com.l2jserver.model.id.object.iterator;
import java.util.Iterator;
import com.l2jserver.model.world.WorldObject;
/**
* This is a simple {@link Iterable} implementation that always return the same
* {@link Iterator}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
* @param <T>
* the return object type
*/
public class WorldObjectIterable<T extends WorldObject> implements Iterable<T> {
private final Iterator<T> iterator;
public WorldObjectIterable(Iterator<T> iterator) {
this.iterator = iterator;
}
@Override
public Iterator<T> iterator() {
return iterator;
}
}

View File

@@ -0,0 +1,44 @@
package com.l2jserver.model.id.object.iterator;
import java.util.Iterator;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.util.ArrayIterator;
/**
* This {@link Iterator} will iterate trough another {@link Iterator} which
* return {@link ObjectID} instances. For each ID, the
* {@link ObjectID#getObject()} method will be called and its result will be
* returned.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
* @param <T>
* the object type
*/
public class WorldObjectIterator<T extends WorldObject> implements Iterator<T> {
private final Iterator<? extends ObjectID<T>> ids;
public WorldObjectIterator(ObjectID<T>... ids) {
this(new ArrayIterator<ObjectID<T>>(ids));
}
public WorldObjectIterator(Iterator<? extends ObjectID<T>> ids) {
this.ids = ids;
}
@Override
public boolean hasNext() {
return ids.hasNext();
}
@Override
public T next() {
return ids.next().getObject();
}
@Override
public void remove() {
ids.remove();
}
}