Permalink
Browse files

Eclipse code formatting

  • Loading branch information...
mordechaim committed Nov 26, 2018
1 parent f88dc9e commit e46157161b0f94db227b6481ce334d2a10d0a883

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -79,17 +79,17 @@
*/
public static void main(String[] args) throws Throwable {
String override = null;

List<String> argsList = List.of(args);
List<String> bootArgs = ArgUtils.beforeSeparator(argsList);
Map<String, String> parsed = ArgUtils.parseArgs(bootArgs);

for (Map.Entry<String, String> e : parsed.entrySet()) {

if("delegate".equals(e.getKey())) {
if ("delegate".equals(e.getKey())) {
ArgUtils.validateHasValue(e);
override = e.getValue();

break;
}

@@ -103,7 +103,8 @@ public static void main(String[] args) throws Throwable {
* {@link Delegate} (specified by {@link Service#version()}) currently present
* in the classpath or modulepath.
*
* @throws Throwable Any throwable thrown in the bootstrap.
* @throws Throwable
* Any throwable thrown in the bootstrap.
*/
public static void start() throws Throwable {
start((String) null);
@@ -119,7 +120,8 @@ public static void start() throws Throwable {
* highest versioned provider (specified by {@link Service#version()}) will be
* used instead.
*
* @throws Throwable Any throwable thrown in the bootstrap.
* @throws Throwable
* Any throwable thrown in the bootstrap.
*/
public static void start(String override) throws Throwable {
start(override, List.of());
@@ -128,7 +130,8 @@ public static void start(String override) throws Throwable {
/**
* Starts the bootstrap running the given {@link Delegate}.
*
* @throws Throwable Any throwable thrown in the bootstrap.
* @throws Throwable
* Any throwable thrown in the bootstrap.
*/
public static void start(Delegate delegate) throws Throwable {
start(delegate, List.of());
@@ -140,7 +143,8 @@ public static void start(Delegate delegate) throws Throwable {
* in the classpath or modulepath, with the given list as command-line
* arguments.
*
* @throws Throwable Any throwable thrown in the bootstrap.
* @throws Throwable
* Any throwable thrown in the bootstrap.
*/
public static void start(List<String> args) throws Throwable {
start((String) null, args);
@@ -156,7 +160,8 @@ public static void start(List<String> args) throws Throwable {
* highest versioned provider (specified by {@link Service#version()}) will be
* used instead.
*
* @throws Throwable Any throwable thrown in the bootstrap.
* @throws Throwable
* Any throwable thrown in the bootstrap.
*/
public static void start(String override, List<String> args) throws Throwable {
start(Service.loadService(Delegate.class, override), args);
@@ -166,7 +171,8 @@ public static void start(String override, List<String> args) throws Throwable {
* Starts the bootstrap running the given {@link Delegate}, with the given list
* as command-line arguments.
*
* @throws Throwable Any throwable thrown in the bootstrap.
* @throws Throwable
* Any throwable thrown in the bootstrap.
*/
public static void start(Delegate delegate, List<String> args) throws Throwable {
delegate.main(args);
@@ -22,7 +22,6 @@
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder;
@@ -31,16 +30,13 @@
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
@@ -913,11 +909,11 @@ public boolean updateTemp(Path tempDir, PublicKey key, Consumer<? super UpdateHa

private boolean updateImpl(Path tempDir, PublicKey key, UpdateHandler handler,
Consumer<? super UpdateHandler> handlerSetup) {
if(key == null) {

if (key == null) {
Warning.signature();
}

boolean updateTemp = tempDir != null;
boolean success;

@@ -998,7 +994,7 @@ private boolean updateImpl(Path tempDir, PublicKey key, UpdateHandler handler,

URL url = file.getUri().toURL();
try (InputStream in = handler.connect(file, url);
OutputStream out = Files.newOutputStream(output)) {
OutputStream out = Files.newOutputStream(output)) {

// We should set download progress only AFTER the request has returned.
// The delay can be monitored by the difference between calls from startDownload to this.
@@ -1173,8 +1169,12 @@ private void checkBootConflicts(FileMetadata file, Path download) throws IOExcep

try {
Files.move(download, newPath);
newMod = ModuleFinder.of(newPath).findAll().stream().map(ModuleReference::descriptor).findAny().orElse(
null);
newMod = ModuleFinder.of(newPath)
.findAll()
.stream()
.map(ModuleReference::descriptor)
.findAny()
.orElse(null);
} finally {
Files.move(newPath, download, StandardCopyOption.REPLACE_EXISTING);
}
@@ -1272,8 +1272,8 @@ private void launchImpl(List<String> args, Launcher launcher, Consumer<? super L
.collect(Collectors.toList());

ModuleLayer parent = ModuleLayer.boot();
java.lang.module.Configuration cf = parent.configuration().resolveAndBind(ModuleFinder.of(), finder,
moduleNames);
java.lang.module.Configuration cf = parent.configuration()
.resolveAndBind(ModuleFinder.of(), finder, moduleNames);

ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader classpathLoader = new URLClassLoader("classpath", classpaths.toArray(new URL[classpaths.size()]),
@@ -1311,8 +1311,9 @@ private void launchImpl(List<String> args, Launcher launcher, Consumer<? super L
}

for (String read : mod.getAddReads()) {
Module target = layer.findModule(read).orElseThrow(() -> new IllegalStateException(
"Module '" + read + "' is not known to the layer."));
Module target = layer.findModule(read)
.orElseThrow(() -> new IllegalStateException(
"Module '" + read + "' is not known to the layer."));

controller.addReads(source, target);
}
@@ -1419,12 +1420,14 @@ private void launchImpl(List<String> args, Launcher launcher, Consumer<? super L
* {@code updateTemp()} you must first call {@link Update#finalizeUpdate(Path)}.
*
*
* @param oldConfig The old configuration.
* @throws IllegalStateException If this method is called but the current
* configuration is not up-to-date.
* @throws IOException If checking if current config is up-to-date,
* checking file equality, or calculating checksum
* failed.
* @param oldConfig
* The old configuration.
* @throws IllegalStateException
* If this method is called but the current configuration is not
* up-to-date.
* @throws IOException
* If checking if current config is up-to-date, checking file
* equality, or calculating checksum failed.
*/
public void deleteOldFiles(Configuration oldConfig) throws IOException {
deleteOldFiles(oldConfig, true, 5);
@@ -1483,16 +1486,19 @@ public void deleteOldFiles(Configuration oldConfig) throws IOException {
* {@code updateTemp()} you must first call {@link Update#finalizeUpdate(Path)}.
*
*
* @param oldConfig The old configuration.
* @param matchChecksum Whether checksums should be checked and delete only if
* matching.
* @param secondsDelay Second to delay deletion after JVM shut down. If less
* the 1, it will be adjusted to 1.
* @throws IllegalStateException If this method is called but the current
* configuration is not up-to-date.
* @throws IOException If checking if current config is up-to-date,
* checking file equality, or calculating checksum
* failed.
* @param oldConfig
* The old configuration.
* @param matchChecksum
* Whether checksums should be checked and delete only if matching.
* @param secondsDelay
* Second to delay deletion after JVM shut down. If less the 1, it
* will be adjusted to 1.
* @throws IllegalStateException
* If this method is called but the current configuration is not
* up-to-date.
* @throws IOException
* If checking if current config is up-to-date, checking file
* equality, or calculating checksum failed.
*/
public void deleteOldFiles(Configuration oldConfig, boolean matchChecksum, int secondsDelay) throws IOException {
if (requiresUpdate()) {
@@ -1542,11 +1548,13 @@ public void deleteOldFiles(Configuration oldConfig, boolean matchChecksum, int s
* {@link #deleteOldFiles(Configuration, boolean, int)}.
*
*
* @param oldConfig The old configuration.
* @param matchChecksum Whether checksums should be matching in order to consider it old.
* @param oldConfig
* The old configuration.
* @param matchChecksum
* Whether checksums should be matching in order to consider it old.
* @return A list of old files.
* @throws IOException If checking file equality, or calculating checksum
* failed.
* @throws IOException
* If checking file equality, or calculating checksum failed.
*/
public List<FileMetadata> getOldFiles(Configuration oldConfig, boolean matchChecksum) throws IOException {
List<FileMetadata> oldFiles = new ArrayList<>();
@@ -1562,15 +1570,14 @@ public void deleteOldFiles(Configuration oldConfig, boolean matchChecksum, int s
}
}

if(matchChecksum) {
if(file.requiresUpdate())
if (matchChecksum) {
if (file.requiresUpdate())
continue;
}

oldFiles.add(file);
}


return oldFiles;
}

@@ -1666,8 +1673,9 @@ private static Configuration parseImpl(ConfigMapper configMapper, PropertyManage
List<FileMetadata> files = new ArrayList<>();

for (FileMapper fm : configMapper.files) {
FileMetadata.Builder fileBuilder = FileMetadata.builder().baseUri(config.getBaseUri()).basePath(
config.getBasePath());
FileMetadata.Builder fileBuilder = FileMetadata.builder()
.baseUri(config.getBaseUri())
.basePath(config.getBasePath());

if (fm.uri != null) {
String s = config.resolvePlaceholders(fm.uri, true, fm.os != null && fm.os != OS.CURRENT);
@@ -263,8 +263,10 @@ public static Reference readFrom(String source) {

public static Stream<Reference> streamDirectory(Path dir) {
try {
return Files.walk(dir).filter(p -> Files.isRegularFile(p)).map(FileMetadata::readFrom).peek(
fm -> fm.path(dir.relativize(fm.getSource())));
return Files.walk(dir)
.filter(p -> Files.isRegularFile(p))
.map(FileMetadata::readFrom)
.peek(fm -> fm.path(dir.relativize(fm.getSource())));
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -638,10 +640,10 @@ Builder comment(String comment) {

return this;
}

Builder signature(String signature) {
this.signature = signature;

return this;
}

@@ -37,7 +37,7 @@
public ModuleLayer getModuleLayer() {
return layer;
}

public ClassLoader getClassLoader() {
return classLoader;
}
@@ -21,8 +21,7 @@
public static final OS CURRENT;

static {
String os = System.getProperty("os.name", "generic")
.toLowerCase();
String os = System.getProperty("os.name", "generic").toLowerCase();

if ((os.contains("mac")) || (os.contains("darwin")))
CURRENT = MAC;
@@ -22,7 +22,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.HashMap;
import java.util.Map;

@@ -93,10 +92,10 @@ public static boolean finalizeUpdate(Path tempDir) throws IOException {
}

for (Map.Entry<Path, Path> e : files.entrySet()) {
if(e.getValue().getParent() != null) {
if (e.getValue().getParent() != null) {
Files.createDirectories(e.getValue().getParent());
}

FileUtils.secureMoveFile(e.getKey(), e.getValue());
}

@@ -16,11 +16,9 @@
package org.update4j.mapper;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.nio.file.Files;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
@@ -167,7 +165,7 @@ private String getChildrenXml() {

// no children
if (baseUri == null && basePath == null && updateHandler == null && launcher == null && properties.isEmpty()
&& files.isEmpty()) {
&& files.isEmpty()) {
return "";
}

@@ -21,7 +21,7 @@

public abstract void parse(Node node);

// public abstract Node toNode(Document doc);
// public abstract Node toNode(Document doc);

public abstract String toXml();

@@ -50,9 +50,7 @@ public static String escape(String orig) {
builder.append("&lt;");
} else if (c == '>') {
builder.append("&gt;");
}

else if (c <= 0x1f || c >= 0x7f) {
} else if (c <= 0x1f || c >= 0x7f) {
builder.append("&#" + ((int) c) + ";");
} else {
builder.append(c);
@@ -175,7 +175,7 @@ private void updateFirst(List<String> args) throws Throwable {
}

if (local != null) {
localConfig = getLocalConfig(remote != null && syncLocal);
localConfig = getLocalConfig(remote != null && syncLocal);
}

if (remoteConfig == null && localConfig == null) {
@@ -276,7 +276,7 @@ private Configuration getLocalConfig(boolean ignoreFileNotFound) {

}
} catch (NoSuchFileException e) {
if(!ignoreFileNotFound) {
if (!ignoreFileNotFound) {
e.printStackTrace();
}
} catch (Exception e) {
Oops, something went wrong.

0 comments on commit e461571

Please sign in to comment.