/** * Subscribe an {@link EventListener} to the event bus.<br/> * All it's methods containing {@link Event} parameters will be invoked when needed. * @param eventListener the {@link EventListener} to subscribe */ public static void subscribe(EventListener eventListener) { ArrayMap<Method, Class<? extends Event>> eventTypes = new ArrayMap<Method, Class<? extends Event>>(); for (Method method : eventListener.getClass().getMethods()) { for (Class<?> c : method.getParameterTypes()) { String name = method.getName(); if (name.equals("wait") // Escape native methods with null parameter types || name.equals("equals") || name.equals("clone") || name.equals("finalize") || name.equals("hashCode") || name.equals("toString") || name.equals("notify") || name.equals("notifyAll")) break; if (c.getSuperclass().equals(Event.class)) { eventTypes.put(method, (Class<? extends Event>) c); } } } eventProcessors.put(eventListener, eventTypes); }
public InputHandlerOld() { tempVec = new Vector2(); activeContexts = new Array<>(); activeKeyCodes = new ArrayMap<>(); activePointers = new ArrayMap<>(); activeMouseInputs = new ArrayMap<>(); inputListeners = new Array<>(); inputContexts = new ArrayMap<>(); keyInputsMap = new ArrayMap<>(); pointerInputsMap = new ArrayMap<>(); stickInputsMap = new ArrayMap<>(); mouseInputsMap = new ArrayMap<>(); Controllers.addListener(this); inputMultiplexer = new InputMultiplexer(this); Gdx.input.setInputProcessor(inputMultiplexer); }
private void dispatchPointerInputs() { if (activePointers.size > 0) { ArrayMap.Keys<Integer> pointers = activePointers.keys(); for (int pointer : pointers) { NhgInput input = activePointers.get(pointer); if (input != null && isValidInput(input)) { processPointerInput(pointer, input); dispatchPointerInput(input); if (input.getAction() == InputAction.UP) { if (activePointers.containsKey(pointer)) { activePointers.removeKey(pointer); } } } } } }
private void dispatchMouseInputs() { if (activeMouseInputs.size > 0) { ArrayMap.Keys<MouseSourceType> mouseInputs = activeMouseInputs.keys(); for (MouseSourceType mouseInput : mouseInputs) { NhgInput input = activeMouseInputs.get(mouseInput); if (input != null && isValidInput(input)) { processMouseInput(input); dispatchMouseInput(input); if (input.getAction() == InputAction.UP) { if (activeMouseInputs.containsKey(mouseInput)) { activeMouseInputs.removeKey(mouseInput); } } } } } }
public static void load() { idsReferences = new ArrayMap<String, String>(); achievementsUnlocked = new ArrayMap<String, Boolean>(); //Ids de los achievements idsReferences.put("achievement_finalized_campaign_id", "CgkIm5z9sJkQEAIQAg"); idsReferences.put("achievement_denizen_deep_id", "CgkIm5z9sJkQEAIQAw"); idsReferences.put("achievement_denizen_heights_id", "CgkIm5z9sJkQEAIQBA"); idsReferences.put("achievement_reflexes_id", "CgkIm5z9sJkQEAIQBQ"); idsReferences.put("achievement_master_id", "CgkIm5z9sJkQEAIQBg"); //Inicialmente todos estarán bloqueados achievementsUnlocked.put("achievement_finalized_campaign_id", false); achievementsUnlocked.put("achievement_denizen_deep_id", false); achievementsUnlocked.put("achievement_denizen_heights_id", false); achievementsUnlocked.put("achievement_reflexes_id", false); achievementsUnlocked.put("achievement_master_id", false); isLoaded = true; }
/** * Creates a map over each triangle and its Edge connections to other triangles. Each edge must follow the * vertex winding order of the triangle associated with it. Since all triangles are assumed to have the same * winding order, this means if two triangles connect, each must have its own edge connection data, where the * edge follows the same winding order as the triangle which owns the edge data. * * @param indexConnections * @param triangles * @param vertexVectors * @return */ private static ArrayMap<Triangle, Array<Edge>> createSharedEdgesMap( Array<IndexConnection> indexConnections, Array<Triangle> triangles, Vector3[] vertexVectors) { ArrayMap<Triangle, Array<Edge>> connectionMap = new ArrayMap<Triangle, Array<Edge>>(); connectionMap.ordered = true; for (Triangle tri : triangles) { connectionMap.put(tri, new Array<Edge>()); } for (IndexConnection i : indexConnections) { Triangle fromNode = triangles.get(i.fromTriIndex); Triangle toNode = triangles.get(i.toTriIndex); Vector3 edgeVertexA = vertexVectors[i.edgeVertexIndex1]; Vector3 edgeVertexB = vertexVectors[i.edgeVertexIndex2]; Edge edge = new Edge(fromNode, toNode, edgeVertexA, edgeVertexB); connectionMap.get(fromNode).add(edge); fromNode.connections.add(edge); } return connectionMap; }
public void save(String sceneName){ if(!isDirty) return; if(sceneName == null || sceneName.isEmpty()) return; Scene.log("Save "+sceneName); if(!sceneName.contains(basePackage) && !sceneName.contains("gdxstudio")) sceneName = basePackage+sceneName; StringBuilder sb = new StringBuilder(); for(Actor actor: getChildren()){ sb.append(json.toJson(actor)); sb.append("\n"); } sb.append(json.toJson(getRoot().findActor(this.sceneName)));//??Warning scenesMap.put(sceneName, sb.toString()); Gdx.files.local(Asset.basePath+"scene").writeString(json.toJson(scenesMap, ArrayMap.class, String.class), false); sb = null; isDirty = false; }
/** * Tiles that have a 'texture' property will be using an optimized tileset. This is to avoid screen tearing. * @param layer */ private void initTileset(TiledMapTileLayer layer) { ArrayMap<String, TextureRegion> textureArr = new ArrayMap<String, TextureRegion>(); for(int x = 0; x < layer.getWidth(); x++) { for(int y = 0; y < layer.getHeight(); y++) { Cell cell = layer.getCell(x, y); if(cell != null) { TiledMapTile oldTile = cell.getTile(); if(oldTile.getProperties().containsKey("texture")) { //D.o("Initializing textures"); String texture = (String) oldTile.getProperties().get("texture"); if(textureArr.containsKey(texture)) { oldTile.getTextureRegion().setRegion(textureArr.get(texture)); } else { TextureRegion t = Tiles.getTile(texture); textureArr.put(texture, t); oldTile.getTextureRegion().setRegion(t); } } } } } }
public void write (Kryo kryo, Output output, ArrayMap map) { output.writeBoolean(map.ordered); int length = map.size; output.writeVarInt(length, true); kryo.writeClass(output, map.keys.getClass().getComponentType()); kryo.writeClass(output, map.values.getClass().getComponentType()); Serializer keySerializer = null; if (keyGenericType != null) { if (keySerializer == null) keySerializer = kryo.getSerializer(keyGenericType); keyGenericType = null; } Serializer valueSerializer = null; if (valueGenericType != null) { if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueGenericType); valueGenericType = null; } for (Iterator iter = map.iterator(); iter.hasNext();) { ObjectMap.Entry entry = (ObjectMap.Entry)iter.next(); if (keySerializer != null) { kryo.writeObject(output, entry.key, keySerializer); } else kryo.writeClassAndObject(output, entry.key); if (valueSerializer != null) { kryo.writeObjectOrNull(output, entry.value, valueSerializer); } else kryo.writeClassAndObject(output, entry.value); } }
@Override public void init(MapProperties properties) { effects = new ArrayMap<GameObject, ParticleEffectPool.PooledEffect>(); pre_draws = new Array<ParticleEffectPool.PooledEffect>(); post_draws = new Array<ParticleEffectPool.PooledEffect>(); pos_check = new Vector2(); cam = getLayer().getCamera(); last_zoom = cam.getZoom(); pcomp = new ParticleComparator(); }
@SuppressWarnings("unchecked") public SceneGraph(Nhg nhg, String rootId) { this.nhg = nhg; this.entitiesArray = new Array<>(); entityIds = new ArrayMap<>(); sceneEntityArchetype = nhg.entities.createArchetype(NodeComponent.class); rootEntity = createSceneEntity(rootId); rootNodeComponent = nhg.entities.getComponent(rootEntity, NodeComponent.class); rootNodeComponent.setId(rootEntity); this.entitiesArray.add(rootEntity); }
public NhgWorld(Messaging messaging, Entities entities, Assets assets, WorldStrategy strategy, Bounds bounds) { this.entities = entities; this.worldStrategy = strategy; this.bounds = bounds; sceneManager = new SceneManager(messaging, entities, assets); scenes = new ArrayMap<>(); }
public void init(Nhg nhg) { this.nhg = nhg; fsm = new DefaultStateMachine<>(this, AssetsStates.IDLE); assetManager = new AssetManager(); syncAssetManager = new AssetManager(); FileHandleResolver resolver = assetManager.getFileHandleResolver(); FileHandleResolver syncResolver = syncAssetManager.getFileHandleResolver(); assetManager.setLoader(Scene.class, new SceneLoader(nhg, resolver)); assetManager.setLoader(InputProxy.class, new InputLoader(resolver)); assetManager.setLoader(JsonValue.class, new JsonLoader(resolver)); assetManager.setLoader(HDRData2.class, new HDRLoader(resolver)); assetManager.setLoader(Model.class, ".g3db", new NhgG3dModelLoader(this, new UBJsonReader(), resolver)); syncAssetManager.setLoader(Scene.class, new SceneLoader(nhg, syncResolver)); syncAssetManager.setLoader(InputProxy.class, new InputLoader(syncResolver)); syncAssetManager.setLoader(JsonValue.class, new JsonLoader(syncResolver)); syncAssetManager.setLoader(HDRData2.class, new HDRLoader(syncResolver)); syncAssetManager.setLoader(Model.class, ".g3db", new NhgG3dModelLoader(this, new UBJsonReader(), syncResolver)); assetManager.setErrorListener(this); syncAssetManager.setErrorListener(this); assetQueue = new Array<>(); assetCache = new ArrayMap<>(); Texture.setAssetManager(assetManager); }
private void dispatchKeyInputs() { if (activeKeyCodes.size > 0) { ArrayMap.Keys<Integer> keyCodes = activeKeyCodes.keys(); for (int keyCode : keyCodes) { NhgInput input = activeKeyCodes.get(keyCode); if (input != null && isValidInput(input)) { dispatchKeyInput(input); } } } }
public VirtualInputHandler(InputProxy inputProxy, InputMultiplexer inputMultiplexer, Array<NhgInput> virtualInputArray) { this.inputProxy = inputProxy; this.inputMultiplexer = inputMultiplexer; this.originalVirtualInputArray = virtualInputArray; vec0 = new Vector2(); activeVirtualInputs = new Array<>(); stages = new ArrayMap<>(); virtualInputs = new ArrayMap<>(); processVirtualInputArray(originalVirtualInputArray); }
public static WorldObjectView createView(Player viewer, PlayerColors colors, WorldObject object) { WorldObjectView view = new WorldObjectView(); ArrayMap<Object, SubView> subViewArrayMap = object.createSubViews(viewer, colors); for (Object key : subViewArrayMap.keys()) { view.addSubView(key, subViewArrayMap.get(key)); } object.initView(view); return view; }
public static void updateView(Player viewer, PlayerColors colors, WorldObject object, WorldObjectView view) { view.clearChildren(); ArrayMap<Object, SubView> subViewArrayMap = object.createSubViews(viewer, colors); for (Object key : subViewArrayMap.keys()) { view.addSubView(key, subViewArrayMap.get(key)); } }
@Initiate void initialize() { App.inst().getInput().addProcessor(this, -1000); ShortcutParser shortcutParser = new ShortcutParser(); Array<Shortcut> shortcutArray = shortcutParser.parse(Gdx.files.internal("hotkeys.txt")); shortcuts = new ArrayMap<>(shortcutArray.size); for (Shortcut shortcut : shortcutArray) { shortcuts.put(shortcut.getActionName(), shortcut); } }
@Test public void parseQueryTest() { try { ArrayMap<String, String> result = Utils.parseQuery("access_token=CAAqyZEeY&expires_in=5182959"); assertEquals("access_token", result.getKeyAt(0)); assertEquals("CAAqyZEeY", result.getValueAt(0)); assertEquals("expires_in", result.getKeyAt(1)); assertEquals("5182959", result.getValueAt(1)); } catch (UnsupportedEncodingException e) { } }
public static ArrayMap<String, String> parseQuery(String query) throws UnsupportedEncodingException { ArrayMap<String, String> params = new ArrayMap<String, String>(); for (String param : query.split("&")) { String[] pair = param.split("="); String key = URLDecoder.decode(pair[0], "UTF-8"); String value = URLDecoder.decode(pair[1], "UTF-8"); params.put(key, value); } return params; }
public ShaderManager(AssetManager assetManager, ShaderLoader shaderLoader) { this.assetManager = assetManager; assetManager.setLoader(ShaderProgram.class, shaderLoader); shaders = new ArrayMap<>(); shaderPaths = new ArrayMap<>(); frameBuffers = new ArrayMap<>(); activeFrameBuffers = new Stack<>(); screenCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); screenMesh = new Mesh(true, 4, 6, new VertexAttribute(VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(VertexAttributes.Usage.ColorUnpacked, 4, ShaderProgram.COLOR_ATTRIBUTE), new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0")); Vector3 vec0 = new Vector3(0, 0, 0); screenCamera.unproject(vec0); Vector3 vec1 = new Vector3(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0); screenCamera.unproject(vec1); screenMesh.setVertices(new float[]{ vec0.x, vec0.y, 0, 1, 1, 1, 1, 0, 1, vec1.x, vec0.y, 0, 1, 1, 1, 1, 1, 1, vec1.x, vec1.y, 0, 1, 1, 1, 1, 1, 0, vec0.x, vec1.y, 0, 1, 1, 1, 1, 0, 0}); screenMesh.setIndices(new short[]{0, 1, 2, 2, 3, 0}); screenCamera.translate(0f, -1f, 0f); screenCamera.update(); }
/** @param keyAndValues pairs of keys and values. Each value has to be proceeded by a key. * @return a new array map with the given values. Not fail-fast - be careful when passing arguments, or it might * result in unexpected map values. */ @SuppressWarnings("unchecked") public static <Key, Value> ArrayMap<Key, Value> newArrayMap(final Object... keyAndValues) { if (keyAndValues.length % 2 != 0) { throw new IllegalArgumentException("Total number of keys and values has to be even."); } final ArrayMap<Key, Value> map = new ArrayMap<Key, Value>(); for (int pairIndex = 0; pairIndex < keyAndValues.length; pairIndex++) { map.put((Key) keyAndValues[pairIndex], (Value) keyAndValues[++pairIndex]); } return map; }
/** @param keyAndValues pairs of keys and values. Each value has to be proceeded by a key. * @return a new typed array map with the given values. Not fail-fast - be careful when passing arguments, or it * might result in unexpected map values. */ @SuppressWarnings("unchecked") public static <Key, Value> ArrayMap<Key, Value> newArrayMap(final Class<Key> keyType, final Class<Value> valueType, final Object... keyAndValues) { if (keyAndValues.length % 2 != 0) { throw new IllegalArgumentException("Total number of keys and values has to be even."); } final ArrayMap<Key, Value> map = new ArrayMap<Key, Value>(keyType, valueType); for (int pairIndex = 0; pairIndex < keyAndValues.length; pairIndex++) { map.put((Key) keyAndValues[pairIndex], (Value) keyAndValues[++pairIndex]); } return map; }
/** * Map the isolated edges for each triangle which does not have all three edges connected to other triangles. * * @param connectionMap * @return */ private static ArrayMap<Triangle, Array<Edge>> createIsolatedEdgesMap(ArrayMap<Triangle, Array<Edge>> connectionMap) { ArrayMap<Triangle, Array<Edge>> disconnectionMap = new ArrayMap<Triangle, Array<Edge>>(); for (int i = 0; i < connectionMap.size; i++) { Triangle tri = connectionMap.getKeyAt(i); Array<Edge> connectedEdges = connectionMap.getValueAt(i); Array<Edge> disconnectedEdges = new Array<Edge>(); disconnectionMap.put(tri, disconnectedEdges); if (connectedEdges.size < 3) { // This triangle does not have all edges connected to other triangles boolean ab = true; boolean bc = true; boolean ca = true; for (Edge edge : connectedEdges) { if (edge.rightVertex == tri.a && edge.leftVertex == tri.b) ab = false; else if (edge.rightVertex == tri.b && edge.leftVertex == tri.c) bc = false; else if (edge.rightVertex == tri.c && edge.leftVertex == tri.a) ca = false; } if (ab) disconnectedEdges.add(new Edge(tri, null, tri.a, tri.b)); if (bc) disconnectedEdges.add(new Edge(tri, null, tri.b, tri.c)); if (ca) disconnectedEdges.add(new Edge(tri, null, tri.c, tri.a)); } int totalEdges = (connectedEdges.size + disconnectedEdges.size); if (totalEdges != 3) { Gdx.app.debug(TAG, "Wrong number of edges (" + totalEdges + ") in triangle " + tri.getIndex()); } } return disconnectionMap; }
/** @param keyAndValues pairs of keys and values. Each value has to be proceeded by a key. * @return a new array map with the given values. Not fail-fast - be careful when passing arguments, or it might * result in unexpected map values. * @param <Key> type of map keys. * @param <Value> type of map values. */ @SuppressWarnings("unchecked") public static <Key, Value> ArrayMap<Key, Value> newArrayMap(final Object... keyAndValues) { if (keyAndValues.length % 2 != 0) { throw new IllegalArgumentException("Total number of keys and values has to be even."); } final ArrayMap<Key, Value> map = new ArrayMap<Key, Value>(); for (int pairIndex = 0; pairIndex < keyAndValues.length; pairIndex++) { map.put((Key) keyAndValues[pairIndex], (Value) keyAndValues[++pairIndex]); } return map; }
/** @param keyType class of map keys. * @param valueType class of map values. * @param keyAndValues pairs of keys and values. Each value has to be proceeded by a key. * @return a new typed array map with the given values. Not fail-fast - be careful when passing arguments, or it * might result in unexpected map values. * @param <Key> type of map keys. * @param <Value> type of map values. */ @SuppressWarnings("unchecked") public static <Key, Value> ArrayMap<Key, Value> newArrayMap(final Class<Key> keyType, final Class<Value> valueType, final Object... keyAndValues) { if (keyAndValues.length % 2 != 0) { throw new IllegalArgumentException("Total number of keys and values has to be even."); } final ArrayMap<Key, Value> map = new ArrayMap<Key, Value>(keyType, valueType); for (int pairIndex = 0; pairIndex < keyAndValues.length; pairIndex++) { map.put((Key) keyAndValues[pairIndex], (Value) keyAndValues[++pairIndex]); } return map; }
private void loadNodes (Iterable<ModelNode> modelNodes) { nodePartBones.clear(); for (ModelNode node : modelNodes) { nodes.add(loadNode(node)); } for (ObjectMap.Entry<NodePart, ArrayMap<String, Matrix4>> e : nodePartBones.entries()) { if (e.key.invBoneBindTransforms == null) e.key.invBoneBindTransforms = new ArrayMap<Node, Matrix4>(Node.class, Matrix4.class); e.key.invBoneBindTransforms.clear(); for (ObjectMap.Entry<String, Matrix4> b : e.value.entries()) e.key.invBoneBindTransforms.put(getNode(b.key), new Matrix4(b.value).inv()); } }
private void setBones () { for (ObjectMap.Entry<NodePart, ArrayMap<Node, Matrix4>> e : nodePartBones.entries()) { if (e.key.invBoneBindTransforms == null) e.key.invBoneBindTransforms = new ArrayMap<Node, Matrix4>(true, e.value.size, Node.class, Matrix4.class); e.key.invBoneBindTransforms.clear(); for (final ObjectMap.Entry<Node, Matrix4> b : e.value.entries()) e.key.invBoneBindTransforms.put(getNode(b.key.id), b.value); // Share the inv bind matrix with the model e.key.bones = new Matrix4[e.value.size]; for (int i = 0; i < e.key.bones.length; i++) e.key.bones[i] = new Matrix4(); } }
public Layer(String name, int cols, int rows, int tileWidth, int tileHeight) { this.name = name; this.cols = cols; this.rows = rows; this.tileWidth = tileWidth; this.tileHeight = tileHeight; this.tiles = new ArrayMap<Integer, Tile>(true, this.cols * this.rows); }
public MainMenu(MasterMaze game) { super(game); ArrayMap<String, MenuAction> items = new ArrayMap<String, MenuAction>(); items.put("Start", new ScreenAction(game, "game")); items.put("Highscores", new ScreenAction(game, "highscore")); items.put("Exit", new ExitAction()); this.setMenuItems(items); }
public static void createProject(String foldername){ GdxStudio.log("Creating Project: "+Content.getProject()); Content.setProject(foldername); new File(Content.getProject()+"atlas").mkdir(); new File(Content.getProject()+"font").mkdir(); new File(Content.getProject()+"map").mkdir(); new File(Content.getProject()+"model").mkdir(); new File(Content.getProject()+"music").mkdir(); new File(Content.getProject()+"sound").mkdir(); new File(Content.getProject()+"source").mkdir(); new File(Content.getProject()+"skin").mkdir(); new File(Content.getProject()+"pack").mkdir(); new File(Content.getProject()+"particle").mkdir(); new File(Content.getProject()+"META-INF").mkdir(); ArrayMap<String, String> map = new ArrayMap<String, String>(); map.put("Title", ""); map.put("TargetSize", ""); map.put("ScreenSize", ""); map.put("AudioBufferCount", ""); map.put("Resize", ""); map.put("ForceExit", ""); map.put("FullScreen", ""); map.put("UseGL20", ""); map.put("VSync", ""); map.put("DisableAudio", ""); map.put("KeepAspectRatio", ""); map.put("ShowFPS", ""); map.put("LoggingEnabled", ""); map.put("Version", ""); map.put("Target", ""); File prjFile = new File(Content.getProject()); Export.writeFile("config", Scene.json.toJson(map, ArrayMap.class)); Export.writeFile(".project", eclipse_project.replace("$$$", prjFile.getName())); Frame.setEnabledProject(); createJar(); }
/** * * @param pRegion * @param pRatioX * @param pRatioY */ public ParallaxLayer(World world, String layer_name, float pRatioX, float pRatioY) { this.world = world; this.layer_name = layer_name; layer_objects = new Array<MapObject>(); layer_textures = new ArrayMap<String, Texture>(); ratioX = pRatioX; ratioY = pRatioY; loadObjects(); }
private void loadNodes (Iterable<ModelNode> modelNodes) { nodePartBones.clear(); for (ModelNode node : modelNodes) { nodes.add(loadNode(null, node)); } for (ObjectMap.Entry<NodePart, ArrayMap<String, Matrix4>> e : nodePartBones.entries()) { if (e.key.invBoneBindTransforms == null) e.key.invBoneBindTransforms = new ArrayMap<Node, Matrix4>(Node.class, Matrix4.class); e.key.invBoneBindTransforms.clear(); for (ObjectMap.Entry<String, Matrix4> b : e.value.entries()) e.key.invBoneBindTransforms.put(getNode(b.key), new Matrix4(b.value).inv()); } }
private void setBones() { for (ObjectMap.Entry<NodePart,ArrayMap<Node, Matrix4>> e : nodePartBones.entries()) { if (e.key.invBoneBindTransforms == null) e.key.invBoneBindTransforms = new ArrayMap<Node, Matrix4>(true, e.value.size, Node.class, Matrix4.class); e.key.invBoneBindTransforms.clear(); for (final ObjectMap.Entry<Node, Matrix4> b : e.value.entries()) e.key.invBoneBindTransforms.put(getNode(b.key.id), b.value); // Share the inv bind matrix with the model e.key.bones = new Matrix4[e.value.size]; for (int i = 0; i < e.key.bones.length; i++) e.key.bones[i] = new Matrix4(); } }
@Override public void create() { Dialog.fadeDuration = 0.01f; Gdx.input.setCatchMenuKey(true); Gdx.input.setCatchBackKey(true); screens = new ArrayMap<String, Screen>(); setScreen("MainMenuScreen"); }
public StageList() { stageArrayMap = new ArrayMap<String, Stage>(50); }
public ArrayMap read (Kryo kryo, Input input, Class<ArrayMap> type) { boolean ordered = input.readBoolean(); int length = input.readVarInt(true); Class knownKeyClass = kryo.readClass(input).getType(); Class knownValueClass = kryo.readClass(input).getType(); ArrayMap map = new ArrayMap(ordered, length, knownKeyClass, knownValueClass); Class keyClass = null; Class valueClass = null; Serializer keySerializer = null; if (keyGenericType != null) { keyClass = keyGenericType; if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass); keyGenericType = null; } Serializer valueSerializer = null; if (valueGenericType != null) { valueClass = valueGenericType; if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass); valueGenericType = null; } kryo.reference(map); for (int i = 0; i < length; i++) { Object key; if (keySerializer != null) { key = kryo.readObject(input, keyClass, keySerializer); } else key = kryo.readClassAndObject(input); Object value; if (valueSerializer != null) { value = kryo.readObjectOrNull(input, valueClass, valueSerializer); } else value = kryo.readClassAndObject(input); map.put(key, value); } return map; }
public ArrayMap copy (Kryo kryo, ArrayMap original) { ArrayMap map = new ArrayMap(original); kryo.reference(map); return map; }
@Override public ArrayMap<String, Integer> getMarkers() { return markers; }