Example usage for com.badlogic.gdx.utils ArrayMap containsValue

List of usage examples for com.badlogic.gdx.utils ArrayMap containsValue

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils ArrayMap containsValue.

Prototype

public boolean containsValue(V value, boolean identity) 

Source Link

Usage

From source file:com.algodal.gdxscreen.GdxGame.java

License:Apache License

private <T extends GdxScreen> void registerScreen(ArrayMap<String, GdxScreen> map, String name, String ref,
        Class<T> clazz) {//w w w . j  a  va  2  s  .co  m
    debug.assertEqual("method is called in initialize", currentState, State.Initializing);
    debug.assertNotNull(name + " ref is not null", ref);
    debug.assertNotNull(name + " class is not null", clazz);
    debug.assertStringNotEmpty(name + " ref is not empty", (ref = ref.trim())); //The trimmed down version of the string is used
    debug.assertContructorEmpty(name + " class has a empty constructor", clazz);

    //generate screen object
    T screen = debug.assertNoException("no allocation excepton", new Operation<T>() {
        @Override
        public T resultOf() throws Exception {
            return clazz.newInstance();
        }
    });
    screen.setGame(this); //This is a must.  Every screen must know their game.

    debug.assertNotNull(name + " is not null", screen);
    debug.assertFalse(name + " ref is unique", map.containsKey(ref)); //unique reference
    debug.assertFalse(name + " object is unique", map.containsValue(screen, false)); //unique screen: see GdxScreen equals(ObjectS) method

    //add new reference
    map.put(ref, screen);
}