com.joshlong.esb.springintegration.modules.net.feed.web.test.NewsItem.java Source code

Java tutorial

Introduction

Here is the source code for com.joshlong.esb.springintegration.modules.net.feed.web.test.NewsItem.java

Source

/*
 * Copyright 2010 the original author or authors
 *
 *     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.joshlong.esb.springintegration.modules.net.feed.web.test;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import java.util.Date;
import java.util.UUID;

/**
 * @author <a href="mailto:josh@joshlong.com">Josh Long</a> BS DTO so I have something to help test with
 */
public class NewsItem implements Comparable<NewsItem> {
    private String title;
    private Date date;
    private String body;
    private String id;

    public NewsItem() {
        this.id = UUID.randomUUID().toString();
    }

    public NewsItem(final String title, final Date date, final String body) {

        this();
        this.title = title;
        this.date = date;
        this.body = body;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    @Override
    public boolean equals(final Object o) {
        return EqualsBuilder.reflectionEquals(this, o);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(final String title) {
        this.title = title;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(final Date date) {
        this.date = date;
    }

    public String getBody() {
        return body;
    }

    public void setBody(final String body) {
        this.body = body;
    }

    public String getId() {
        return id;
    }

    public void setId(final String id) {
        this.id = id;
    }

    public int compareTo(final NewsItem newsItem) {
        return CompareToBuilder.reflectionCompare(this, newsItem);
    }
}