Removed some unused FormatUtils methods

This commit is contained in:
Rsl1122 2018-05-25 10:37:16 +03:00
parent e8b412762b
commit 751e0e6cb4
2 changed files with 0 additions and 142 deletions

View File

@ -2,9 +2,7 @@ package com.djrapitops.plan.utilities;
import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.utilities.Format;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.Location;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -37,17 +35,6 @@ public class FormatUtils {
return formatMilliseconds(ms); return formatMilliseconds(ms);
} }
/**
* Format the time difference between an end point and a start point.
*
* @param before Epoch ms.
* @param after Epoch ms.
* @return String formatted with the config settings.
*/
public static String formatTimeAmountDifference(long before, long after) {
return formatMilliseconds(Math.abs(after - before));
}
public static String formatTimeStampISO8601NoClock(long epochMs) { public static String formatTimeStampISO8601NoClock(long epochMs) {
String format = "yyyy-MM-dd"; String format = "yyyy-MM-dd";
@ -117,34 +104,6 @@ public class FormatUtils {
return format(epochMs, format); return format(epochMs, format);
} }
/**
* Removes letters from a string leaving only numbers and dots.
*
* @param dataPoint String to remove stuff from.
* @return String with the stuff removed.
*/
public static String removeLetters(String dataPoint) {
return Format.create(dataPoint)
.removeLetters()
.removeWhitespace()
.removeSymbolsButDot()
.toString();
}
/**
* Removes numbers from a string leaving only letters.
*
* @param dataPoint String to remove stuff from.
* @return String with the stuff removed.
*/
public static String removeNumbers(String dataPoint) {
return Format.create(dataPoint)
.removeNumbers()
.removeWhitespace()
.removeDot()
.toString();
}
// Formats long in milliseconds into d:h:m:s string // Formats long in milliseconds into d:h:m:s string
private static String formatMilliseconds(long ms) { private static String formatMilliseconds(long ms) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -234,17 +193,6 @@ public class FormatUtils {
return formattedTime; return formattedTime;
} }
/**
* Turns the version string into a integer
*
* @param versionString String - number format 1.1.1
* @return parsed double - for example 1,11
* @throws NumberFormatException When wrong format
*/
public static long parseVersionNumber(String versionString) {
return com.djrapitops.plugin.utilities.FormatUtils.parseVersionNumber(versionString);
}
/** /**
* Merges multiple arrays into one. * Merges multiple arrays into one.
* *
@ -255,16 +203,6 @@ public class FormatUtils {
return com.djrapitops.plugin.utilities.FormatUtils.mergeArrays(arrays); return com.djrapitops.plugin.utilities.FormatUtils.mergeArrays(arrays);
} }
/**
* Formats a Minecraft Location into readable format.
*
* @param loc Location to format
* @return Readable location format.
*/
public static String formatLocation(Location loc) {
return com.djrapitops.plugin.utilities.FormatUtils.formatLocation(loc);
}
/** /**
* Remove extra decimals from the end of the double. * Remove extra decimals from the end of the double.
* *

View File

@ -1,8 +1,6 @@
package com.djrapitops.plan.utilities; package com.djrapitops.plan.utilities;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import org.bukkit.Location;
import org.bukkit.World;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
@ -12,9 +10,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import utilities.RandomData; import utilities.RandomData;
import utilities.Teardown; import utilities.Teardown;
import utilities.mocks.SystemMockUtil; import utilities.mocks.SystemMockUtil;
import utilities.mocks.objects.MockUtils;
import java.util.Date;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -42,74 +37,12 @@ public class FormatUtilsTest {
assertEquals(expResult, result); assertEquals(expResult, result);
} }
@Test
public void testFormatTimeAmountSinceDate() {
Date before = new Date(300000L);
Date now = new Date(310000L);
String expResult = "10s";
String result = FormatUtils.formatTimeAmountDifference(before.getTime(), now.getTime());
assertEquals(expResult, result);
}
@Test @Test
public void testFormatTimeAmountMonths() { public void testFormatTimeAmountMonths() {
long time = TimeAmount.DAY.ms() * 40L; long time = TimeAmount.DAY.ms() * 40L;
assertEquals("1 month, 10d ", FormatUtils.formatTimeAmount(time)); assertEquals("1 month, 10d ", FormatUtils.formatTimeAmount(time));
} }
@Test
public void testRemoveLetters() {
String dataPoint = "435729847jirggu.eiwb¤#¤%¤#";
String expResult = "435729847.";
String result = FormatUtils.removeLetters(dataPoint);
assertEquals(expResult, result);
}
@Test
public void testRemoveNumbers() {
String dataPoint = "34532453.5 $";
String expResult = "$";
String result = FormatUtils.removeNumbers(dataPoint);
assertEquals(expResult, result);
}
@Test
public void testRemoveNumbers2() {
String dataPoint = "l43r4545tl43 4.5";
String expResult = "lrtl";
String result = FormatUtils.removeNumbers(dataPoint);
assertEquals(expResult, result);
}
@Test
public void testParseVersionNumber() {
String versionString = "2.10.2";
long expResult = 21002000000000000L;
long result = FormatUtils.parseVersionNumber(versionString);
assertEquals(expResult, result);
}
@Test
public void testVersionNumber() {
String versionString = "2.10.2";
String versionString2 = "2.9.3";
long result = FormatUtils.parseVersionNumber(versionString);
long result2 = FormatUtils.parseVersionNumber(versionString2);
assertTrue("Higher version not higher", result > result2);
}
@Test @Test
public void testMergeArrays() { public void testMergeArrays() {
String randomString1 = RandomData.randomString(10); String randomString1 = RandomData.randomString(10);
@ -125,19 +58,6 @@ public class FormatUtilsTest {
assertArrayEquals(expResult, result); assertArrayEquals(expResult, result);
} }
@Test
public void testFormatLocation() {
int randomInt = RandomData.randomInt(0, 100);
World mockWorld = MockUtils.mockWorld();
Location loc = new Location(mockWorld, randomInt, randomInt, randomInt);
String expResult = "x " + randomInt + " z " + randomInt + " in World";
String result = FormatUtils.formatLocation(loc);
assertEquals(expResult, result);
}
@Test @Test
public void testCutDecimalsWhichIsRoundedDown() { public void testCutDecimalsWhichIsRoundedDown() {
double d = 0.05234; double d = 0.05234;