mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-11 09:42:54 +00:00
Written javadoc for many classes
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -15,9 +15,20 @@ import com.l2jserver.model.world.WorldObject;
|
||||
* the {@link WorldObject} type
|
||||
*/
|
||||
public abstract class ObjectID<T extends WorldObject> extends ID {
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param id
|
||||
* the raw id
|
||||
*/
|
||||
protected ObjectID(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link WorldObject} associated with this {@link ID}
|
||||
*
|
||||
* @return the {@link WorldObject} if existent, <tt>null</tt> otherwise
|
||||
*/
|
||||
public abstract T getObject();
|
||||
}
|
||||
|
||||
@@ -7,12 +7,22 @@ import com.l2jserver.model.template.Template;
|
||||
* defined in the template class.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public abstract class TemplateID<T extends Template<?>> extends ID {
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param id
|
||||
* the raw id
|
||||
*/
|
||||
public TemplateID(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Template} associated with this {@link ID}
|
||||
*
|
||||
* @return the {@link Template} if existent, <tt>null</tt> otherwise
|
||||
*/
|
||||
public abstract T getTemplate();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.l2jserver.model.id.factory;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import com.l2jserver.model.id.object.allocator.BitSetIDAllocator;
|
||||
@@ -13,6 +14,11 @@ import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory;
|
||||
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
|
||||
import com.l2jserver.model.id.template.factory.SkillTemplateIDFactory;
|
||||
|
||||
/**
|
||||
* Google Guice {@link IDFactory} {@link Module}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class IDFactoryModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
||||
@@ -5,6 +5,13 @@ import com.google.inject.assistedinject.Assisted;
|
||||
import com.l2jserver.model.id.ObjectID;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
|
||||
/**
|
||||
* An {@link ObjectID} instance representing an {@link Actor} object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <T>
|
||||
* the actor subclass
|
||||
*/
|
||||
public abstract class ActorID<T extends Actor> extends ObjectID<T> {
|
||||
@Inject
|
||||
public ActorID(@Assisted int id) {
|
||||
|
||||
@@ -3,8 +3,14 @@ package com.l2jserver.model.id.object;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.l2jserver.db.dao.CharacterDAO;
|
||||
import com.l2jserver.model.id.ObjectID;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
|
||||
/**
|
||||
* An {@link ObjectID} instance representing an {@link L2Character} object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public final class CharacterID extends ActorID<L2Character> {
|
||||
/**
|
||||
* Data Access Object (DAO) for characters
|
||||
|
||||
@@ -5,6 +5,11 @@ import com.l2jserver.db.dao.ClanDAO;
|
||||
import com.l2jserver.model.id.ObjectID;
|
||||
import com.l2jserver.model.world.Clan;
|
||||
|
||||
/**
|
||||
* An {@link ObjectID} instance representing an {@link Clan} object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public final class ClanID extends ObjectID<Clan> {
|
||||
/**
|
||||
* Data Access Object (DAO) for clans
|
||||
|
||||
@@ -6,6 +6,11 @@ import com.l2jserver.db.dao.ItemDAO;
|
||||
import com.l2jserver.model.id.ObjectID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* An {@link ObjectID} instance representing an {@link Item} object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public final class ItemID extends ObjectID<Item> {
|
||||
/**
|
||||
* Data Access Object (DAO) for items
|
||||
|
||||
@@ -2,8 +2,14 @@ package com.l2jserver.model.id.object;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.db.dao.PetDAO;
|
||||
import com.l2jserver.model.id.ObjectID;
|
||||
import com.l2jserver.model.world.Pet;
|
||||
|
||||
/**
|
||||
* An {@link ObjectID} instance representing an {@link Pet} object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public final class PetID extends ActorID<Pet> {
|
||||
/**
|
||||
* Data Access Object (DAO) for pets
|
||||
|
||||
@@ -10,7 +10,15 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.util.PrimeFinder;
|
||||
|
||||
/**
|
||||
* The {@link BitSet} id allocator allocates new IDs backed by an {@link BitSet}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BitSetIDAllocator implements IDAllocator {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(BitSetIDAllocator.class);
|
||||
|
||||
@@ -32,6 +40,9 @@ public class BitSetIDAllocator implements IDAllocator {
|
||||
*/
|
||||
private AtomicInteger nextId = new AtomicInteger();
|
||||
|
||||
/**
|
||||
* Initializes this allocator
|
||||
*/
|
||||
public void init() {
|
||||
ids = new BitSet(PrimeFinder.nextPrime(100000));
|
||||
ids.clear();
|
||||
@@ -108,6 +119,9 @@ public class BitSetIDAllocator implements IDAllocator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the {@link BitSet} capacity
|
||||
*/
|
||||
private void increaseBitSetCapacity() {
|
||||
log.debug("Increasing BitSet capacity from {}", ids.size());
|
||||
BitSet newBitSet = new BitSet(
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.l2jserver.model.id.object.allocator;
|
||||
|
||||
/**
|
||||
* Exception thrown by an {@link IDAllocator}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class IDAllocatorException extends RuntimeException {
|
||||
private static final long serialVersionUID = 111195059766878062L;
|
||||
|
||||
|
||||
@@ -13,8 +13,17 @@ import com.l2jserver.model.world.WorldObject;
|
||||
* the return object type
|
||||
*/
|
||||
public class WorldObjectIterable<T extends WorldObject> implements Iterable<T> {
|
||||
/**
|
||||
* The {@link Iterator}
|
||||
*/
|
||||
private final Iterator<T> iterator;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param iterator
|
||||
* the iterator
|
||||
*/
|
||||
public WorldObjectIterable(Iterator<T> iterator) {
|
||||
this.iterator = iterator;
|
||||
}
|
||||
|
||||
@@ -17,12 +17,27 @@ import com.l2jserver.util.ArrayIterator;
|
||||
* the object type
|
||||
*/
|
||||
public class WorldObjectIterator<T extends WorldObject> implements Iterator<T> {
|
||||
/**
|
||||
* The {@link ObjectID} iterator
|
||||
*/
|
||||
private final Iterator<? extends ObjectID<T>> ids;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param ids
|
||||
* the {@link ObjectID} var-arg
|
||||
*/
|
||||
public WorldObjectIterator(ObjectID<T>... ids) {
|
||||
this(new ArrayIterator<ObjectID<T>>(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param ids
|
||||
* the {@link ObjectID} iterator
|
||||
*/
|
||||
public WorldObjectIterator(Iterator<? extends ObjectID<T>> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,16 @@ import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
|
||||
/**
|
||||
* An {@link TemplateID} instance representing an {@link CharacterTemplate}
|
||||
* object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterTemplateID extends TemplateID<CharacterTemplate> {
|
||||
/**
|
||||
* The template service
|
||||
*/
|
||||
private final TemplateService templateService;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -6,7 +6,16 @@ import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
|
||||
/**
|
||||
* An {@link TemplateID} instance representing an {@link ItemTemplate}
|
||||
* object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ItemTemplateID extends TemplateID<ItemTemplate> {
|
||||
/**
|
||||
* The template service
|
||||
*/
|
||||
private final TemplateService templateService;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -6,7 +6,16 @@ import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.template.SkillTemplate;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
|
||||
/**
|
||||
* An {@link TemplateID} instance representing an {@link SkillTemplate}
|
||||
* object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SkillTemplateID extends TemplateID<SkillTemplate> {
|
||||
/**
|
||||
* The template service
|
||||
*/
|
||||
private final TemplateService templateService;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -2,6 +2,11 @@ package com.l2jserver.model.id.template.factory;
|
||||
|
||||
import com.l2jserver.model.id.template.CharacterTemplateID;
|
||||
|
||||
/**
|
||||
* Creates new {@link CharacterTemplateID} instances
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface CharacterTemplateIDFactory extends
|
||||
TemplateIDFactory<CharacterTemplateID> {
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@ package com.l2jserver.model.id.template.factory;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
|
||||
/**
|
||||
* Creates new {@link ItemTemplateID} instances
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface ItemTemplateIDFactory extends
|
||||
TemplateIDFactory<ItemTemplateID> {
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@ package com.l2jserver.model.id.template.factory;
|
||||
|
||||
import com.l2jserver.model.id.template.SkillTemplateID;
|
||||
|
||||
/**
|
||||
* Creates new {@link SkillTemplateID} instances
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface SkillTemplateIDFactory extends
|
||||
TemplateIDFactory<SkillTemplateID> {
|
||||
}
|
||||
|
||||
@@ -3,6 +3,14 @@ package com.l2jserver.model.id.template.factory;
|
||||
import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.id.factory.IDFactory;
|
||||
|
||||
/**
|
||||
* Creates a new {@link TemplateID}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
* @param <T>
|
||||
* the subclass of {@link TemplateID} that will be createdF
|
||||
*/
|
||||
public interface TemplateIDFactory<T extends TemplateID<?>> extends
|
||||
IDFactory<T> {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user