Add some testing

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot
2012-01-29 11:10:40 +01:00
parent ae0eb736d1
commit ac2271958e
34 changed files with 871 additions and 281 deletions

View File

@@ -1,8 +1,9 @@
package org.bukkit;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
/**
* Represents the different species of trees regardless of size.
*/
@@ -11,21 +12,21 @@ public enum TreeSpecies {
/**
* Represents the common tree species.
*/
GENERIC((byte) 0x0),
GENERIC(0x0),
/**
* Represents the darker barked/leaved tree species.
*/
REDWOOD((byte) 0x1),
REDWOOD(0x1),
/**
* Represents birches.
*/
BIRCH((byte) 0x2);
BIRCH(0x2);
private final byte data;
private final static Map<Byte, TreeSpecies> species = new HashMap<Byte, TreeSpecies>();
private final static Map<Byte, TreeSpecies> BY_DATA = Maps.newHashMap();
private TreeSpecies(final byte data) {
this.data = data;
private TreeSpecies(final int data) {
this.data = (byte) data;
}
/**
@@ -40,18 +41,17 @@ public enum TreeSpecies {
/**
* Gets the TreeSpecies with the given data value
*
* @param data
* Data value to fetch
* @param data Data value to fetch
* @return The {@link TreeSpecies} representing the given value, or null if
* it doesn't exist
*/
public static TreeSpecies getByData(final byte data) {
return species.get(data);
return BY_DATA.get(data);
}
static {
for (TreeSpecies s : TreeSpecies.values()) {
species.put(s.getData(), s);
for (TreeSpecies species : values()) {
BY_DATA.put(species.data, species);
}
}
}