/******************************************************************************* * Copyright (c) 2012-2015 INRIA. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Generoso Pagano - initial API and implementation ******************************************************************************/ package fr.inria.soctrace.lib.model; import fr.inria.soctrace.lib.model.utils.SoCTraceException; /** * Class representing the EVENT_PARAM_TYPE entity of the data model. * * @author "Generoso Pagano <generoso.pagano@inria.fr>" * */ public class EventParamType implements IModelElement, IGroupable { private final int id; private EventType eventType; private String name; private String type; /** * Constructor * @param id the entity unique id */ public EventParamType(int id) { this.id = id; } /** * @return the eventType */ public EventType getEventType() { return eventType; } /** * Note: the EventParamType is added to the EventType as well. * @param eventType the eventType to set */ public void setEventType(EventType eventType) { this.eventType = eventType; this.eventType.addEventParamType(this); } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the type */ public String getType() { return type; } /** * @param type the type to set */ public void setType(String type) { this.type = type; } /** * @return the id */ public int getId() { return id; } @Override public String toString() { return "EventParamType[(id:" + getId() + ")," + "(event_type.name:\"" + getEventType().getName() + "\")," + "(type:\"" + getType() + "\"),(name:\"" + getName() + "\")]"; } @Override public void accept(IModelVisitor visitor) throws SoCTraceException { visitor.visit(this); } /* Note to equals and hashCode. * * Compare only ID, NAME, TYPE to avoid recursive check. */ /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + id; result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof EventParamType)) return false; EventParamType other = (EventParamType) obj; if (id != other.id) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (type == null) { if (other.type != null) return false; } else if (!type.equals(other.type)) return false; return true; } }