
com.buschmais.jqassistant.plugin.common.api.report.Generic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
The jQAssistant Plugin Common provides a set of common
classes which can be used by all jQAssistant plugins.
The newest version!
package com.buschmais.jqassistant.plugin.common.api.report;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Optional;
import com.buschmais.jqassistant.core.report.api.SourceProvider;
import com.buschmais.jqassistant.core.report.api.model.Language;
import com.buschmais.jqassistant.core.report.api.model.LanguageElement;
import com.buschmais.jqassistant.core.report.api.model.source.FileLocation;
import com.buschmais.jqassistant.core.store.api.model.Descriptor;
import com.buschmais.jqassistant.plugin.common.api.model.ArtifactFileDescriptor;
import com.buschmais.jqassistant.plugin.common.api.model.FileDescriptor;
import com.buschmais.jqassistant.plugin.common.api.model.NamedDescriptor;
import static java.util.Optional.empty;
/**
* Defines generic language elements.
*/
@Language
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Generic {
GenericLanguageElement value();
enum GenericLanguageElement implements LanguageElement {
/**
* Named elements.
*/
Named {
@Override
public SourceProvider getSourceProvider() {
return new SourceProvider() {
@Override
public String getName(NamedDescriptor descriptor) {
return descriptor.getName();
}
@Override
public Optional getSourceLocation(NamedDescriptor descriptor) {
if (descriptor instanceof FileDescriptor) {
return FileSourceHelper.getSourceLocation((FileDescriptor) descriptor, empty(), empty());
}
return empty();
}
};
}
},
/**
* Files.
*/
File {
@Override
public SourceProvider extends Descriptor> getSourceProvider() {
return new SourceProvider() {
@Override
public String getName(FileDescriptor descriptor) {
return descriptor.getFileName();
}
@Override
public Optional getSourceLocation(FileDescriptor descriptor) {
return FileSourceHelper.getSourceLocation(descriptor, empty(), empty());
}
};
}
},
/**
* Artifacts.
*/
ArtifactFile {
@Override
public SourceProvider extends Descriptor> getSourceProvider() {
return new SourceProvider() {
@Override
public String getName(ArtifactFileDescriptor descriptor) {
return descriptor.getFullQualifiedName() != null ? descriptor.getFullQualifiedName() : descriptor.getFileName();
}
@Override
public Optional getSourceLocation(ArtifactFileDescriptor descriptor) {
return FileSourceHelper.getSourceLocation(descriptor, empty(), empty());
}
};
}
};
@Override
public String getLanguage() {
return "Generic";
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy