All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codetracker.element.Class Maven / Gradle / Ivy

Go to download

A refactoring-aware tool that can generate the commit change history of code elements with a very high accuracy.

There is a newer version: 2.6
Show newest version
package org.codetracker.element;

import gr.uom.java.xmi.LocationInfo;
import gr.uom.java.xmi.UMLAbstractClass;
import org.codetracker.api.Version;

import static org.codetracker.util.Util.annotationsToString;
import static org.codetracker.util.Util.getPath;

public class Class extends BaseCodeElement {
    private final UMLAbstractClass umlClass;

    private Class(UMLAbstractClass umlClass, String identifierExcludeVersion, String name, String filePath, Version version) {
        super(identifierExcludeVersion, name, filePath, version);
        this.umlClass = umlClass;
    }

    public static Class of(UMLAbstractClass umlClass, Version version) {
        String sourceFolder = getPath(umlClass.getLocationInfo().getFilePath(), umlClass.getName());
        String packageName = umlClass.getPackageName();
        String name = umlClass.getName().replace(umlClass.getPackageName(), "").replace(".", "");
        String modifiersString = new ModifiersBuilder()
                .isFinal(umlClass.isFinal())
                .isStatic(umlClass.isStatic())
                .isAbstract(umlClass.isAbstract())
                .build();
        String visibility = umlClass.getVisibility().toString();
        String identifierExcludeVersion = String.format("%s%s.(%s)%s(%s)%s%s", sourceFolder, packageName, visibility, modifiersString, umlClass.getTypeDeclarationKind(), name, annotationsToString(umlClass.getAnnotations()));
        String className = String.format("%s%s.(%s)%s%s(%d)", sourceFolder, packageName, visibility, modifiersString, name, umlClass.getLocationInfo().getStartLine());
        return new Class(umlClass, identifierExcludeVersion, className, umlClass.getLocationInfo().getFilePath(), version);
    }

    public UMLAbstractClass getUmlClass() {
        return umlClass;
    }

    @Override
    public LocationInfo getLocation() {
        return umlClass.getLocationInfo();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy