#12 -- Add base classes for heuristic
This commit is contained in:
parent
4af08bc9b8
commit
5730954c13
@ -0,0 +1,23 @@
|
||||
package ru.ulstu.extractor.heuristic.api;
|
||||
|
||||
import ru.ulstu.extractor.heuristic.model.BuildTool;
|
||||
import ru.ulstu.extractor.heuristic.model.ProgrammingLanguage;
|
||||
import ru.ulstu.extractor.heuristic.model.StructuralUnit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StructuralUnitIdentifier {
|
||||
List<StructuralUnit> getEntityClasses();
|
||||
|
||||
List<StructuralUnit> getBusinessLogicClasses();
|
||||
|
||||
ProgrammingLanguage getMainProgrammingLanguage();
|
||||
|
||||
boolean isMultiModuleProject();
|
||||
|
||||
BuildTool getBuildTool();
|
||||
|
||||
default boolean canAppliedToProject() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public abstract class BuildTool {
|
||||
private final String name;
|
||||
|
||||
public BuildTool(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
protected abstract boolean canAppliedToProject();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public class GradleBuildTool extends BuildTool {
|
||||
|
||||
public GradleBuildTool() {
|
||||
super("Gradle");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAppliedToProject() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public class JavaProgrammingLanguage extends ProgrammingLanguage {
|
||||
public JavaProgrammingLanguage() {
|
||||
super("Java");
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public abstract class ProgrammingLanguage {
|
||||
private final String name;
|
||||
|
||||
public ProgrammingLanguage(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public abstract class StructuralUnit {
|
||||
private String pathToFile;
|
||||
private String moduleName;
|
||||
|
||||
public String getPathToFile() {
|
||||
return pathToFile;
|
||||
}
|
||||
|
||||
public String getModuleName() {
|
||||
return moduleName;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package ru.ulstu.extractor.heuristic.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.extractor.heuristic.api.StructuralUnitIdentifier;
|
||||
import ru.ulstu.extractor.heuristic.model.BuildTool;
|
||||
import ru.ulstu.extractor.heuristic.model.GradleBuildTool;
|
||||
import ru.ulstu.extractor.heuristic.model.JavaProgrammingLanguage;
|
||||
import ru.ulstu.extractor.heuristic.model.ProgrammingLanguage;
|
||||
import ru.ulstu.extractor.heuristic.model.StructuralUnit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class JavaIdentifier implements StructuralUnitIdentifier {
|
||||
@Override
|
||||
public boolean canAppliedToProject() {
|
||||
return getBuildTool() instanceof GradleBuildTool
|
||||
&& getMainProgrammingLanguage() instanceof JavaProgrammingLanguage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructuralUnit> getEntityClasses() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructuralUnit> getBusinessLogicClasses() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProgrammingLanguage getMainProgrammingLanguage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMultiModuleProject() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuildTool getBuildTool() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package ru.ulstu.extractor.heuristic.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.extractor.heuristic.api.StructuralUnitIdentifier;
|
||||
import ru.ulstu.extractor.heuristic.model.StructuralUnit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class StructuralUnitService {
|
||||
private final List<StructuralUnitIdentifier> structuralUnitIdentifiers;
|
||||
|
||||
public StructuralUnitService(List<StructuralUnitIdentifier> structuralUnitIdentifiers) {
|
||||
this.structuralUnitIdentifiers = structuralUnitIdentifiers;
|
||||
}
|
||||
|
||||
public List<StructuralUnit> getEntities() {
|
||||
StructuralUnitIdentifier selectedIdentifier = structuralUnitIdentifiers.stream()
|
||||
.filter(StructuralUnitIdentifier::canAppliedToProject)
|
||||
.findAny()
|
||||
.orElseThrow(() -> new RuntimeException("Identifier not found"));
|
||||
return selectedIdentifier.getEntityClasses();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user