blob: 01b9b9775510520932f0c7071b0378d2c0759d48 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010 IBM Corporation and others.
* 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:
* Andrew Eisenberg - iniital version
*******************************************************************************/
package org.eclipse.contribution.xref.core.tests;
import org.eclipse.core.runtime.IAdaptable;
/**
*
* @author Andrew Eisenberg
* @created Dec 5, 2010
*/
public class AdaptableObject implements IAdaptable {
private final Object o;
public AdaptableObject() {
this.o = "";
}
public AdaptableObject(String o) {
this.o = o;
}
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
if (String.class == adapter) {
return o;
}
return null;
}
public Object getObject() {
return o;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((o == null) ? 0 : o.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;
AdaptableObject other = (AdaptableObject) obj;
if (o == null) {
if (other.o != null)
return false;
} else if (!o.equals(other.o))
return false;
return true;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("AdaptableObject [o=");
builder.append(o);
builder.append("]");
return builder.toString();
}
}