com.cubeia.backoffice.users.entity.UserAttribute.java Source code

Java tutorial

Introduction

Here is the source code for com.cubeia.backoffice.users.entity.UserAttribute.java

Source

/**
 * Copyright (C) 2010 Cubeia Ltd <info@cubeia.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.cubeia.backoffice.users.entity;

import static org.apache.commons.lang.builder.ToStringStyle.SHORT_PREFIX_STYLE;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Index;

@Entity
@Table(name = "UserAttribute", uniqueConstraints = { @UniqueConstraint(columnNames = { "akey", "user_id" }) })
public class UserAttribute implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;

    private String key;

    private String value;

    private User user;

    public UserAttribute() {
    }

    public UserAttribute(User user, String key, String value) {
        this.user = user;
        this.key = key;
        this.value = value;
    }

    public UserAttribute(Long id, User user, String key, String value) {
        this.id = id;
        this.user = user;
        this.key = key;
        this.value = value;
    }

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

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

    @Column(name = "akey", length = 32)
    @Index(name = "attribute_key_idx")
    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    @Lob
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @ManyToOne
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, SHORT_PREFIX_STYLE).append("id", getId()).append("value", getValue())
                .toString();
    }

}