/** * Returns the given {@code String} surrounded by single quotes, or {@code null} if the given {@code String} is * {@code null}. * * @param s the given {@code String}. * @return the given {@code String} surrounded by single quotes, or {@code null} if the given {@code String} is * {@code null}. */ public static String quote(String s) { return s != null ? concat("'", s, "'") : null; }
protected String toStringOf(String s) { return concat("\"", s, "\""); }
protected String toStringOf(Character c) { return concat("'", c, "'"); }
/** * Returns the given {@code String} surrounded by single quotes, or {@code null} if the given {@code String} is * {@code null}. * * @param s the given {@code String}. * @return the given {@code String} surrounded by single quotes, or {@code null} if the given {@code String} is * {@code null}. */ public static String quote(String s) { return s != null ? concat("'", s, "'") : null; }
/** * Appends the {@code String} specified in the constructor to the {@code String} passed as argument. * * @param s the target {@code String}. * @return a {@code String} containing the target {@code String} with the given {@code String} to append added to * the end. */ public String to(String s) { if (!s.endsWith(toAppend)) { return concat(s, toAppend); } return s; } }
/** * Appends the {@code String} specified in the constructor to the {@code String} passed as argument. * * @param s the target {@code String}. * @return a {@code String} containing the target {@code String} with the given {@code String} to append added to * the end. */ public String to(String s) { if (!s.endsWith(toAppend)) { return concat(s, toAppend); } return s; } }
/** * Creates a new file in the system's temporary directory. The name of the file will be the result of: * <pre><code class='java'> concat(UUID.randomUUID().toString(), ".txt");</code></pre> * * @return the created file. */ public static File newTemporaryFile() { String tempFileName = concat(UUID.randomUUID().toString(), ".txt"); return newFile(concat(temporaryFolderPath(), tempFileName)); }
@Override protected String toStringOf(Character character) { return concat("'", toStringOf((short) (int) character), "'"); }
@Override protected String toStringOf(Character character) { return concat("'", toStringOf((short) (int) character), "'"); }
protected String toStringOf(CompletableFuture<?> future) { String className = future.getClass().getSimpleName(); if (!future.isDone()) return concat(className, "[Incomplete]"); try { Object joinResult = future.join(); // avoid stack overflow error if future join on itself or another future that cycles back to the first Object joinResultRepresentation = joinResult instanceof CompletableFuture ? joinResult : toStringOf(joinResult); return concat(className, "[Completed: ", joinResultRepresentation, "]"); } catch (CompletionException e) { return concat(className, "[Failed: ", toStringOf(e.getCause()), "]", String.format("%n%s", getStackTrace(e))); } catch (CancellationException e) { return concat(className, "[Cancelled]"); } }
protected String toStringOf(Representation representation, String s) { return concat("\"", representation.toStringOf(s.toCharArray()), "\""); }
protected String toStringOf(Representation representation, String s) { return concat("\"", representation.toStringOf(s.toCharArray()), "\""); }
private static UncheckedIOException cannotCreateNewFile(String path, String reason, Exception cause) { String message = String.format("Unable to create the new file %s", quote(path)); if (!Strings.isNullOrEmpty(reason)) { message = concat(message, ": ", reason); } if (cause == null) { throw new RuntimeException(message); } if (cause instanceof IOException) { throw new UncheckedIOException(message, (IOException) cause); } throw new RuntimeException(message, cause); }
/** * Creates a new file in the system's temporary directory. The name of the file will be the result of: * <pre><code class='java'> concat(UUID.randomUUID().toString(), ".txt");</code></pre> * * @return the created file. */ public static File newTemporaryFile() { String tempFileName = concat(UUID.randomUUID().toString(), ".txt"); return newFile(concat(temporaryFolderPath(), tempFileName)); }
/** * Creates a new directory in the system's temporary directory. The name of the directory will be the result of: * <pre><code class='java'> UUID.randomUUID().toString();</code></pre> * * @return the created file. */ public static File newTemporaryFolder() { String tempFileName = UUID.randomUUID().toString(); return newFolder(concat(temporaryFolderPath(), tempFileName)); }
@Override protected String toStringOf(Character character) { return concat("'", toStringOf((short) (int) character), "'"); }
protected String toStringOf(Representation representation, String s) { return concat("\"", representation.toStringOf(s.toCharArray()), "\""); }
protected String toStringOf(CompletableFuture<?> future) { String className = future.getClass().getSimpleName(); if (!future.isDone()) return concat(className, "[Incomplete]"); try { Object joinResult = future.join(); // avoid stack overflow error if future join on itself or another future that cycles back to the first Object joinResultRepresentation = joinResult instanceof CompletableFuture ? joinResult : toStringOf(joinResult); return concat(className, "[Completed: ", joinResultRepresentation, "]"); } catch (CompletionException e) { return concat(className, "[Failed: ", toStringOf(e.getCause()), "]", String.format("%n%s", getStackTrace(e))); } catch (CancellationException e) { return concat(className, "[Cancelled]"); } }
@Override protected String toStringOf(Character character) { return concat("'", toStringOf((short) (int) character), "'"); }
/** * Creates a new directory in the system's temporary directory. The name of the directory will be the result of: * <pre><code class='java'> UUID.randomUUID().toString();</code></pre> * * @return the created file. */ public static File newTemporaryFolder() { String tempFileName = UUID.randomUUID().toString(); return newFolder(concat(temporaryFolderPath(), tempFileName)); }