1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-05 23:22:47 +00:00

Implements item drop mode configuration

This commit is contained in:
2011-12-29 01:16:50 -02:00
parent 394a2853e2
commit c5911ea884
8 changed files with 144 additions and 22 deletions

View File

@@ -21,12 +21,20 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* An abstract service implementing basic life-cycle methods.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class AbstractService implements Service {
/**
* The service logger
*/
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* Running state of a service
*/

View File

@@ -30,8 +30,6 @@ public class ArrayUtils {
/**
* Copy an entire array except objects in <code>except</code> array.
*
* @param type
* the array type
* @param array
* the source array
* @param except
@@ -39,8 +37,8 @@ public class ArrayUtils {
* @return the copied array
*/
@SafeVarargs
public final static <T> T[] copyArrayExcept(Class<T[]> type, T[] array,
T... except) {
@SuppressWarnings("unchecked")
public final static <T> T[] copyArrayExcept(T[] array, T... except) {
final List<T> values = CollectionFactory.newList();
for (final T item : array) {
if (Arrays.binarySearch(except, item, new Comparator<T>() {
@@ -52,6 +50,6 @@ public class ArrayUtils {
values.add(item);
}
}
return Arrays.copyOf(values.toArray(), values.size(), type);
return (T[]) Arrays.copyOf(values.toArray(), values.size(), array.getClass());
}
}

View File

@@ -26,6 +26,7 @@ import com.l2jserver.util.transformer.impl.BooleanTransformer;
import com.l2jserver.util.transformer.impl.ByteTransformer;
import com.l2jserver.util.transformer.impl.ClassTransformer;
import com.l2jserver.util.transformer.impl.DoubleTransformer;
import com.l2jserver.util.transformer.impl.EnumTransformer;
import com.l2jserver.util.transformer.impl.FileTransformer;
import com.l2jserver.util.transformer.impl.FloatTransformer;
import com.l2jserver.util.transformer.impl.InetSocketAddressTransformer;
@@ -77,6 +78,8 @@ public class TransformerFactory {
return URLTransformer.SHARED_INSTANCE;
} else if (type == Path.class) {
return PathTransformer.SHARED_INSTANCE;
} else if(type.isEnum()) {
return EnumTransformer.SHARED_INSTANCE;
}
return null;
}

View File

@@ -29,7 +29,7 @@ import org.junit.Test;
*/
public class ArrayUtilsTest extends ArrayUtils {
/**
* Test for {@link ArrayUtils#copyArrayExcept(Class, Object[], Object...)}
* Test for {@link ArrayUtils#copyArrayExcept(Object[], Object...)}
*/
@Test
public void testCopyArrayExcept() {
@@ -38,7 +38,7 @@ public class ArrayUtilsTest extends ArrayUtils {
final TestClass objC = new TestClass("c");
TestClass[] arr = new TestClass[] { objA, objB, objC };
TestClass[] selected = copyArrayExcept(TestClass[].class, arr, objB);
TestClass[] selected = copyArrayExcept(arr, objB);
System.out.println(Arrays.toString(selected));
Assert.assertTrue(Arrays.equals(new TestClass[] { objA, objC },