Updated ClassUtils and fixed some minor warnings with Excel

This commit is contained in:
Collin Smith 2019-09-28 03:45:38 -07:00
parent 761c6f8447
commit 0416c93abf
2 changed files with 14 additions and 2 deletions

View File

@ -112,11 +112,11 @@ public abstract class Excel<T extends Excel.Entry> implements Iterable<T> {
if (!FORCE_TXT && isBinned(excelClass) && bin != null && bin.exists()) {
if (DEBUG_TYPE) Gdx.app.debug(TAG, "Loading bin " + bin);
excel = loadBin(bin, excelClass, entryClass);
file = bin;
if (DEBUG_TIME) file = bin;
} else {
if (DEBUG_TYPE) Gdx.app.debug(TAG, "Loading txt " + txt);
excel = loadTxt(txt, excelClass, entryClass, ignore);
file = txt;
if (DEBUG_TIME) file = txt;
}
long end = System.currentTimeMillis();
@ -314,6 +314,7 @@ public abstract class Excel<T extends Excel.Entry> implements Iterable<T> {
return excel;
}
@SuppressWarnings("unchecked")
private static <T extends Excel> T loadBin(FileHandle bin, Class<T> excelClass, Class<Entry> entryClass) throws Exception {
final boolean index = ClassUtils.hasAnnotation(entryClass, Index.class);
@ -380,6 +381,7 @@ public abstract class Excel<T extends Excel.Entry> implements Iterable<T> {
public void readBin(DataInput in) throws IOException {}
@SuppressWarnings("unchecked")
public void writeBin(DataOutput out) throws IOException {
//if (!isBinned()) return;
Class excelClass = this.getClass();

View File

@ -16,4 +16,14 @@ public class ClassUtils {
public static boolean hasAnnotation(Class c, Class annotationClass) {
return c.getAnnotation(annotationClass) != null;
}
public static Field findField(Class c, Class annotationClass) {
for (Field f : c.getFields()) {
if (f.getAnnotation(annotationClass) != null) {
return f;
}
}
return null;
}
}