001/* 002 * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. 003 * Copyright (C) 2000-2010 The Gridarta Developers. 004 * 005 * This program is free software; you can redistribute it and/or modify 006 * it under the terms of the GNU General Public License as published by 007 * the Free Software Foundation; either version 2 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU General Public License for more details. 014 * 015 * You should have received a copy of the GNU General Public License along 016 * with this program; if not, write to the Free Software Foundation, Inc., 017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 018 */ 019 020package net.sf.gridarta.model.io; 021 022import java.io.File; 023import java.io.IOException; 024import net.sf.gridarta.model.archetype.TestArchetype; 025import net.sf.gridarta.model.gameobject.TestGameObject; 026import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; 027import net.sf.gridarta.model.maparchobject.TestMapArchObject; 028import org.jetbrains.annotations.NotNull; 029 030/** 031 * An {@link MapReaderFactory} implementation for testing purposes. 032 * @author Andreas Kirschbaum 033 */ 034public class TestMapReaderFactory implements MapReaderFactory<TestGameObject, TestMapArchObject> { 035 036 /** 037 * The {@link MapArchObjectParserFactory} instance. 038 */ 039 @NotNull 040 private final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory; 041 042 /** 043 * The {@link MapArchObjectFactory} instance. 044 */ 045 @NotNull 046 private final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory; 047 048 /** 049 * The {@link GameObjectParser} instance. 050 */ 051 @NotNull 052 private final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser; 053 054 /** 055 * Creates a new instance. 056 * @param mapArchObjectParserFactory the map arch object parser factory 057 * instance 058 * @param mapArchObjectFactory the map arch object factory instance 059 * @param gameObjectParser the game object parser instance 060 */ 061 public TestMapReaderFactory(@NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser) { 062 this.mapArchObjectParserFactory = mapArchObjectParserFactory; 063 this.mapArchObjectFactory = mapArchObjectFactory; 064 this.gameObjectParser = gameObjectParser; 065 } 066 067 /** 068 * {@inheritDoc} 069 */ 070 @NotNull 071 @Override 072 public MapReader<TestGameObject, TestMapArchObject> newMapReader(@NotNull final File file) throws IOException { 073 return new DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, file); 074 } 075 076}