net.spals.appbuilder.graph.model.ServiceTreeVertex Maven / Gradle / Ivy
package net.spals.appbuilder.graph.model;
import com.google.auto.value.AutoValue;
import com.google.common.base.Preconditions;
import com.google.inject.Key;
import java.util.Optional;
import static net.spals.appbuilder.graph.model.ServiceGraphVertex.DEFAULT_SEPARATOR;
/**
* @author tkral
*/
@AutoValue
public abstract class ServiceTreeVertex implements IServiceTreeVertex {
abstract IServiceDAGVertex getDelegate();
static ServiceTreeVertex createTreeChild(final IServiceDAGVertex delegate,
final IServiceTreeVertex> parent) {
Preconditions.checkNotNull(parent);
return new AutoValue_ServiceTreeVertex<>(delegate, Optional.of(parent));
}
static ServiceTreeVertex createTreeRoot(final IServiceDAGVertex delegate) {
return new AutoValue_ServiceTreeVertex<>(delegate, Optional.empty());
}
@Override
public final Key getGuiceKey() {
return getDelegate().getGuiceKey();
}
@Override
public final T getServiceInstance() {
return getDelegate().getServiceInstance();
}
@Override
public abstract Optional> getParent();
@Override
public final Optional> getProviderSource() {
return getDelegate().getProviderSource();
}
@Override
public String toString() {
return toString(DEFAULT_SEPARATOR);
}
@Override
public final String toString(final String separator) {
return getDelegate().toString(separator);
}
}