package org.jenkinsci.plugins.p4.scm.swarm;

import java.io.File;

public class P4Path {

	private final String path;
	private final String revision;

	public P4Path(String path, String revision) {
		this.path = path;
		this.revision = revision;
	}

	public P4Path(String path) {
		this.path = path;
		this.revision = null;
	}

	public String getPathBuilder(String file) {
		String filePath = path + File.separator + file;
		if (getRevision() == null) {
			return filePath;
		} else {
			return filePath + "@" + getRevision();
		}
	}

	public String getName() {
		String p = getPath();
		if (p.startsWith("//")) {
			p = p.substring("//".length());
			p = p.replaceAll("/", ".");
		}

		String r = getRevision();
		if (r != null && r.startsWith("refs/pull/")) {
			r = r.substring("refs/pull/".length());
		}
		r = r.replaceAll("/", ".");

		return p + "." + r;
	}

	public String getPath() {
		return path;
	}

	public String getRevision() {
		if (revision != null && revision.startsWith("refs/heads/")) {
			return revision.substring("refs/heads/".length());
		}
		return revision;
	}
}

@@ -63,30 +63,134 @@
 le;%0A
-%0Apublic class P4Path %7B
+import java.io.Serializable;%0A%0Apublic class P4Path implements Serializable %7B%0A%0A%09private static final long serialVersionUID = 1L;
 %0A%0A%09p
@@ -825,20 +825,26 @@
  != null
- && 
+) %7B%0A%09%09%09if(
 r.starts
@@ -861,24 +861,25 @@
 /pull/%22)) %7B%0A
+%09
 %09%09%09r = r.sub
@@ -911,18 +911,20 @@
 h());%0A%09%09
+%09
 %7D%0A
+%09
 %09%09r = r.
@@ -944,16 +944,20 @@
 %22, %22.%22);
+%0A%09%09%7D
 %0A%0A%09%09retu

Fix FindBug Errors.