mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Update summaries when billing rate configuration changes. Refactor some of the billing rate variable names to be more clear.
This commit is contained in:
@@ -177,6 +177,30 @@ public class CollectionUtils {
|
||||
return _arr[_arr.length - 1];
|
||||
}
|
||||
|
||||
public static <T> boolean isEqual(Collection<T> _l1, Collection<T> _l2) {
|
||||
if (size(_l1) != size(_l2))
|
||||
return false;
|
||||
Iterator<T> i1 = _l1.iterator();
|
||||
Iterator<T> i2 = _l2.iterator();
|
||||
while (i1.hasNext()) {
|
||||
if (NullUtils.isNotEqual(i1.next(), i2.next()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static <T extends IIdentical<T>> boolean isIdentical(Collection<T> _l1, Collection<T> _l2) {
|
||||
if (size(_l1) != size(_l2))
|
||||
return false;
|
||||
Iterator<T> i1 = _l1.iterator();
|
||||
Iterator<T> i2 = _l2.iterator();
|
||||
while (i1.hasNext()) {
|
||||
if (NullUtils.isNotIdentical(i1.next(), i2.next()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static <T> boolean contains(Collection<T> _coll, T _t) {
|
||||
if (_coll == null)
|
||||
return false;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.lanternsoftware.util;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public abstract class DateUtils {
|
||||
@@ -405,6 +405,14 @@ public abstract class DateUtils {
|
||||
return dateFormat(_format, _tz).format(_dt);
|
||||
}
|
||||
|
||||
public static String formatDate(int _format, TimeZone _tz, Date _dt) {
|
||||
if (_dt == null)
|
||||
return null;
|
||||
DateFormat format = DateFormat.getDateInstance(_format, Locale.getDefault());
|
||||
format.setTimeZone(_tz);
|
||||
return format.format(_dt);
|
||||
}
|
||||
|
||||
public static Date parse(String _format, String _date) {
|
||||
return parse(_format, TimeZone.getTimeZone("UTC"), _date);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.lanternsoftware.util;
|
||||
|
||||
public interface IIdentical<T> {
|
||||
boolean isIdentical(T _other);
|
||||
}
|
||||
@@ -23,6 +23,16 @@ public class NullUtils {
|
||||
return (b == null);
|
||||
}
|
||||
|
||||
public static <T extends IIdentical<T>> boolean isNotIdentical(T a, T b) {
|
||||
return !isIdentical(a, b);
|
||||
}
|
||||
|
||||
public static <T extends IIdentical<T>> boolean isIdentical(T a, T b) {
|
||||
if (a != null)
|
||||
return (b != null) && a.isIdentical(b);
|
||||
return (b == null);
|
||||
}
|
||||
|
||||
public static <T> boolean isNotEqual(T a, T b, IEquals<T> _equals) {
|
||||
return !isEqual(a, b, _equals);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user