org.conqat.engine.index.shared.PreCommitUploadData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of teamscale-commons Show documentation
Show all versions of teamscale-commons Show documentation
Provides common DTOs for Teamscale
/*-------------------------------------------------------------------------+
| |
| Copyright (c) 2009-2017 CQSE GmbH |
| |
+-------------------------------------------------------------------------*/
package org.conqat.engine.index.shared;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import org.conqat.lib.commons.collections.CollectionUtils;
import org.conqat.lib.commons.collections.UnmodifiableMap;
import org.conqat.lib.commons.collections.UnmodifiableSet;
import org.conqat.lib.commons.uniformpath.UniformPath;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Data class for a pre-commit upload. */
public class PreCommitUploadData implements Serializable {
/** Default serial version UID */
private static final long serialVersionUID = 1L;
/**
* A mapping from uniform paths to the content of the respective file. This
* should contain all the changes that need to be analyzed.
*/
@JsonProperty("uniformPathToContentMap")
private final HashMap uniformPathToContentMap = new HashMap<>();
/** Set of uniform paths that have been deleted. */
@JsonProperty("deletedUniformPaths")
private final HashSet deletedUniformPaths = new HashSet<>();
@JsonCreator
public PreCommitUploadData() {
// Used for JSON deserialization
}
/**
* Constructor.
*/
public PreCommitUploadData(Map uniformPathToContentMap,
Collection deletedUniformPaths) {
for (Entry entry : uniformPathToContentMap.entrySet()) {
UniformPath uniformPath = entry.getKey();
String content = entry.getValue();
this.uniformPathToContentMap.put(uniformPath.toString(), content);
}
for (UniformPath uniformPath : deletedUniformPaths) {
this.deletedUniformPaths.add(uniformPath.toString());
}
}
/** @see #uniformPathToContentMap */
public UnmodifiableMap getUniformPathToContentMap() {
return CollectionUtils.asUnmodifiable(uniformPathToContentMap);
}
/** @see #deletedUniformPaths */
public UnmodifiableSet getDeletedUniformPaths() {
return CollectionUtils.asUnmodifiable(deletedUniformPaths);
}
/** Validates if the content has been properly set. */
public boolean isValid() {
return deletedUniformPaths != null && uniformPathToContentMap != null;
}
/** Returns true if no files are deleted and no files are new or changed. */
public boolean isEmpty() {
return deletedUniformPaths.isEmpty() && uniformPathToContentMap.isEmpty();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy