aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-02-10 14:37:28 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-02-10 14:38:18 +0100
commitbb882254ad79bfa75140ee4ea99a95ff46b7d11d (patch)
tree0c8a44772048990320cd80b0f41b755c0c3ffb50 /sonar-plugin-api/src
parent53829c96bba989fb21f4888cd0162be946c7a01a (diff)
downloadsonarqube-bb882254ad79bfa75140ee4ea99a95ff46b7d11d.tar.gz
sonarqube-bb882254ad79bfa75140ee4ea99a95ff46b7d11d.zip
fix quality flaws
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java110
1 files changed, 57 insertions, 53 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java
index a83d19fd29b..cd22585f357 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java
@@ -168,6 +168,14 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
this.rootProjectId = guessRootProjectId(resource, parent);
}
+ public Snapshot(ResourceModel resource, boolean last, String status, Date date) {
+ this();
+ setResource(resource);
+ this.status = status;
+ this.last = last;
+ this.createdAt = date.getTime();
+ }
+
private static Integer guessRootProjectId(ResourceModel resource, Snapshot parent) {
Integer result;
if (parent == null) {
@@ -182,14 +190,6 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return session.save(this);
}
- public Snapshot(ResourceModel resource, boolean last, String status, Date date) {
- this();
- setResource(resource);
- this.status = status;
- this.last = last;
- this.createdAt = date.getTime();
- }
-
/**
* Insertion date (technical)
*
@@ -199,10 +199,6 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return longToDate(buildDate);
}
- public Long getBuildDateMs() {
- return buildDate;
- }
-
/**
* Insertion date (technical)
*
@@ -213,6 +209,10 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return this;
}
+ public Long getBuildDateMs() {
+ return buildDate;
+ }
+
public Snapshot setBuildDateMs(Long d) {
this.buildDate = d;
return this;
@@ -222,15 +222,15 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return longToDate(createdAt);
}
- public Long getCreatedAtMs() {
- return createdAt;
- }
-
public Snapshot setCreatedAt(Date createdAt) {
this.createdAt = dateToLong(createdAt);
return this;
}
+ public Long getCreatedAtMs() {
+ return createdAt;
+ }
+
public Snapshot setCreatedAtMs(Long createdAt) {
this.createdAt = createdAt;
return this;
@@ -343,15 +343,6 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return depth;
}
- public Integer getRootProjectId() {
- return rootProjectId;
- }
-
- public Snapshot setRootProjectId(Integer rootProjectId) {
- this.rootProjectId = rootProjectId;
- return this;
- }
-
/**
* Sets the depth of the snapshot
*
@@ -364,6 +355,15 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
this.depth = depth;
}
+ public Integer getRootProjectId() {
+ return rootProjectId;
+ }
+
+ public Snapshot setRootProjectId(Integer rootProjectId) {
+ this.rootProjectId = rootProjectId;
+ return this;
+ }
+
public String getPeriod1Mode() {
return period1Mode;
}
@@ -508,10 +508,6 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return longToDate(period1Date);
}
- public Long getPeriod1DateMs() {
- return period1Date;
- }
-
/**
* For internal use.
*
@@ -522,6 +518,10 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return this;
}
+ public Long getPeriod1DateMs() {
+ return period1Date;
+ }
+
public Snapshot setPeriod1DateMs(Long period1Date) {
this.period1Date = period1Date;
return this;
@@ -531,10 +531,6 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return longToDate(period2Date);
}
- public Long getPeriod2DateMs() {
- return period2Date;
- }
-
/**
* For internal use.
*
@@ -545,6 +541,10 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return this;
}
+ public Long getPeriod2DateMs() {
+ return period2Date;
+ }
+
public Snapshot setPeriod2DateMs(Long period2Date) {
this.period2Date = period2Date;
return this;
@@ -554,10 +554,6 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return longToDate(period3Date);
}
- public Long getPeriod3DateMs() {
- return period3Date;
- }
-
/**
* For internal use.
*
@@ -568,6 +564,10 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return this;
}
+ public Long getPeriod3DateMs() {
+ return period3Date;
+ }
+
public Snapshot setPeriod3DateMs(Long period3Date) {
this.period3Date = period3Date;
return this;
@@ -577,10 +577,6 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return longToDate(period4Date);
}
- public Long getPeriod4DateMs() {
- return period4Date;
- }
-
/**
* For internal use.
*
@@ -591,6 +587,10 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return this;
}
+ public Long getPeriod4DateMs() {
+ return period4Date;
+ }
+
public Snapshot setPeriod4DateMs(Long period4Date) {
this.period4Date = period4Date;
return this;
@@ -600,10 +600,6 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return longToDate(period5Date);
}
- public Long getPeriod5DateMs() {
- return period5Date;
- }
-
/**
* For internal use.
*
@@ -614,6 +610,10 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
return this;
}
+ public Long getPeriod5DateMs() {
+ return period5Date;
+ }
+
public Snapshot setPeriod5DateMs(Long period5Date) {
this.period5Date = period5Date;
return this;
@@ -642,7 +642,7 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
period5Mode = s;
break;
default:
- throw new IndexOutOfBoundsException("Index of Snapshot.periodMode is between 1 and 5");
+ throw newPeriodIndexOutOfBoundsException("periodMode");
}
return this;
}
@@ -660,7 +660,7 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
case 5:
return period5Mode;
default:
- throw new IndexOutOfBoundsException("Index of Snapshot.periodMode is between 1 and 5");
+ throw newPeriodIndexOutOfBoundsException("periodMode");
}
}
@@ -687,7 +687,7 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
period5Param = s;
break;
default:
- throw new IndexOutOfBoundsException("Index of Snapshot.periodModeParameter is between 1 and 5");
+ throw newPeriodIndexOutOfBoundsException("periodParameter");
}
return this;
}
@@ -705,7 +705,7 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
case 5:
return period5Param;
default:
- throw new IndexOutOfBoundsException("Index of Snapshot.periodModeParameter is between 1 and 5");
+ throw newPeriodIndexOutOfBoundsException("periodParameter");
}
}
@@ -733,7 +733,7 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
period5Date = time;
break;
default:
- throw new IndexOutOfBoundsException("Index of Snapshot.periodDate is between 1 and 5");
+ throw newPeriodIndexOutOfBoundsException("periodDate");
}
return this;
}
@@ -756,7 +756,7 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
period5Date = date;
break;
default:
- throw new IndexOutOfBoundsException("Index of Snapshot.periodDate is between 1 and 5");
+ throw newPeriodIndexOutOfBoundsException("periodDate");
}
return this;
}
@@ -774,7 +774,7 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
case 5:
return longToDate(period5Date);
default:
- throw new IndexOutOfBoundsException("Index of Snapshot.periodDate is between 1 and 5");
+ throw newPeriodIndexOutOfBoundsException("periodDate");
}
}
@@ -791,10 +791,14 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable
case 5:
return period5Date;
default:
- throw new IndexOutOfBoundsException("Index of Snapshot.periodDate is between 1 and 5");
+ throw newPeriodIndexOutOfBoundsException("periodDate");
}
}
+ private IndexOutOfBoundsException newPeriodIndexOutOfBoundsException(String field) {
+ return new IndexOutOfBoundsException(String.format("Index of Snapshot.%s is between 1 and 5", field));
+ }
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Snapshot)) {