/**
 * Copyright (c) Anton Johansson <antoon.johansson@gmail.com>
 *
 * 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 com.antonjohansson.counterstrike.dto.meta;

import com.antonjohansson.counterstrike.domain.counterstrikeoverview.counterstrikeoverviewtest.counterstrikeoverviewtest.map.Map;

import static org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString;
import static org.apache.commons.lang3.builder.ToStringStyle.SHORT_PREFIX_STYLE;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * Data-transfer object for maps.
 *
 * @author Anton Johansson
 */
public class MapDto
{
	private long mapId;
	private String mapName = "";

	/**
	 * Constructs a new, empty {@link MapDto}.
	 */
	public MapDto() {}

	/**
	 * Constructs a new {@link MapDto} from given {@link Map}.
	 *
	 * @param map The map to construct from.
	 */
	public MapDto(Map map)
	{
		this.mapId = map.getMapId();
		this.mapName = map.getMapName();
	}

	public long getMapId()
	{
		return mapId;
	}

	public void setMapId(long mapId)
	{
		this.mapId = mapId;
	}

	public String getMapName()
	{
		return mapName;
	}

	public void setMapName(String mapName)
	{
		this.mapName = mapName;
	}

	/** {@inheritDoc} */
	@Override
	public int hashCode()
	{
		return new HashCodeBuilder().append(mapId).toHashCode();
	}

	/** {@inheritDoc} */
	@Override
	public boolean equals(Object obj)
	{
		if (obj == this)
		{
			return true;
		}
		if (!(obj instanceof MapDto))
		{
			return false;
		}

		MapDto that = (MapDto) obj;
		return new EqualsBuilder()
				.append(this.mapId, that.mapId)
				.append(this.mapName, that.mapName)
				.isEquals();
	}

	/** {@inheritDoc} */
	@Override
	public String toString()
	{
		return reflectionToString(this, SHORT_PREFIX_STYLE);
	}
}
