Java tutorial
/** * *************************************************************************** * Copyright (c) 2010 Qcadoo Limited * Project: Qcadoo Framework * Version: 1.3 * * This file is part of Qcadoo. * * Qcadoo 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, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *************************************************************************** */ package com.qcadoo.model.beans.qcadooPlugin; import java.util.Locale; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import org.apache.commons.lang3.StringUtils; import com.qcadoo.plugin.api.Plugin; @Entity @Table(name = "qcadooplugin_plugin") public class QcadooPluginPlugin { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column private String identifier; @Column private String version; @Column private String state; @Column private boolean isSystem; public QcadooPluginPlugin() { // empty } public QcadooPluginPlugin(final Plugin plugin) { identifier = plugin.getIdentifier(); version = plugin.getVersion().toString(); setState(plugin.getState().toString()); isSystem = plugin.isSystemPlugin(); } public String getIdentifier() { return identifier; } public void setIdentifier(final String identifier) { this.identifier = identifier; } public String getState() { return state; } public void setState(final String state) { this.state = StringUtils.trim(StringUtils.upperCase(state, Locale.ENGLISH)); } public String getVersion() { return version; } public void setVersion(final String version) { this.version = version; } public void setId(final Long id) { this.id = id; } public Long getId() { return id; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); result = prime * result + ((state == null) ? 0 : state.hashCode()); result = prime * result + ((version == null) ? 0 : version.hashCode()); return result; } @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof QcadooPluginPlugin)) { return false; } QcadooPluginPlugin other = (QcadooPluginPlugin) obj; if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (identifier == null) { if (other.identifier != null) { return false; } } else if (!identifier.equals(other.identifier)) { return false; } if (!state.equals(other.state)) { return false; } if (version == null) { if (other.version != null) { return false; } } else if (!version.equals(other.version)) { return false; } if (isSystem != other.isSystem) { return false; } return true; } public boolean getIsSystem() { return isSystem; } public void setIsSystem(final boolean isSystem) { this.isSystem = isSystem; } }