blob: 643abacd1824024ee9651c8f7e123baa443ace3e [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2016 IBM Corporation and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
*******************************************************************************/
package org.eclipse.dltk.ti.goals;
import org.eclipse.dltk.ti.IContext;
public abstract class AbstractGoal implements IGoal {
protected final IContext context;
public AbstractGoal(IContext context) {
this.context = context;
}
@Override
public IContext getContext() {
return context;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((context == null) ? 0 : context.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;
AbstractGoal other = (AbstractGoal) obj;
if (context == null) {
if (other.context != null)
return false;
} else if (!context.equals(other.context))
return false;
return true;
}
protected String getClassName() {
String name = getClass().getName();
int pos = name.lastIndexOf('.');
if (pos > 0) {
return name.substring(pos + 1);
} else {
return name;
}
}
}