001/*
002 *  Copyright 2018 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.repository.data;
017
018import java.time.ZonedDateTime;
019import java.util.Objects;
020
021/**
022 * A comment on a data. 
023 */
024public class DataComment
025{
026    private final String _comment;
027    private final ZonedDateTime _date;
028    private final String _author;
029    
030    /**
031     * Constructor
032     * @param comment The comment text
033     * @param date The date of the comment
034     * @param author The full name of the author
035     */
036    public DataComment(String comment, ZonedDateTime date, String author)
037    {
038        _comment = comment;
039        _date = date;
040        _author = author;
041    }
042    
043    /**
044     * Retrieves the comment.
045     * @return the comment
046     */
047    public String getComment()
048    {
049        return _comment;
050    }
051
052    /**
053     * Retrieves the date.
054     * @return the date
055     */
056    public ZonedDateTime getDate()
057    {
058        return _date;
059    }
060
061    /**
062     * Retrieves the author.
063     * @return the author
064     */
065    public String getAuthor()
066    {
067        return _author;
068    }
069
070    @Override
071    public int hashCode()
072    {
073        return Objects.hash(_author, _comment, _date);
074    }
075
076    @Override
077    public boolean equals(Object obj)
078    {
079        if (this == obj)
080        {
081            return true;
082        }
083        if (obj == null)
084        {
085            return false;
086        }
087        if (getClass() != obj.getClass())
088        {
089            return false;
090        }
091        DataComment other = (DataComment) obj;
092        return Objects.equals(_author, other._author) && Objects.equals(_comment, other._comment) && _date.isEqual(other._date);
093    }
094}