blob: ab4f2df05c8f22ee8d8618f433e5d56e41954ebd [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2012, 2019 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.internal.rtm.base.ui.editors;
import java.util.UUID;
import org.eclipse.jface.text.AbstractDocument;
import org.eclipse.jface.text.Document;
import org.eclipse.statet.ecommons.text.ISourceFragment;
/**
* Source fragment of an R process
*/
public class RCodeGenSourceFragment implements ISourceFragment {
private final String id;
private final String name;
private final String fullName;
private final AbstractDocument document;
public RCodeGenSourceFragment(final String name, final String fullName) {
this.name= name;
this.fullName= fullName;
this.document= new Document();
this.id= "rtask:" + this.fullName + '-' + UUID.randomUUID(); //$NON-NLS-1$
}
@Override
public String getId() {
return this.id;
}
@Override
public String getName() {
return this.name;
}
@Override
public String getFullName() {
return this.fullName;
}
@Override
public AbstractDocument getDocument() {
return this.document;
}
@Override
public <T> T getAdapter(final Class<T> adapterType) {
return null;
}
@Override
public int hashCode() {
return this.id.hashCode();
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof RCodeGenSourceFragment)) {
return false;
}
final RCodeGenSourceFragment other= (RCodeGenSourceFragment) obj;
return (this.id.equals(other.id)
&& this.fullName.equals(other.fullName)
&& this.document.equals(other.document) );
}
@Override
public String toString() {
return this.fullName;
}
}