/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.ambari.server.orm.cache;


public class HostConfigMappingImpl implements HostConfigMapping {
  
  private Long clusterId;
  private String hostName;
  private String type;
  private Long createTimestamp;
  private String version;
  private String serviceName;
  private String user;
  private Integer selected;
  

  
  public HostConfigMappingImpl(HostConfigMapping entry) {
    setClusterId(entry.getClusterId());
    setHostName(entry.getHostName());
    setType(entry.getType());
    setCreateTimestamp(entry.getCreateTimestamp());
    setVersion(entry.getVersion());
    setServiceName(entry.getServiceName());
    setUser(entry.getUser());
    setSelected(entry.getSelected());
  }

  public HostConfigMappingImpl() {
  }

  @Override
  public Long getClusterId() {
    return clusterId;
  }
  
  @Override
  public void setClusterId(Long clusterId) {
    if (clusterId == null)
      throw new RuntimeException("ClusterId couldn't be null");
    this.clusterId = clusterId;
  }
  
  @Override
  public String getHostName() {
    return hostName;
  }
  
  @Override
  public void setHostName(String hostName) {
    if (hostName == null)
      throw new RuntimeException("HostName couldn't be null");
    this.hostName = hostName;
  }
  
  @Override
  public String getType() {
    return type;
  }
  
  @Override
  public void setType(String type) {
    if (type == null)
      throw new RuntimeException("Type couldn't be null");
    this.type = type;
  }
  
  @Override
  public Long getCreateTimestamp() {
    return createTimestamp;
  }
  
  @Override
  public void setCreateTimestamp(Long createTimestamp) {
    if (createTimestamp == null)
      throw new RuntimeException("CreateTimestamp couldn't be null");
    this.createTimestamp = createTimestamp;
  }
  
  @Override
  public String getVersion() {
    return version;
  }
  
  @Override
  public void setVersion(String version) {
    if (version == null)
      throw new RuntimeException("Version couldn't be null");
    this.version = version;
  }
  public String getServiceName() {
    return serviceName;
  }
  
  @Override
  public void setServiceName(String serviceName) {
    this.serviceName = serviceName;
  }
  
  @Override
  public String getUser() {
    return user;
  }
  
  @Override
  public void setUser(String user) {
    if (user == null)
      throw new RuntimeException("User couldn't be null");
    this.user = user;
  }

  @Override
  public Integer getSelected() {
    return selected;
  }

  @Override
  public void setSelected(Integer selected) {
    if (selected == null)
      throw new RuntimeException("Selected couldn't be null");
    this.selected = selected;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((clusterId == null) ? 0 : clusterId.hashCode());
    result =
        prime * result
            + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
    result = prime * result + ((hostName == null) ? 0 : hostName.hashCode());
    result = prime * result + ((type == null) ? 0 : type.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    HostConfigMappingImpl other = (HostConfigMappingImpl) obj;
    if (clusterId == null) {
      if (other.clusterId != null)
        return false;
    } else if (!clusterId.equals(other.clusterId))
      return false;
    if (createTimestamp == null) {
      if (other.createTimestamp != null)
        return false;
    } else if (!createTimestamp.equals(other.createTimestamp))
      return false;
    if (hostName == null) {
      if (other.hostName != null)
        return false;
    } else if (!hostName.equals(other.hostName))
      return false;
    if (type == null) {
      if (other.type != null)
        return false;
    } else if (!type.equals(other.type))
      return false;
    return true;
  }
  

}
