當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassReflection.getSimpleName方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:Anuken,項目名稱:Mindustry,代碼行數:16,代碼來源:ByteSerializer.java

示例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);
}
 
開發者ID:EtherWorks,項目名稱:arcadelegends-gg,代碼行數:19,代碼來源:ScreenManager.java

示例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);
}
 
開發者ID:EtherWorks,項目名稱:arcadelegends-gg,代碼行數:8,代碼來源:ScreenManager.java

示例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;
}
 
開發者ID:JayKEm,項目名稱:Aftamath,代碼行數:11,代碼來源:Pair.java

示例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);
}
 
開發者ID:EtherWorks,項目名稱:arcadelegends-gg,代碼行數:6,代碼來源:ScreenManager.java


注:本文中的com.badlogic.gdx.utils.reflect.ClassReflection.getSimpleName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。