Various code simplification/fixes and a lot of typo/grammar fixes (may brake some stuff)
This commit is contained in:
@@ -10,9 +10,9 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A bi-direction map storing in a synchronized way a {@code forwardMap} that store the key to value mapping, and a
|
||||
* A bidirectional map storing in a synchronized way a {@code forwardMap} that store the key to value mapping, and a
|
||||
* {@code backwardMap} that store the value to key mapping.
|
||||
* All the keys and value are always unique in this bi-directional map.
|
||||
* All the keys and value are always unique in this bidirectional map.
|
||||
* This class is fully thread safe.
|
||||
* @param <K> the type of the "key"
|
||||
* @param <V> the type of the "value"
|
||||
@@ -25,7 +25,7 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
protected final Map<K, V> forwardMap;
|
||||
|
||||
/**
|
||||
* The backend bawkward map
|
||||
* The backend backward map
|
||||
*/
|
||||
protected final Map<V, K> backwardMap;
|
||||
|
||||
@@ -45,14 +45,14 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new bi-directional map with {@link HashMap} as the two backend maps.
|
||||
* Create a new bidirectional map with {@link HashMap} as the two backend maps.
|
||||
*/
|
||||
public BiMap() {
|
||||
this(HashMap::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new bi-directional map with {@link HashMap} as the two backend maps, and filled with the provided source
|
||||
* Create a new bidirectional map with {@link HashMap} as the two backend maps, and filled with the provided source
|
||||
* {@link Map}.
|
||||
* @param source the source to fill the new {@link BiMap}.
|
||||
*/
|
||||
@@ -72,9 +72,9 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate the provided key and value to each other in this bi-directional map.
|
||||
* Associate the provided key and value to each other in this bidirectional map.
|
||||
* Since the {@link BiMap} cannot have duplicate keys or values: if a key is already present, the currently mapped
|
||||
* value will be removed from the map. Also if a value is already present, the currently mapped key will also be
|
||||
* value will be removed from the map. Also, if a value is already present, the currently mapped key will also be
|
||||
* removed.
|
||||
* @param k the key.
|
||||
* @param v the value.
|
||||
@@ -92,9 +92,9 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
|
||||
|
||||
/**
|
||||
* Associate the provided key and value to each other in this bi-directional map.
|
||||
* Associate the provided key and value to each other in this bidirectional map.
|
||||
* Since the {@link BiMap} cannot have duplicate keys or values: if a key is already present, the currently mapped
|
||||
* value will be removed from the map. Also if a value is already present, the currently mapped key will also be
|
||||
* value will be removed from the map. Also, if a value is already present, the currently mapped key will also be
|
||||
* removed.
|
||||
* @param entry the entry with a key and value.
|
||||
*/
|
||||
@@ -103,8 +103,8 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Put the content of the provided map into this bi-directional map.
|
||||
* This methods will call the {@link #put(Entry)} method successively in the order of the provided Map’s iterator.
|
||||
* Put the content of the provided map into this bidirectional map.
|
||||
* This method will call the {@link #put(Entry)} method successively in the order of the provided Map’s iterator.
|
||||
* @param source the source map.
|
||||
*/
|
||||
public void putAll(Map<? extends K, ? extends V> source) {
|
||||
@@ -187,7 +187,7 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable {@link Set} view of this map.
|
||||
* It’s iteration order will depends on the implementation of the {@code forwardMap}.
|
||||
* It’s iteration order will depend on the implementation of the {@code forwardMap}.
|
||||
* @return an unmodifiable {@link Set} view of this map.
|
||||
* @see Map#entrySet()
|
||||
*/
|
||||
@@ -197,7 +197,7 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
|
||||
/**
|
||||
* Returns an iterator of this map.
|
||||
* It’s iteration order will depends on the implementation of the {@code forwardMap}.
|
||||
* It’s iteration order will depend on the implementation of the {@code forwardMap}.
|
||||
* @return an iterator of this map.
|
||||
* @see Map#entrySet()
|
||||
* @see Set#iterator()
|
||||
@@ -209,7 +209,7 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable {@link Set} view of the keys contained in this map.
|
||||
* It’s iteration order will depends on the implementation of the {@code forwardMap}’s key set.
|
||||
* It’s iteration order will depend on the implementation of the {@code forwardMap}’s key set.
|
||||
* @return an unmodifiable {@link Set} view of the keys contained in this map.
|
||||
* @see Map#keySet()
|
||||
*/
|
||||
@@ -219,7 +219,7 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable {@link Set} view of the values contained in this map.
|
||||
* It’s iteration order will depends on the implementation of the {@code backwardMap}’s key set.
|
||||
* It’s iteration order will depend on the implementation of the {@code backwardMap}’s key set.
|
||||
* @return an unmodifiable {@link Set} view of the values contained in this map.
|
||||
* @see Map#keySet()
|
||||
*/
|
||||
@@ -228,16 +228,16 @@ public class BiMap<K, V> implements Iterable<Entry<K, V>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable {@link Map} view of the {@code forwardMap} of this bi-directional map.
|
||||
* It’s iteration order will depends on the implementation of the {@code forwardMap}.
|
||||
* @return an unmodifiable {@link Map} view of the {@code forwardMap} of this bi-directional map.
|
||||
* Returns an unmodifiable {@link Map} view of the {@code forwardMap} of this bidirectional map.
|
||||
* It’s iteration order will depend on the implementation of the {@code forwardMap}.
|
||||
* @return an unmodifiable {@link Map} view of the {@code forwardMap} of this bidirectional map.
|
||||
*/
|
||||
public Map<K, V> asMap() {
|
||||
return Collections.unmodifiableMap(forwardMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a reversed view of this bi-directional map.
|
||||
* Create a reversed view of this bidirectional map.
|
||||
* Since the returned {@link BiMap} is a view of this {@link BiMap}, any change to either of those will affect both
|
||||
* of them. Also, calling {@code bimap.reversedView().reversedView()} will return the original instance
|
||||
* {@code bimap} since calling this method will cache each map into the respective reversed view.
|
||||
|
@@ -13,20 +13,20 @@ public class DistanceUtil {
|
||||
* specified metric prefix
|
||||
* @param meterDist the distance to display, in meter
|
||||
* @param precision the number of digit to display after the decimal separator
|
||||
* @param desiredUnits the prefered unit prefix to use for convertion.
|
||||
* @param desiredUnits the preferred unit prefix to use for conversion.
|
||||
* @return a string representation of the provided distance
|
||||
*/
|
||||
public static String distanceToString(double meterDist, int precision, DistanceUnit... desiredUnits) {
|
||||
|
||||
Arrays.sort(desiredUnits);
|
||||
|
||||
DistanceUnit choosenUnit = desiredUnits[0]; // la plus petite unitée
|
||||
DistanceUnit chosenUnit = desiredUnits[0]; // la plus petite unité
|
||||
for (DistanceUnit unit : desiredUnits) {
|
||||
if (meterDist / unit.multiplicator < 1) continue;
|
||||
choosenUnit = unit;
|
||||
if (meterDist / unit.multiplier < 1) continue;
|
||||
chosenUnit = unit;
|
||||
}
|
||||
|
||||
if (choosenUnit != desiredUnits[0] && precision <= 2) precision = 2;
|
||||
if (chosenUnit != desiredUnits[0] && precision <= 2) precision = 2;
|
||||
|
||||
String precisionFormat = "##0";
|
||||
if (precision > 0) precisionFormat += ".";
|
||||
@@ -34,9 +34,9 @@ public class DistanceUtil {
|
||||
|
||||
DecimalFormat df = new DecimalFormat(precisionFormat);
|
||||
|
||||
double dist = meterDist / choosenUnit.multiplicator;
|
||||
double dist = meterDist / chosenUnit.multiplier;
|
||||
|
||||
return df.format(dist) + choosenUnit.unitStr;
|
||||
return df.format(dist) + chosenUnit.unitStr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ public class DistanceUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumeration of comonly used distance metric unit
|
||||
* Enumeration of commonly used distance metric unit
|
||||
*/
|
||||
public enum DistanceUnit {
|
||||
|
||||
@@ -91,15 +91,15 @@ public class DistanceUtil {
|
||||
/**
|
||||
* The value of this unit in meter.
|
||||
*/
|
||||
public final double multiplicator;
|
||||
public final double multiplier;
|
||||
|
||||
/**
|
||||
* String representation of the unit symbol.
|
||||
*/
|
||||
public final String unitStr;
|
||||
|
||||
DistanceUnit(double mult, String s) {
|
||||
multiplicator = mult;
|
||||
DistanceUnit(double multiplier, String s) {
|
||||
this.multiplier = multiplier;
|
||||
unitStr = s;
|
||||
}
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ public class EnumUtil {
|
||||
*
|
||||
* @param enumType the class of the enum in which to search
|
||||
* @param search the case-insensitive name of the enum value to return.
|
||||
* @return the element found in the enum, or null if not found or if the provideid type is not an enum.
|
||||
* @return the element found in the enum, or null if not found or if the provided type is not an enum.
|
||||
*/
|
||||
public static Enum<?> searchUncheckedEnum(Class<?> enumType, String search) {
|
||||
if (!enumType.isEnum())
|
||||
|
@@ -28,17 +28,17 @@ public class FileUtils {
|
||||
* @param target the copy destination.
|
||||
* @throws IOException if an IO error occurs.
|
||||
* @throws IllegalStateException if the target destination already exists and is not a directory.
|
||||
* @throws IllegalArgumentException if at least one of the parameter is null, or if the source doesn’t exists.
|
||||
* @throws IllegalArgumentException if at least one of the parameter is null, or if the source doesn't exist.
|
||||
*/
|
||||
public static void copy(File source, File target) throws IOException {
|
||||
if (source == null || !source.exists()) {
|
||||
throw new IllegalArgumentException("source is null or doesn’t exists: " + source);
|
||||
if (source == null || !source.exists() || !source.isDirectory()) {
|
||||
throw new IllegalArgumentException("source is null or doesn't exist: " + source);
|
||||
}
|
||||
if (target == null) {
|
||||
throw new IllegalArgumentException("target cannot be null");
|
||||
}
|
||||
if (target.exists() && !target.isDirectory()) {
|
||||
throw new IllegalStateException("target file already exists: " + target);
|
||||
throw new IllegalStateException("target file already exists but is not a directory: " + target);
|
||||
}
|
||||
BasicFileAttributes sourceAttr = Files.readAttributes(source.toPath(), BasicFileAttributes.class);
|
||||
if (sourceAttr.isDirectory()) {
|
||||
|
@@ -7,7 +7,7 @@ import java.util.function.ToIntBiFunction;
|
||||
/**
|
||||
* Implementation of the <a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance algorithm</a>
|
||||
* that operate on characters. Its purpose is to compute a "distance" between two strings of characters, that represents
|
||||
* how many edition operations must be performed on the first string ({@code initialString}) to optain the second
|
||||
* how many edition operations must be performed on the first string ({@code initialString}) to obtain the second
|
||||
* one ({@code finalString}).
|
||||
* <p>
|
||||
* All the parameters of the algorithm are configurable:
|
||||
@@ -23,7 +23,7 @@ import java.util.function.ToIntBiFunction;
|
||||
* between the two strings.
|
||||
* <p>
|
||||
* A more advanced usage offer the possibility to progressively compute a distance from a predefined
|
||||
* {@code initialString} to a {@code finalString} that is feeded progressively using {@link #add(char)} or
|
||||
* {@code initialString} to a {@code finalString} that is fed progressively using {@link #add(char)} or
|
||||
* {@link #add(String)}. This is useful if the {@code finalString} is an input that is currently being typed by the
|
||||
* user, so the application can progressively update a list of suggested words based on the distance.
|
||||
* For this usage, you can use those constructors to avoid initializing the {@code finalString}:
|
||||
|
@@ -3,7 +3,7 @@ package fr.pandacube.lib.util;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides utility methods related to lists.
|
||||
* Provides utility methods for lists.
|
||||
*/
|
||||
public class ListUtil {
|
||||
|
||||
|
@@ -7,9 +7,9 @@ import java.util.ListIterator;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A Wrapper list that provides a mapped view of the backend list. Every modification of this list will modify the bakend
|
||||
* list. Each time a value is accessed or modified, the appropriate setter or getter is used to convert the value
|
||||
* between the source {@code S} and the visible {@code T} type.
|
||||
* A Wrapper list that provides a mapped view of the backend list. Every modification of this list will modify the
|
||||
* backend list. Each time a value is accessed or modified, the appropriate setter or getter is used to convert the
|
||||
* value between the source {@code S} and the visible {@code T} type.
|
||||
* @param <S> the source (backend) type
|
||||
* @param <T> the visible (mapped) type
|
||||
*/
|
||||
@@ -111,22 +111,6 @@ public class MappedListView<S, T> extends AbstractList<T> {
|
||||
backend.subList(fromIndex, toIndex).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return backend.equals(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return backend.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@@ -36,19 +36,19 @@ public class MemoryUtil {
|
||||
break;
|
||||
}
|
||||
|
||||
String dispValue;
|
||||
String displayValue;
|
||||
if (unit == roundTo) {
|
||||
dispValue = "" + unit.toUnitRound(size, si);
|
||||
displayValue = "" + unit.toUnitRound(size, si);
|
||||
}
|
||||
else {
|
||||
dispValue = format.format(unit.toUnit(size, si));
|
||||
displayValue = format.format(unit.toUnit(size, si));
|
||||
}
|
||||
|
||||
return (neg ? "-" : "") + dispValue + unit.unit(si);
|
||||
return (neg ? "-" : "") + displayValue + unit.unit(si);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a string representation of the provided memory amount, displayinh the value in byte (as is) and with the
|
||||
* Generate a string representation of the provided memory amount, displaying the value in byte (as is) and with the
|
||||
* unit symbol {@code "o"}.
|
||||
* <p>
|
||||
* <b>This method returns the unit symbol in French.</b>
|
||||
@@ -62,7 +62,7 @@ public class MemoryUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration of comonly used unit of memory prefix.
|
||||
* Enumeration of commonly used unit of memory prefix.
|
||||
*/
|
||||
public enum MemoryUnit {
|
||||
|
||||
@@ -152,10 +152,10 @@ public class MemoryUtil {
|
||||
return unitMultiplier == null ? "o" : (unitMultiplier + (si ? "o" : "io"));
|
||||
}
|
||||
|
||||
MemoryUnit(long vTrad, long vSI, String uMult) {
|
||||
MemoryUnit(long vTrad, long vSI, String uMultiplier) {
|
||||
valueTrad = vTrad;
|
||||
valueSI = vSI;
|
||||
unitMultiplier = uMult;
|
||||
unitMultiplier = uMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -253,28 +253,28 @@ public enum MinecraftVersion {
|
||||
|
||||
/**
|
||||
* Returns a string representation of all the Minecraft version of this enum value, using
|
||||
* {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the gramatical word "et"
|
||||
* {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the grammatical word "et"
|
||||
* ("and" in french).
|
||||
*
|
||||
* @return a string representation of this {@link MinecraftVersion}.
|
||||
* @deprecated it uses the hardcoded french word "et" as the final word separator.
|
||||
* @deprecated it uses the hardcoded French word "et" as the final word separator.
|
||||
* Use {@link #displayOptimizedListOfVersions(List, String)} with "et" as the last parameter instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public String toStringAnd() {
|
||||
return toString("et");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of all the Minecraft version of this enum value, using
|
||||
* {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the gramatical word "ou"
|
||||
* {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the grammatical word "ou"
|
||||
* ("or" in french).
|
||||
*
|
||||
* @return a string representation of this {@link MinecraftVersion}.
|
||||
* @deprecated it uses the hardcoded french word "ou" as the final word separator.
|
||||
* @deprecated it uses the hardcoded French word "ou" as the final word separator.
|
||||
* Use {@link #displayOptimizedListOfVersions(List, String)} with "ou" as the last parameter instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public String toStringOr() {
|
||||
return toString("ou");
|
||||
}
|
||||
@@ -316,30 +316,30 @@ public enum MinecraftVersion {
|
||||
|
||||
/**
|
||||
* Generate a string representation of the provided list of version, using
|
||||
* {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the gramatical word "et"
|
||||
* {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the grammatical word "et"
|
||||
* ("and" in french).
|
||||
*
|
||||
* @param versions the minecraft versions to list
|
||||
* @return a string representation of the provided list of version.
|
||||
* @deprecated it uses the hardcoded french word "et" as the final word separator.
|
||||
* @deprecated it uses the hardcoded French word "et" as the final word separator.
|
||||
* Use {@link #displayOptimizedListOfVersions(List, String)} with "et" as the last parameter instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String displayOptimizedListOfVersionsAnd(List<MinecraftVersion> versions) {
|
||||
return displayOptimizedListOfVersions(versions, "et");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a string representation of the provided list of version, using
|
||||
* {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the gramatical word "ou"
|
||||
* {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the grammatical word "ou"
|
||||
* ("or" in french).
|
||||
*
|
||||
* @param versions the minecraft versions to list
|
||||
* @return a string representation of the provided list of version.
|
||||
* @deprecated it uses the hardcoded french word "ou" as the final word separator.
|
||||
* @deprecated it uses the hardcoded French word "ou" as the final word separator.
|
||||
* Use {@link #displayOptimizedListOfVersions(List, String)} with "ou" as the last parameter instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String displayOptimizedListOfVersionsOr(List<MinecraftVersion> versions) {
|
||||
return displayOptimizedListOfVersions(versions, "ou");
|
||||
}
|
||||
@@ -348,7 +348,7 @@ public enum MinecraftVersion {
|
||||
* Returns an optimized list of string representation of Minecraft version, that represent the provided list of
|
||||
* Minecraft version.
|
||||
* <p>
|
||||
* This methods try to merge successive Minecraft version into a single string: for instance, all versions from 1.18
|
||||
* This method try to merge successive Minecraft version into a single string: for instance, all versions from 1.18
|
||||
* to 1.18.2 are represented by the string "1.18.x"; all version from 1.14.1 to 1.14.4 are represented by the string
|
||||
* "1.14.1-1.14.4".
|
||||
* <p>
|
||||
|
@@ -10,17 +10,17 @@ public class MinecraftWebUtil {
|
||||
* <p>
|
||||
* Each colored part of the text will be contained in a {@code <span>} tag with {@code class="cX"} where {@code X}
|
||||
* is the color code from 0 to F in uppercase.
|
||||
* The bold, striked, underlined and italic parts will be contained in a {@code <span>} tag with respectively the
|
||||
* The bold, struck, underlined and italic parts will be contained in a {@code <span>} tag with respectively the
|
||||
* classes {@code cL}, {@code cM}, {@code cN} and {@code cO}.
|
||||
* Some CSS properties are needed to apply the colors to the CSS classes.
|
||||
* @param chatcolorPrefix the prefix used for the color codes
|
||||
* @param chatColorPrefix the prefix used for the color codes
|
||||
* @param legacyText the legacy text to convert to HTML.
|
||||
* @return The text formated in HTML.
|
||||
* @implNote the current implementation does not yet supports the RGB colors.
|
||||
* @return The text formatted in HTML.
|
||||
* @implNote the current implementation does not yet support the RGB colors.
|
||||
*/
|
||||
// TODO update to support RGB colors (Bungee and Essentials notation). (see JS implementation at https://www.pandacube.fr/assets/js/global.js )
|
||||
// TODO moves this to pandalib-chat and use Adventure API to help serializing to HTML
|
||||
public static String fromMinecraftColorCodeToHTML(char chatcolorPrefix, String legacyText)
|
||||
public static String fromMinecraftColorCodeToHTML(char chatColorPrefix, String legacyText)
|
||||
{
|
||||
String color_char = "0123456789abcdefr";
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MinecraftWebUtil {
|
||||
for (int i=0; i<legacyText.length(); i++) {
|
||||
char c = legacyText.charAt(i);
|
||||
|
||||
if (c == chatcolorPrefix && (i<legacyText.length()-1)) {
|
||||
if (c == chatColorPrefix && (i<legacyText.length()-1)) {
|
||||
i++;
|
||||
c = legacyText.charAt(i);
|
||||
if (color_char.contains(String.valueOf(Character.toLowerCase(c)))) {
|
||||
@@ -85,7 +85,7 @@ public class MinecraftWebUtil {
|
||||
}
|
||||
}
|
||||
else {
|
||||
builder.append(chatcolorPrefix + c);
|
||||
builder.append(chatColorPrefix + c);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -8,7 +8,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* Utility class and program that generate offline UUIDs for provided player names.
|
||||
* <p>
|
||||
* You can generate the UUID programatically using {@link #getFromNickName(String)} and
|
||||
* You can generate the UUID programmatically using {@link #getFromNickName(String)} and
|
||||
* {@link #getFromNickNames(String[])}.
|
||||
*
|
||||
* To use this class as a program, type
|
||||
@@ -23,7 +23,7 @@ public class OfflineUUID {
|
||||
|
||||
/**
|
||||
* Generate the offline {@link UUID} of the provided player name.
|
||||
* @param nickname the player name to optain the offline UUID from.
|
||||
* @param nickname the player name to obtain the offline UUID from.
|
||||
* @return the offline {@link UUID} of the provided player name.
|
||||
*/
|
||||
public static UUID getFromNickName(String nickname) {
|
||||
@@ -33,7 +33,7 @@ public class OfflineUUID {
|
||||
|
||||
/**
|
||||
* Generate the offline {@link UUID}s of the provided player names.
|
||||
* @param nicknames an array of player name to optain the offline UUIDs from.
|
||||
* @param nicknames an array of player name to obtain the offline UUIDs from.
|
||||
* @return the offline {@link UUID}s of the provided player name in an array, at the same order as the input.
|
||||
*/
|
||||
public static UUID[] getFromNickNames(String[] nicknames) {
|
||||
|
@@ -15,35 +15,35 @@ public class RandomUtil {
|
||||
public static final Random rand = new Random();
|
||||
|
||||
/**
|
||||
* Returns a randomly generated integer between {@code minInclu} included and {@code maxExclu} excluded.
|
||||
* Returns a randomly generated integer between {@code minInclusive} included and {@code maxExclusive} excluded.
|
||||
* This method is safer to use that Random#nextInt(int, int) because it does not check the validity of
|
||||
* the parameters.
|
||||
* @param minInclu the minimum value, included.
|
||||
* @param maxExclu the maximum value, excluded.
|
||||
* @return a random number between {@code minInclu} included and {@code maxExclu} excluded.
|
||||
* @param minInclusive the minimum value, included.
|
||||
* @param maxExclusive the maximum value, excluded.
|
||||
* @return a random number between {@code minInclusive} included and {@code maxExclusive} excluded.
|
||||
* @see Random#nextInt(int, int)
|
||||
* @throws IllegalArgumentException if {@code minInclu} is greater than {@code maxExclu}.
|
||||
* @throws IllegalArgumentException if {@code minInclusive} is greater than {@code maxExclusive}.
|
||||
*/
|
||||
public static int nextIntBetween(int minInclu, int maxExclu) {
|
||||
return minInclu + rand.nextInt(maxExclu - minInclu);
|
||||
public static int nextIntBetween(int minInclusive, int maxExclusive) {
|
||||
return minInclusive + rand.nextInt(maxExclusive - minInclusive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a randomly generated double between {@code minInclu} included and {@code maxExclu} excluded.
|
||||
* Returns a randomly generated double between {@code minInclusive} included and {@code maxExclusive} excluded.
|
||||
* This method is safer to use that Random#nextDouble(double, double) because it does not check the validity of
|
||||
* the parameters
|
||||
* @param minInclu the minimum value, included.
|
||||
* @param maxExclu the maximum value, excluded.
|
||||
* @return a random number between {@code minInclu} included and {@code maxExclu} excluded.
|
||||
* @param minInclusive the minimum value, included.
|
||||
* @param maxExclusive the maximum value, excluded.
|
||||
* @return a random number between {@code minInclusive} included and {@code maxExclusive} excluded.
|
||||
* @see Random#nextDouble(double, double)
|
||||
*/
|
||||
public static double nextDoubleBetween(double minInclu, double maxExclu) {
|
||||
return minInclu + rand.nextDouble() * (maxExclu - minInclu);
|
||||
public static double nextDoubleBetween(double minInclusive, double maxExclusive) {
|
||||
return minInclusive + rand.nextDouble() * (maxExclusive - minInclusive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random element from the provided array.
|
||||
* @param array the array in whith to pick a value randomly.
|
||||
* @param array the array in which to pick a value randomly.
|
||||
* @return the value randomly picked from the array, or null if the array is null or empty.
|
||||
* @param <T> the type of the array elements.
|
||||
* @see Random#nextInt(int)
|
||||
@@ -54,7 +54,7 @@ public class RandomUtil {
|
||||
|
||||
/**
|
||||
* Returns a random element from the provided list.
|
||||
* @param list the list in whith to pick a value randomly.
|
||||
* @param list the list in which to pick a value randomly.
|
||||
* @return the value randomly picked from the list, or null if the array is null or empty.
|
||||
* @param <T> the type of the list elements.
|
||||
* @see Random#nextInt(int)
|
||||
@@ -65,7 +65,7 @@ public class RandomUtil {
|
||||
|
||||
/**
|
||||
* Returns a random character from the provided string.
|
||||
* @param str the string in whith to pick a character randomly.
|
||||
* @param str the string in which to pick a character randomly.
|
||||
* @return the character randomly picked from the string, or {@code '\0'} if the string is null or empty.
|
||||
* @see Random#nextInt(int)
|
||||
*/
|
||||
@@ -98,8 +98,8 @@ public class RandomUtil {
|
||||
/**
|
||||
* Return a value between 0 and the number of parameter minus 1, using the provided frequencies.
|
||||
* <p>
|
||||
* The probability of each value to be returned depends of the frequencies provided.
|
||||
* @param frequencies the frequencies of each entries
|
||||
* The probability of each value to be returned depends on the frequencies provided.
|
||||
* @param frequencies the frequencies of each entry
|
||||
* @return the index of an entry, or -1 if it is unable to pick anything (all the frequencies are 0 or there is no provided frequency)
|
||||
* @throws IllegalArgumentException if frequencies is null.
|
||||
*/
|
||||
@@ -144,18 +144,18 @@ public class RandomUtil {
|
||||
public static final String PASSWORD_CHARSET_SPECIAL = "@#+*/-;:,.?!='()[]{}&";
|
||||
|
||||
/**
|
||||
* A set of characters representing uppercase and lowercase latin alphabet letters and digits, exclusing some that
|
||||
* A set of characters representing uppercase and lowercase latin alphabet letters and digits, excluding some that
|
||||
* can be confusing to read (like {@code iIl1} or {@code oO0}).
|
||||
*/
|
||||
public static final String PASSWORD_CHARSET_NO_ANBIGUITY = "abcdefghkmnpqrstwxyzACDEFGHKLMNPQRSTWXYZ2345679";
|
||||
public static final String PASSWORD_CHARSET_NO_AMBIGUITY = "abcdefghkmnpqrstwxyzACDEFGHKLMNPQRSTWXYZ2345679";
|
||||
|
||||
/**
|
||||
* Generate a random password of the provided length, using the characters listed in {@link #PASSWORD_CHARSET_NO_ANBIGUITY}.
|
||||
* Generate a random password of the provided length, using the characters listed in {@link #PASSWORD_CHARSET_NO_AMBIGUITY}.
|
||||
* @param length the length of the generated password.
|
||||
* @return the generated password.
|
||||
*/
|
||||
public static String randomPassword(int length) {
|
||||
return randomPassword(length, PASSWORD_CHARSET_NO_ANBIGUITY);
|
||||
return randomPassword(length, PASSWORD_CHARSET_NO_AMBIGUITY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -24,24 +24,24 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of occurence of a speficied character in a string.
|
||||
* Counts the number of occurrence of a specified character in a string.
|
||||
* @param string the character sequence to search into.
|
||||
* @param character the character to count.
|
||||
* @return the number of occurence of
|
||||
* @deprecated Because it uses snake_case naming convention. Use {@link #countOccurences(CharSequence, char)} instead.
|
||||
* @return the number of occurrence of
|
||||
* @deprecated Because it uses snake_case naming convention. Use {@link #countOccurrences(CharSequence, char)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2022-07-26")
|
||||
public static int char_count(CharSequence string, char character) {
|
||||
return countOccurences(string, character);
|
||||
return countOccurrences(string, character);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of occurence of a speficied character in a string.
|
||||
* Counts the number of occurrence of a specified character in a string.
|
||||
* @param string the character sequence to search into.
|
||||
* @param character the character to count.
|
||||
* @return the number of occurence of
|
||||
* @return the number of occurrence of
|
||||
*/
|
||||
public static int countOccurences(CharSequence string, char character) {
|
||||
public static int countOccurrences(CharSequence string, char character) {
|
||||
int count = 0;
|
||||
for (char c : string.toString().toCharArray()) {
|
||||
if (c == character) {
|
||||
@@ -53,8 +53,8 @@ public class StringUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Do like {@link String#join(CharSequence, Iterable)}, but the last separator is different than the others.
|
||||
* It is usedful when enumerating thins in a sentense, for instance : <code>"a thing<u>, </u>a thing<u> and </u>a thing"</code>
|
||||
* Do like {@link String#join(CharSequence, Iterable)}, but the last separator is different from the others.
|
||||
* It is useful when enumerating thins in a sentence, for instance : <code>"a thing<u>, </u>a thing<u> and </u>a thing"</code>
|
||||
* (the coma being the usual separator, and {@code " and "} being the final separator).
|
||||
* @param regularSeparator the separator used everywhere except between the two last strings to join.
|
||||
* @param finalSeparator the separator used between the two last strings to join.
|
||||
@@ -91,9 +91,9 @@ public class StringUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Generate a name based on the original name, but that does not conflit with anouther one, according to the
|
||||
* Generate a name based on the original name, but that does not conflit with another one, according to the
|
||||
* provided predicate.
|
||||
* It can be used to to add an entry in a map when the key already exists, and it is ok to modify the added key to
|
||||
* It can be used to add an entry in a map when the key already exists, and it is ok to modify the added key to
|
||||
* not erase the previous data.
|
||||
* This situation can be compared to when a file is added to a directory but another file with the same name exists,
|
||||
* so the new file have a suffix number to make the file name different.
|
||||
@@ -141,17 +141,17 @@ public class StringUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Generate a {@link Pattern} with extra wrapping regex around the provided one to consider a sentense (like a chat
|
||||
* Generate a {@link Pattern} with extra wrapping regex around the provided one to consider a sentence (like a chat
|
||||
* message). For instance, the returned pattern will only match the expression at the beginning or end of sentence,
|
||||
* or separated by the rest of it with space or another non-letter character.
|
||||
* @param wordPattern the regex pattern to wrap.
|
||||
* @param caseInsensitive if the pattern must match ignoring case.
|
||||
* @return a {@link Pattern}. The matching will match 3 groups. The first group is the eventual non-letter separator
|
||||
* before the matched word, the second one is the actual word, and the last one is the eventual non-letter separator
|
||||
* after the matched word. Any additionnal pattern group between the 2nd and the last one are thoses provided in the
|
||||
* after the matched word. Any additional pattern group between the 2nd and the last one are those provided in the
|
||||
* wordPattern.
|
||||
*/
|
||||
public static Pattern asPatternInSentense(String wordPattern, boolean caseInsensitive) {
|
||||
public static Pattern asPatternInSentence(String wordPattern, boolean caseInsensitive) {
|
||||
return Pattern.compile((caseInsensitive ? "(?i)" : "") + "(\\P{L}|^)(" + wordPattern + ")(\\P{L}|$)");
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import fr.pandacube.lib.util.ThrowableUtil.SupplierException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A class that delay and accumulate thown exceptions, that can be thrown later using {@link #throwCatched()}.
|
||||
* A class that delay and accumulate thrown exceptions, that can be thrown later using {@link #throwCaught()}.
|
||||
* @param <T> the type of {@link Throwable} to accumulate.
|
||||
*/
|
||||
public class ThrowableAccumulator<T extends Throwable> {
|
||||
@@ -81,13 +81,13 @@ public class ThrowableAccumulator<T extends Throwable> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an exception if there is at least one catched by this accumulator.
|
||||
* If multiple exception where catched, all the exception after the first one are added to the first one as
|
||||
* Throws an exception if there is at least one caught by this accumulator.
|
||||
* If multiple exception where caught, all the exception after the first one are added to the first one as
|
||||
* suppressed exceptions.
|
||||
* If no exception were catched, this method does nothing.
|
||||
* If no exception were caught, this method does nothing.
|
||||
* @throws Exception the first accumulated throwable, the other ones being suppressed.
|
||||
*/
|
||||
public void throwCatched() throws Exception {
|
||||
public void throwCaught() throws Exception {
|
||||
synchronized (this) {
|
||||
if (base != null)
|
||||
throwEx(base);
|
||||
|
@@ -15,7 +15,7 @@ public class ThrowableUtil {
|
||||
* Convert a {@link Throwable} into a {@link String} using the {@link Throwable#printStackTrace(PrintStream)} method,
|
||||
* so the returned string contains the full stack trace.
|
||||
* @param t the {@link Throwable}
|
||||
* @return a {@link String} containing the full stack thace of the provided {@link Throwable}.
|
||||
* @return a {@link String} containing the full stack trace of the provided {@link Throwable}.
|
||||
*/
|
||||
public static String stacktraceToString(Throwable t) {
|
||||
if (t == null) return null;
|
||||
@@ -97,7 +97,7 @@ public class ThrowableUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Makes the provided Throwable unckecked if necessary.
|
||||
* Makes the provided Throwable unchecked if necessary.
|
||||
* @param t the throwable to eventually wrap into a {@link RuntimeException}.
|
||||
* @param convertReflectionExceptionToError true to convert reflection related exception to their error counterpart.
|
||||
* @return a {@link RuntimeException}
|
||||
|
@@ -17,8 +17,8 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Utility class providing methods to display human readable time and duration, and parse duration strings.
|
||||
*
|
||||
* Utility class providing methods to display human-readable time and duration, and parse duration strings.
|
||||
* <p>
|
||||
* The methods that return date and daytime are hardcoded in French.
|
||||
*/
|
||||
public class TimeUtil {
|
||||
@@ -37,17 +37,17 @@ public class TimeUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Provides a human readable date of the provided time, with ability to adapt the text relatively to the current
|
||||
* Provides a human-readable date of the provided time, with ability to adapt the text relatively to the current
|
||||
* time (for instance "il y a 13 minutes" (french for "13 minutes ago"))
|
||||
* <p>
|
||||
* <b>This method renders the text in French.</b>
|
||||
*
|
||||
* @param time the timestamp in milliseconds of the time to diplay.
|
||||
* @param showSeconds if the returned string should includes seconds (true) or not (false). To have more control
|
||||
* @param time the timestamp in milliseconds of the time to display.
|
||||
* @param showSeconds if the returned string should include seconds (true) or not (false). To have more control
|
||||
* over the precision, call {@link #relativeDateFr(long, RelativePrecision, DisplayPrecision,
|
||||
* boolean)}.
|
||||
* @param compactWords true to use compact words, false to use full words.
|
||||
* @return a human readable {@link String} representation of the provided time.
|
||||
* @return a human-readable {@link String} representation of the provided time.
|
||||
*/
|
||||
public static String relativeDateFr(long time, boolean showSeconds, boolean compactWords) {
|
||||
return relativeDateFr(time,
|
||||
@@ -58,18 +58,18 @@ public class TimeUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Provides a human readable date of the provided time, with ability to adapt the text relatively to the current
|
||||
* Provides a human-readable date of the provided time, with ability to adapt the text relatively to the current
|
||||
* time (for instance "il y a 13 minutes" (french for "13 minutes ago"))
|
||||
* <p>
|
||||
* <b>This method renders the text in French.</b>
|
||||
*
|
||||
* @param time the timestamp in milliseconds of the time to diplay.
|
||||
* @param time the timestamp in milliseconds of the time to display.
|
||||
* @param relPrecision the precision of the relative text.
|
||||
* @param dispPrecision the precision of the full date and time.
|
||||
* @param displayPrecision the precision of the full date and time.
|
||||
* @param compactWords true to use compact words, false to use full words.
|
||||
* @return a human readable {@link String} representation of the provided time.
|
||||
* @return a human-readable {@link String} representation of the provided time.
|
||||
*/
|
||||
public static String relativeDateFr(long time, RelativePrecision relPrecision, DisplayPrecision dispPrecision, boolean compactWords) {
|
||||
public static String relativeDateFr(long time, RelativePrecision relPrecision, DisplayPrecision displayPrecision, boolean compactWords) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
@@ -91,27 +91,27 @@ public class TimeUtil {
|
||||
return compactWords ? "dans moins d’1min" : "dans moins d’une minute";
|
||||
if (timeDiffSec > -60*2) // dans 2 min
|
||||
return compactWords ? "dans 1min" : "dans une minute";
|
||||
if (timeDiffSec > -3600) // dans moins d’1h
|
||||
if (timeDiffSec > -3600) // dans moins d'1 h
|
||||
return "dans " + (-timeDiffSec/60) + (compactWords ? "min" : " minutes");
|
||||
}
|
||||
if (relPrecision.ordinal() >= RelativePrecision.HOURS.ordinal()) {
|
||||
if (timeDiffSec > -3600) // dans moins d’1h
|
||||
if (timeDiffSec > -3600) // dans moins d'1 h
|
||||
return compactWords ? "dans moins d’1h" : "dans moins d’une heure";
|
||||
if (timeDiffSec > -3600*2) // dans moins de 2h
|
||||
if (timeDiffSec > -3600*2) // dans moins de 2 h
|
||||
return compactWords ? "dans 1h" : "dans une heure";
|
||||
if (timeDiffSec > -3600*12) // dans moins de 12h
|
||||
if (timeDiffSec > -3600*12) // dans moins de 12 h
|
||||
return "dans " + (-timeDiffSec/3600) + (compactWords ? "h" : " heures");
|
||||
}
|
||||
if (relPrecision.ordinal() >= RelativePrecision.DAYS.ordinal()) {
|
||||
LocalDateTime nextMidnight = LocalDateTime.of(currentDateTime.getYear(), currentDateTime.getMonth(), currentDateTime.getDayOfMonth(), 0, 0).plusDays(1);
|
||||
if (displayDateTime.isBefore(nextMidnight)) // aujourd'hui
|
||||
return "aujourd’hui à " + dayTimeFr(time, dispPrecision);
|
||||
return "aujourd’hui à " + dayTimeFr(time, displayPrecision);
|
||||
if (displayDateTime.isBefore(nextMidnight.plusDays(1))) // demain
|
||||
return "demain à " + dayTimeFr(time, dispPrecision);
|
||||
return "demain à " + dayTimeFr(time, displayPrecision);
|
||||
if (displayDateTime.isBefore(nextMidnight.plusDays(5))) // dans moins d'1 semaine
|
||||
return (compactWords ? cmpDayOfWeekFormatter : dayOfWeekFormatter).format(displayDateTime) + " "
|
||||
+ dayOfMonthFormatter.format(displayDateTime) + " à "
|
||||
+ dayTimeFr(time, dispPrecision);
|
||||
+ dayTimeFr(time, displayPrecision);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -121,43 +121,43 @@ public class TimeUtil {
|
||||
return "maintenant";
|
||||
|
||||
if (relPrecision == RelativePrecision.SECONDS) {
|
||||
if (timeDiffSec < 60) // ya moins d'1 min
|
||||
if (timeDiffSec < 60) // il y a moins d'1 min
|
||||
return "il y a " + timeDiffSec + (compactWords ? "s" : " secondes");
|
||||
}
|
||||
if (relPrecision.ordinal() >= RelativePrecision.MINUTES.ordinal()) {
|
||||
if (timeDiffSec < 60) // ya moins d'1 min
|
||||
if (timeDiffSec < 60) // il y a moins d'1 min
|
||||
return compactWords ? "il y a moins d’1min" : "il y a moins d’une minute";
|
||||
if (timeDiffSec < 60*2) // ya moins de 2 min
|
||||
if (timeDiffSec < 60*2) // il y a moins de 2 min
|
||||
return compactWords ? "il y a 1min" : "il y a une minute";
|
||||
if (timeDiffSec < 3600) // ya moins d'1h
|
||||
if (timeDiffSec < 3600) // il y a moins d'1 h
|
||||
return "il y a " + (timeDiffSec/60) + (compactWords ? "min" : " minutes");
|
||||
}
|
||||
if (relPrecision.ordinal() >= RelativePrecision.HOURS.ordinal()) {
|
||||
if (timeDiffSec < 3600) // ya moins d'1h
|
||||
if (timeDiffSec < 3600) // il y a moins d'1 h
|
||||
return "il y a moins d’une heure";
|
||||
if (timeDiffSec < 3600*2) // ya moins de 2h
|
||||
if (timeDiffSec < 3600*2) // il y a moins de 2 h
|
||||
return "il y a une heure";
|
||||
if (timeDiffSec < 3600*12) // ya moins de 12h
|
||||
if (timeDiffSec < 3600*12) // il y a moins de 12 h
|
||||
return "il y a " + (timeDiffSec/3600) + " heures";
|
||||
}
|
||||
if (relPrecision.ordinal() >= RelativePrecision.DAYS.ordinal()) {
|
||||
LocalDateTime lastMidnight = LocalDateTime.of(currentDateTime.getYear(), currentDateTime.getMonth(), currentDateTime.getDayOfMonth(), 0, 0);
|
||||
if (!displayDateTime.isBefore(lastMidnight)) // aujourd'hui
|
||||
return "aujourd’hui à " + dayTimeFr(time, dispPrecision);
|
||||
return "aujourd’hui à " + dayTimeFr(time, displayPrecision);
|
||||
if (!displayDateTime.isBefore(lastMidnight.minusDays(1))) // hier
|
||||
return "hier à " + dayTimeFr(time, dispPrecision);
|
||||
if (!displayDateTime.isBefore(lastMidnight.minusDays(6))) // ya moins d'1 semaine
|
||||
return "hier à " + dayTimeFr(time, displayPrecision);
|
||||
if (!displayDateTime.isBefore(lastMidnight.minusDays(6))) // il y a moins d'1 semaine
|
||||
return (compactWords ? cmpDayOfWeekFormatter : dayOfWeekFormatter).format(displayDateTime) + " dernier à "
|
||||
+ dayTimeFr(time, dispPrecision);
|
||||
+ dayTimeFr(time, displayPrecision);
|
||||
}
|
||||
|
||||
}
|
||||
return fullDateFr(time, dispPrecision, true, compactWords);
|
||||
return fullDateFr(time, displayPrecision, true, compactWords);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumaration of different level of precision to display a relative time.
|
||||
* Enumeration of different level of precision to display a relative time.
|
||||
*/
|
||||
public enum RelativePrecision {
|
||||
/**
|
||||
@@ -183,7 +183,7 @@ public class TimeUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumaration of different level of precision to display a date and daytime.
|
||||
* Enumeration of different level of precision to display a date and daytime.
|
||||
*/
|
||||
public enum DisplayPrecision {
|
||||
/**
|
||||
@@ -195,11 +195,11 @@ public class TimeUtil {
|
||||
*/
|
||||
HOURS,
|
||||
/**
|
||||
* Display the date and the time of the day up to the minute.
|
||||
* Display the date and the time of the day with minute precision.
|
||||
*/
|
||||
MINUTES,
|
||||
/**
|
||||
* Display the date and the time of the day up to the second.
|
||||
* Display the date and the time of the day with second precision.
|
||||
*/
|
||||
SECONDS
|
||||
}
|
||||
@@ -211,7 +211,7 @@ public class TimeUtil {
|
||||
* <b>This method renders the text in French.</b>
|
||||
*
|
||||
* @param timestamp the time to represent in the returned string.
|
||||
* @param showSeconds if the returned string should includes seconds (true) or not (false). To have more control
|
||||
* @param showSeconds if the returned string should include seconds (true) or not (false). To have more control
|
||||
* over the precision, call {@link #fullDateFr(long, DisplayPrecision, boolean, boolean)}.
|
||||
* @param showWeekday true to show the week day, false otherwise.
|
||||
* @param compactWords true to use compact words, false to use full words.
|
||||
@@ -269,7 +269,7 @@ public class TimeUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Converts the provided duration into a human readable {@link String}.
|
||||
* Converts the provided duration into a human-readable {@link String}.
|
||||
* @param msDuration the duration in millisecond.
|
||||
* @param hUnit the biggest unit of time to display.
|
||||
* @param lUnit the smallest unit of time to display.
|
||||
@@ -334,7 +334,7 @@ public class TimeUtil {
|
||||
|
||||
/**
|
||||
* Indicate the 0-padded length of a number for the provided {@link TimeUnit}.
|
||||
* Will returns 3 for below-second time units, 2 for seconds, munutes and hours and 1 otherwise.
|
||||
* Will returns 3 for below-second time units, 2 for seconds, minutes and hours and 1 otherwise.
|
||||
* @param u the {@link TimeUnit}
|
||||
* @return the 0-padded length of a number for the provided {@link TimeUnit}.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user