Skip to content

Commit 1d482c5

Browse files
committed
make some java modern changes
Signed-off-by: Olivier Lamy <[email protected]>
1 parent a746bab commit 1d482c5

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

src/main/java/org/sonatype/plexus/build/incremental/BuildContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
// TODO should it be BuildWorkspace or something like that?
2424
public interface BuildContext {
25-
public static final int SEVERITY_WARNING = 1;
25+
int SEVERITY_WARNING = 1;
2626

27-
public static final int SEVERITY_ERROR = 2;
27+
int SEVERITY_ERROR = 2;
2828

2929
// TODO should we add File getBasedir()?
3030

@@ -50,7 +50,7 @@ public interface BuildContext {
5050
*
5151
* @param relpaths List<String> are paths relative to build context basedir
5252
*/
53-
boolean hasDelta(List relpaths);
53+
boolean hasDelta(List<String> relpaths);
5454

5555
/**
5656
* Indicates that the file or folder content has been modified during the build.
@@ -103,7 +103,7 @@ public interface BuildContext {
103103
*
104104
* Returns empty Scanner if <code>basedir</code> is not under this build context basedir.
105105
*
106-
* @see http://jira.codehaus.org/browse/MSHARED-125
106+
* https://issues.apache.org/jira/browse/MSHARED-125
107107
*/
108108
Scanner newScanner(File basedir, boolean ignoreDelta);
109109

src/main/java/org/sonatype/plexus/build/incremental/DefaultBuildContext.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public boolean hasDelta(File file) {
4646
return true;
4747
}
4848

49-
public boolean hasDelta(List relpaths) {
49+
public boolean hasDelta(List<String> relpaths) {
5050
return true;
5151
}
5252

@@ -84,10 +84,7 @@ public void setValue(String key, Object value) {
8484
}
8585

8686
private String getMessage(File file, int line, int column, String message) {
87-
StringBuffer sb = new StringBuffer();
88-
sb.append(file.getAbsolutePath()).append(" [").append(line).append(':').append(column).append("]: ");
89-
sb.append(message);
90-
return sb.toString();
87+
return file.getAbsolutePath() + " [" + line + ':' + column + "]: " + message;
9188
}
9289

9390
/**

src/main/java/org/sonatype/plexus/build/incremental/ThreadBuildContext.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@
3131
*/
3232
public class ThreadBuildContext implements BuildContext {
3333

34-
private static final ThreadLocal threadContext = new ThreadLocal();
34+
private static final ThreadLocal<BuildContext> threadContext = new ThreadLocal<BuildContext>(){
35+
@Override
36+
protected BuildContext initialValue() {
37+
return defaultContext;
38+
}
39+
};
3540

3641
private static final DefaultBuildContext defaultContext = new DefaultBuildContext();
3742

3843
public static BuildContext getContext() {
39-
BuildContext context = (BuildContext) threadContext.get();
40-
if(context == null) {
41-
context = defaultContext;
42-
}
43-
return context;
44+
return threadContext.get();
4445
}
4546

4647
public static void setThreadBuildContext(BuildContext context) {
@@ -55,7 +56,7 @@ public boolean hasDelta(File file) {
5556
return getContext().hasDelta(file);
5657
}
5758

58-
public boolean hasDelta(List relPaths) {
59+
public boolean hasDelta(List<String> relPaths) {
5960
return getContext().hasDelta(relPaths);
6061
}
6162

src/test/java/org/sonatype/plexus/build/incremental/test/TestFullBuildContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
public class TestFullBuildContext extends DefaultBuildContext {
2222

23-
private final Map context;
23+
private final Map<String, Object> context;
2424

25-
public TestFullBuildContext(Map context) {
25+
public TestFullBuildContext(Map<String, Object> context) {
2626
this.context = context;
2727
}
2828

src/test/java/org/sonatype/plexus/build/incremental/test/TestIncrementalBuildContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class TestIncrementalBuildContext implements BuildContext {
3232

3333
private final File basedir;
3434

35-
private final HashSet refresh = new HashSet();
35+
private final Set<File> refresh = new HashSet<>();
3636

3737
private static final class TestScanner implements Scanner {
3838
private final File basedir;
@@ -105,9 +105,9 @@ public boolean hasDelta(String relpath) {
105105
return changedFiles.contains(relpath) || deletedFiles.contains(relpath);
106106
}
107107

108-
public boolean hasDelta(List relpaths) {
109-
for(Iterator i = relpaths.iterator(); i.hasNext();) {
110-
String relpath = (String) i.next();
108+
public boolean hasDelta(List<String> relpaths) {
109+
for(Iterator<String> i = relpaths.iterator(); i.hasNext();) {
110+
String relpath = i.next();
111111
if(hasDelta(relpath)) {
112112
return true;
113113
}

0 commit comments

Comments
 (0)