All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sangupta.blogparser.domain.Blog Maven / Gradle / Ivy

The newest version!
/**
 *
 * BlogParser - Parsing library for Blog exports 
 * Copyright (c) 2012, Sandeep Gupta
 * 
 * http://www.sangupta/projects/blog-parser
 * 
 * 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.sangupta.blogparser.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * Strongly-typed object representing the entire blog.
 * 
 * @author sangupta
 * @since 1.0
 */
public class Blog {
	
	/**
	 * Title of the blog
	 */
	private String title;
	
	/**
	 * Description of the blog, if provided
	 */
	private String description;
	
	/**
	 * Absolute URL of the blog
	 */
	private String url;
	
	/**
	 * All posts available in this blog
	 */
	private List posts;
	
	/**
	 * All authors of this blog
	 */
	private List authors;
	
	/**
	 * All pages available in this blog
	 */
	private List pages;
	
	/**
	 * Add an author to this blog
	 * 
	 * @param author
	 */
	public void addAuthor(Author author) {
		if(this.authors == null) {
			this.authors = new ArrayList();
		}
		
		this.authors.add(author);
	}
	
	/**
	 * Add a post to this blog
	 * 
	 * @param post
	 */
	public void addPost(BlogPost post) {
		if(this.posts == null) {
			this.posts = new ArrayList();
		}
		
		this.posts.add(post);
	}
	
	/**
	 * Add a page to this blog
	 * 
	 * @param page
	 */
	public void addPage(BlogPage page) {
		if(this.pages == null) {
			this.pages = new ArrayList();			
		}
		
		this.pages.add(page);
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null) {
			return false;
		}
		
		if(!(obj instanceof Blog)) {
			return false;
		}
		
		Blog blog = (Blog) obj;
		return this.url.equals(blog.getUrl());
	}
	
	@Override
	public int hashCode() {
		return this.url.hashCode();
	}
	
	@Override
	public String toString() {
		return "[Blog: " + this.url + "]";
	}
	
	// Usual accessors follow

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * @return the posts
	 */
	public List getPosts() {
		return posts;
	}

	/**
	 * @param posts the posts to set
	 */
	public void setPosts(List posts) {
		this.posts = posts;
	}

	/**
	 * @return the authors
	 */
	public List getAuthors() {
		return authors;
	}

	/**
	 * @param authors the authors to set
	 */
	public void setAuthors(List authors) {
		this.authors = authors;
	}

	/**
	 * @return the pages
	 */
	public List getPages() {
		return pages;
	}

	/**
	 * @param pages the pages to set
	 */
	public void setPages(List pages) {
		this.pages = pages;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy