/*
* Copyright 2012 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.github.carlomicieli.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import org.hibernate.annotations.Index;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.URL;
/**
* It represents a model railroad company.
* @author Carlo Micieli
*
*/
@Entity
@Table(name = "brands")
public class Brand {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
long id;
@NotBlank(message = "brand.name.required")
@Size(max = 25, message = "brand.name.size.notvalid")
@Index(name = "idx_brand_name")
String name;
@URL(message = "brand.website.url.notvalid")
String website;
@Size(max = 250, message = "brand.description.size.notvalid")
String description;
/**
* Create a new brand with <em>null</em> value.
*/
public Brand() { //required
}
/**
* Create a new brand.
* @param id the unique id.
*/
public Brand(long id) {
this.id = id;
}
/**
* Create a new brand.
* @param name the company name.
* @param website the company website url.
*/
public Brand(String name, String website) {
this.name = name;
this.website = website;
}
/**
* Returns the unique id for the <em>Brand</em>.
* @return the unique id.
*/
public long getId() {
return id;
}
/**
* Sets the unique id for the <em>Brand</em>.
* @param id the unique id.
*/
public void setId(long id) {
this.id = id;
}
/**
* Returns the company name.
* @return the company name.
*/
public String getName() {
return name;
}
/**
* Sets the company name.
* @param name the company name.
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the company website url.
* @return the company website url.
*/
public String getWebsite() {
return website;
}
/**
* Sets the company website url.
* @param website the company website url.
*/
public void setWebsite(String website) {
this.website = website;
}
/**
* Returns the short description for the <em>Brand</em>.
* @return the short description.
*/
public String getDescription() {
return description;
}
/**
* Sets the short description for the <em>Brand</em>.
* @param description the short description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Returns a string representation of this <em>Brand</em>.
* @return a string representation of the object.
*/
@Override
public String toString() {
return new StringBuffer()
.append(getId() + ": ")
.append(getName())
.toString();
}
}