/**
 * This file is part of the Meeds project (https://meeds.io/).
 *
 * Copyright (C) 2020 - 2025 Meeds Association contact@meeds.io
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package org.exoplatform.services.organization.impl;

import java.util.Date;
import java.util.Objects;

import org.exoplatform.services.organization.ExtendedCloneable;
import org.exoplatform.services.organization.MembershipType;

public class MembershipTypeImpl implements MembershipType, ExtendedCloneable {
  private static final long serialVersionUID = -8441178538275068955L;

  private String name;

  private String description;

  private String owner;

  private Date createdDate;

  private Date modifiedDate;

  public MembershipTypeImpl() {
  }

  public MembershipTypeImpl(String name, String owner, String desc) {
    this.name = name;
    this.owner = owner;
    this.description = desc;
  }

  public String getName() {
    return name;
  }

  public void setName(String s) {
    name = s;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String s) {
    description = s;
  }

  public String getOwner() {
    return owner;
  }

  public void setOwner(String s) {
    owner = s;
  }

  public Date getCreatedDate() {
    return createdDate;
  }

  public void setCreatedDate(Date d) {
    createdDate = d;
  }

  public Date getModifiedDate() {
    return modifiedDate;
  }

  public void setModifiedDate(Date d) {
    modifiedDate = d;
  }

  /**
   * {@inheritDoc}
   **/
  public MembershipTypeImpl clone() {
    MembershipTypeImpl mti;
    try {
      mti = (MembershipTypeImpl) super.clone();
      if (createdDate != null) {
        mti.createdDate = (Date) createdDate.clone();
      }
      if (modifiedDate != null) {
        mti.modifiedDate = (Date) modifiedDate.clone();
      }
    } catch (CloneNotSupportedException e) {
      return this;
    }

    return mti;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    MembershipTypeImpl that = (MembershipTypeImpl) o;
    return Objects.equals(name, that.name) &&
            Objects.equals(description, that.description) &&
            Objects.equals(owner, that.owner) &&
            Objects.equals(createdDate, that.createdDate) &&
            Objects.equals(modifiedDate, that.modifiedDate);
  }

  @Override
  public int hashCode() {
    return Objects.hash(name, description, owner, createdDate, modifiedDate);
  }
}
