tools.dynamia.domain.EntityReference Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2023 Dynamia Soluciones IT S.A.S - NIT 900302344-1
* Colombia / South America
*
* 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 tools.dynamia.domain;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
public class EntityReference implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3969866122612228133L;
private ID id;
private String name;
private String className;
private String description;
private final Map attributes = new HashMap<>();
public EntityReference() {
}
public EntityReference(ID id, String className) {
super();
this.id = id;
this.className = className;
}
public EntityReference(ID id, String className, String name) {
super();
this.id = id;
this.name = name;
this.className = className;
}
public ID getId() {
return id;
}
public void setId(ID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void addAttribute(String name, Object value) {
attributes.put(name, value);
}
public Object getAttribute(String name) {
return attributes.get(name);
}
public Map getAttributes() {
return attributes;
}
@Override
public String toString() {
return name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
EntityReference other = (EntityReference) obj;
if (className == null) {
if (other.className != null) {
return false;
}
} else if (!className.equals(other.className)) {
return false;
}
if (id == null) {
return other.id == null;
} else return id.equals(other.id);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy