本文整理匯總了Java中com.badlogic.gdx.utils.reflect.ClassReflection.getSimpleName方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassReflection.getSimpleName方法的具體用法?Java ClassReflection.getSimpleName怎麽用?Java ClassReflection.getSimpleName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.reflect.ClassReflection
的用法示例。
在下文中一共展示了ClassReflection.getSimpleName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: write
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
@Override
public void write(ByteBuffer byteBuffer, Object o) {
if(o instanceof FrameworkMessage){
byteBuffer.put((byte)-2); //code for framework message
FrameworkSerializer.write(byteBuffer, (FrameworkMessage)o);
}else {
if (!(o instanceof Packet))
throw new RuntimeException("All sent objects must implement be Packets! Class: " + o.getClass());
byte id = Registrator.getID(o.getClass());
if (id == -1)
throw new RuntimeException("Unregistered class: " + ClassReflection.getSimpleName(o.getClass()));
byteBuffer.put(id);
((Packet) o).write(byteBuffer);
}
}
示例2: register
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
/**
* Registers the given screen into the {@link ScreenManager}.
* Initializes the given {@link Screen} with a default constructor, if init is true.
*
* @param type type of the {@link Screen}
* @return the old registered instance
*/
public synchronized <T extends Screen> T register(Class<T> type) {
if (screenMap.containsKey(type))
throw new IllegalArgumentException("Screen already registerd: " + ClassReflection.getSimpleName(type));
T screen = null;
try {
screen = ClassReflection.newInstance(type);
} catch (ReflectionException e) {
throw new IllegalArgumentException(e);
}
return (T) screenMap.put(type, screen);
}
示例3: get
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
public synchronized <T extends Screen> T get(Class<T> type, boolean init) {
if (init && !isRegistered(type))
register(type);
if (!isRegistered(type))
throw new IllegalArgumentException("Screen not registered: " + ClassReflection.getSimpleName(type));
return (T) screenMap.get(type);
}
示例4: swap
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
/** swaps key and value
* @throws IllegalStateException if the classes of {@link #key} and {@link #value} are not {@link Class#isAssignableFrom(Class) assignable} from each other */
@SuppressWarnings("unchecked")
public void swap() throws IllegalStateException {
if(key.getClass() != value.getClass())
throw new IllegalStateException("key and value are not of the same type: " + ClassReflection.getSimpleName(key.getClass()) + " - " + ClassReflection.getSimpleName(value.getClass()));
V oldValue = value;
value = (V) key;
key = (K) oldValue;
}
示例5: remove
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
public synchronized void remove(Class<? extends Screen> type) {
if (!screenMap.containsKey(type))
throw new IllegalArgumentException("Screen not registered: " + ClassReflection.getSimpleName(type));
screenMap.remove(type);
}