gr.uom.java.xmi.UMLInitializer Maven / Gradle / Ivy
package gr.uom.java.xmi;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import gr.uom.java.xmi.decomposition.AbstractCall;
import gr.uom.java.xmi.decomposition.AnonymousClassDeclarationObject;
import gr.uom.java.xmi.decomposition.LambdaExpressionObject;
import gr.uom.java.xmi.decomposition.OperationBody;
import gr.uom.java.xmi.decomposition.VariableDeclaration;
import gr.uom.java.xmi.diff.CodeRange;
public class UMLInitializer implements Serializable, VariableDeclarationContainer {
private LocationInfo locationInfo;
private String name;
private String className;
private boolean isStatic;
private Optional anonymousClassContainer;
private OperationBody body;
private List anonymousClassList;
private UMLJavadoc javadoc;
private List comments;
private Map> variableDeclarationMap;
public UMLInitializer(String name, LocationInfo locationInfo) {
this.name = name;
this.locationInfo = locationInfo;
this.comments = new ArrayList();
this.anonymousClassList = new ArrayList();
}
public boolean isStatic() {
return isStatic;
}
public void setStatic(boolean isStatic) {
this.isStatic = isStatic;
}
public UMLJavadoc getJavadoc() {
return javadoc;
}
public void setJavadoc(UMLJavadoc javadoc) {
this.javadoc = javadoc;
}
public List getComments() {
return comments;
}
@Override
public LocationInfo getLocationInfo() {
return locationInfo;
}
@Override
public CodeRange codeRange() {
LocationInfo info = getLocationInfo();
return info.codeRange();
}
@Override
public List getParameterDeclarationList() {
return Collections.emptyList();
}
@Override
public List getParameterTypeList() {
return Collections.emptyList();
}
@Override
public List getParameterNameList() {
return Collections.emptyList();
}
@Override
public List getParametersWithoutReturnType() {
return Collections.emptyList();
}
@Override
public int getNumberOfNonVarargsParameters() {
return 0;
}
@Override
public boolean hasVarargsParameter() {
return false;
}
@Override
public OperationBody getBody() {
return body;
}
public void setBody(OperationBody body) {
this.body = body;
}
public void addAnonymousClass(UMLAnonymousClass anonymous) {
this.anonymousClassList.add(anonymous);
}
public boolean isDeclaredInAnonymousClass() {
return anonymousClassContainer != null && anonymousClassContainer.isPresent();
}
@Override
public boolean isGetter() {
return false;
}
@Override
public boolean isConstructor() {
return false;
}
@Override
public AbstractCall isDelegate() {
return null;
}
public Optional getAnonymousClassContainer() {
return anonymousClassContainer;
}
public void setAnonymousClassContainer(UMLAnonymousClass anonymousClass) {
this.anonymousClassContainer = Optional.of(anonymousClass);
}
@Override
public List getAnonymousClassList() {
return anonymousClassList;
}
@Override
public List getAllLambdas() {
return body.getAllLambdas();
}
@Override
public List getAllOperationInvocations() {
return body.getAllOperationInvocations();
}
@Override
public List getAllCreations() {
return body.getAllCreations();
}
@Override
public List getAllVariables() {
return body.getAllVariables();
}
@Override
public String getName() {
return name;
}
@Override
public String getElementType() {
return "initializer";
}
@Override
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String toString() {
return name;
}
@Override
public String toQualifiedString() {
return name;
}
@Override
public Map> variableDeclarationMap() {
if(this.variableDeclarationMap == null) {
this.variableDeclarationMap = new LinkedHashMap>();
for(VariableDeclaration declaration : getAllVariableDeclarations()) {
if(variableDeclarationMap.containsKey(declaration.getVariableName())) {
variableDeclarationMap.get(declaration.getVariableName()).add(declaration);
}
else {
Set variableDeclarations = new LinkedHashSet();
variableDeclarations.add(declaration);
variableDeclarationMap.put(declaration.getVariableName(), variableDeclarations);
}
}
}
return variableDeclarationMap;
}
@Override
public UMLAnonymousClass findAnonymousClass(AnonymousClassDeclarationObject anonymousClassDeclaration) {
for(UMLAnonymousClass anonymousClass : this.getAnonymousClassList()) {
if(anonymousClass.getLocationInfo().equals(anonymousClassDeclaration.getLocationInfo())) {
return anonymousClass;
}
}
return null;
}
@Override
public boolean hasTestAnnotation() {
return false;
}
@Override
public boolean hasParameterizedTestAnnotation() {
return false;
}
@Override
public boolean hasSetUpAnnotation() {
return false;
}
@Override
public boolean hasTearDownAnnotation() {
return false;
}
@Override
public boolean isRecursive() {
return false;
}
@Override
public boolean isMain() {
return false;
}
@Override
public List getAnnotations() {
return Collections.emptyList();
}
}