| Line 40... |
Line 40... |
| 40 |
import java.util.function.Predicate;
|
40 |
import java.util.function.Predicate;
|
| 41 |
import java.util.regex.Matcher;
|
41 |
import java.util.regex.Matcher;
|
| 42 |
import java.util.regex.Pattern;
|
42 |
import java.util.regex.Pattern;
|
| 43 |
|
43 |
|
| 44 |
public class Utils {
|
44 |
public class Utils {
|
| 45 |
|
45 |
|
| 46 |
private static final float FLOAT_EPSILON = 0.001f;
|
46 |
private static final float FLOAT_EPSILON = 0.001f;
|
| 47 |
|
47 |
|
| - |
|
48 |
private static final double DOUBLE_EPSILON = 0.001d;
|
| - |
|
49 |
|
| 48 |
private static final Logger logger = LogManager.getLogger(Utils.class);
|
50 |
private static final Logger logger = LogManager.getLogger(Utils.class);
|
| 49 |
public static final String EXPORT_ENTITIES_PATH = getExportPath();
|
51 |
public static final String EXPORT_ENTITIES_PATH = getExportPath();
|
| 50 |
public static final String PRODUCT_PROPERTIES_SNIPPET = "ProductPropertiesSnippet.html";
|
52 |
public static final String PRODUCT_PROPERTIES_SNIPPET = "ProductPropertiesSnippet.html";
|
| 51 |
public static final String DOCUMENT_STORE = "/profitmandi/documents/";
|
53 |
public static final String DOCUMENT_STORE = "/profitmandi/documents/";
|
| 52 |
private Gson gson = new Gson();
|
54 |
private Gson gson = new Gson();
|
| Line 59... |
Line 61... |
| 59 |
public static Map<RechargeOrderStatus, String> rechargeStatusMap = new HashMap<>();
|
61 |
public static Map<RechargeOrderStatus, String> rechargeStatusMap = new HashMap<>();
|
| 60 |
public static OrderStatusGroups ORDER_STATUS_GROUPS = new OrderStatusGroups();
|
62 |
public static OrderStatusGroups ORDER_STATUS_GROUPS = new OrderStatusGroups();
|
| 61 |
public static final String SYSTEM_PARTNER = "testpxps@gmail.com";
|
63 |
public static final String SYSTEM_PARTNER = "testpxps@gmail.com";
|
| 62 |
public static final int SYSTEM_PARTNER_ID = 175120474;
|
64 |
public static final int SYSTEM_PARTNER_ID = 175120474;
|
| 63 |
private static final RestClient rc = new RestClient();
|
65 |
private static final RestClient rc = new RestClient();
|
| 64 |
private static final String regex = "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$";
|
66 |
private static final String regex = "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$";
|
| 65 |
public static final LocalTime MAX_TIME=LocalTime.of(23, 59, 59);
|
67 |
public static final LocalTime MAX_TIME = LocalTime.of(23, 59, 59);
|
| 66 |
//Compile regular expression to get the pattern
|
68 |
// Compile regular expression to get the pattern
|
| 67 |
private static final Pattern pattern = Pattern.compile(regex);
|
69 |
private static final Pattern pattern = Pattern.compile(regex);
|
| 68 |
|
70 |
|
| 69 |
public static boolean validateEmail(String email) {
|
71 |
public static boolean validateEmail(String email) {
|
| 70 |
if(email== null) {
|
72 |
if (email == null) {
|
| 71 |
return false;
|
73 |
return false;
|
| 72 |
}
|
74 |
}
|
| 73 |
Matcher matcher = pattern.matcher(email);
|
75 |
Matcher matcher = pattern.matcher(email);
|
| 74 |
return matcher.matches();
|
76 |
return matcher.matches();
|
| 75 |
}
|
77 |
}
|
| 76 |
|
78 |
|
| 77 |
@SuppressWarnings("serial")
|
79 |
@SuppressWarnings("serial")
|
| 78 |
public static final Map<String, String> MIME_TYPE = Collections.unmodifiableMap(new HashMap<String, String>() {
|
80 |
public static final Map<String, String> MIME_TYPE = Collections.unmodifiableMap(new HashMap<String, String>() {
|
| 79 |
{
|
81 |
{
|
| 80 |
put("image/png", "png");
|
82 |
put("image/png", "png");
|
| Line 470... |
Line 472... |
| 470 |
return 0;
|
472 |
return 0;
|
| 471 |
}
|
473 |
}
|
| 472 |
return Float.compare(f1, f2);
|
474 |
return Float.compare(f1, f2);
|
| 473 |
}
|
475 |
}
|
| 474 |
|
476 |
|
| - |
|
477 |
public static int compareDouble(double d1, double d2) {
|
| - |
|
478 |
if ((d1 - d2 < DOUBLE_EPSILON) || (d1 - d2 < -DOUBLE_EPSILON)) {
|
| - |
|
479 |
return 0;
|
| - |
|
480 |
}
|
| - |
|
481 |
return Double.compare(d1, d2);
|
| - |
|
482 |
}
|
| - |
|
483 |
|
| 475 |
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
484 |
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
| 476 |
Set<Object> seen = ConcurrentHashMap.newKeySet();
|
485 |
Set<Object> seen = ConcurrentHashMap.newKeySet();
|
| 477 |
return t -> seen.add(keyExtractor.apply(t));
|
486 |
return t -> seen.add(keyExtractor.apply(t));
|
| 478 |
}
|
487 |
}
|
| 479 |
|
488 |
|
| 480 |
|
- |
|
| 481 |
}
|
489 |
}
|
| 482 |
|
490 |
|