/*******************************************************************************
 * Copyright 2013 Raphael Jolivet
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package java2typescript.jackson.module.grammar;

import java.io.IOException;
import java.io.Writer;
import java.util.*;

import com.google.common.base.Preconditions;
import java2typescript.jackson.module.grammar.base.AbstractNamedType;
import java2typescript.jackson.module.grammar.base.AbstractType;
import java2typescript.jackson.module.writer.InternalModuleFormatWriter;

public class Module {

	private String name;

	private Map<String, AbstractNamedType> namedTypes = new HashMap<String, AbstractNamedType>();

	private Map<String, AbstractType> vars = new HashMap<String, AbstractType>();

	private Deque<Class<?>> classesToParse = new LinkedList<>();

	public Module() {
	}

	public Module(String name) {
		this.name = name;
	}

	public Map<String, AbstractNamedType> getNamedTypes() {
		return namedTypes;
	}

	public AbstractNamedType getNamedType(String typeName) {
		return namedTypes.get(typeName);
	}

	public void addNamedType(String typeName, AbstractNamedType namedType, Class<?> originalClass) {
		Preconditions
				.checkNotNull(originalClass, "Please provide original java class that was used to create the named type");
		namedType.setOriginalClass(originalClass);
		namedTypes.put(typeName, namedType);
	}

	public Map<String, AbstractType> getVars() {
		return vars;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void write(Writer writer) throws IOException {
		new InternalModuleFormatWriter().write(this, writer);
	}

	public void addClassesToParse(Collection<? extends Class<?>> classes) {
		this.classesToParse.addAll(classes);
	}

	public Class<?> pollNextClassToParse() {
		return this.classesToParse.poll();
	}

}

@@ -1121,16 +1121,60 @@
 tWriter;
+%0Aimport lombok.Getter;%0Aimport lombok.Setter;
 %0A%0Apublic
@@ -1190,16 +1190,34 @@
 dule %7B%0A%0A
+%09@Getter%0A%09@Setter%0A
 %09private
@@ -1231,16 +1231,25 @@
  name;%0A%0A
+%09@Getter%0A
 %09private
@@ -1309,38 +1309,22 @@
 Map%3C
-String, AbstractNamedType%3E();%0A
+%3E();%0A%0A%09@Getter
 %0A%09pr
@@ -1374,36 +1374,16 @@
 HashMap%3C
-String, AbstractType
 %3E();%0A%0A%09p
@@ -1524,90 +1524,8 @@
 %09%7D%0A%0A
-%09public Map%3CString, AbstractNamedType%3E getNamedTypes() %7B%0A%09%09return namedTypes;%0A%09%7D%0A%0A
 %09pub
@@ -1934,179 +1934,8 @@
 %09%7D%0A%0A
-%09public Map%3CString, AbstractType%3E getVars() %7B%0A%09%09return vars;%0A%09%7D%0A%0A%09public void setName(String name) %7B%0A%09%09this.name = name;%0A%09%7D%0A%0A%09public String getName() %7B%0A%09%09return name;%0A%09%7D%0A%0A
 %09pub

replace some getters/setters with lombok annotations