Update PluginData#toString, PluginData#equals and PluginData#hashCode

Fix Warn message in Logs when the MySQL Server uses SSL
This commit is contained in:
Fuzzlemann 2017-09-03 01:40:37 +02:00
parent 2c156fd29a
commit 5aa6038df9
6 changed files with 38 additions and 49 deletions

View File

@ -1,6 +1,7 @@
package main.java.com.djrapitops.plan.data.additional; package main.java.com.djrapitops.plan.data.additional;
import main.java.com.djrapitops.plan.utilities.html.Html; import main.java.com.djrapitops.plan.utilities.html.Html;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.Serializable; import java.io.Serializable;
import java.util.*; import java.util.*;
@ -289,40 +290,35 @@ public abstract class PluginData {
&& analysisTypes.contains(AnalysisType.BOOLEAN_TOTAL); && analysisTypes.contains(AnalysisType.BOOLEAN_TOTAL);
} }
/**
* If a PluginData object has same placeholder, sourcePlugin and
* analysisTypes, it is considered equal.
*
* @param obj Another Object.
* @return Is current object equal to given object.
*/
@Override @Override
public final boolean equals(Object obj) { public boolean equals(Object o) {
if (this == obj) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
} PluginData that = (PluginData) o;
if (obj == null) { return analysisOnly == that.analysisOnly &&
return false; Objects.equals(analysisTypes, that.analysisTypes) &&
} Objects.equals(placeholder, that.placeholder) &&
if (getClass() != obj.getClass()) { Objects.equals(sourcePlugin, that.sourcePlugin) &&
return false; Objects.equals(icon, that.icon) &&
} Objects.equals(prefix, that.prefix) &&
final PluginData other = (PluginData) obj; Objects.equals(suffix, that.suffix);
return this.analysisOnly == other.analysisOnly
&& Objects.equals(this.placeholder, other.placeholder)
&& Objects.equals(this.sourcePlugin, other.sourcePlugin)
&& Objects.equals(this.analysisTypes, other.analysisTypes);
} }
@Override @Override
public final int hashCode() { public int hashCode() {
int hash = 5; return Objects.hash(analysisTypes, placeholder, sourcePlugin, analysisOnly, icon, prefix, suffix);
hash = 47 * hash + Objects.hashCode(this.placeholder); }
hash = 47 * hash + Objects.hashCode(this.sourcePlugin);
hash = 47 * hash + (this.analysisOnly ? 1 : 0); @Override
hash = 47 * hash + Objects.hashCode(this.prefix); public String toString() {
hash = 47 * hash + Objects.hashCode(this.suffix); return new ToStringBuilder(this)
hash = 47 * hash + Objects.hashCode(this.analysisTypes); .append("analysisTypes", analysisTypes)
return hash; .append("placeholder", placeholder)
.append("sourcePlugin", sourcePlugin)
.append("analysisOnly", analysisOnly)
.append("icon", icon)
.append("prefix", prefix)
.append("suffix", suffix)
.toString();
} }
} }

View File

@ -81,10 +81,7 @@ public abstract class TimeKeeper {
if (state == null) { if (state == null) {
state = newState; state = newState;
} }
Long currentTime = times.get(state); Long currentTime = times.getOrDefault(state, 0L);
if (currentTime == null) {
currentTime = 0L;
}
long diff = playTime - lastStateChange; long diff = playTime - lastStateChange;
times.put(state, currentTime + Math.abs(diff)); times.put(state, currentTime + Math.abs(diff));
state = newState; state = newState;

View File

@ -40,7 +40,7 @@ public class MySQLDB extends SQLDB {
String port = config.getInt("Database.MySQL.Port").toString(); String port = config.getInt("Database.MySQL.Port").toString();
String database = config.getString("Database.MySQL.Database"); String database = config.getString("Database.MySQL.Database");
dataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + database + "?rewriteBatchedStatements=true"); dataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + database + "?rewriteBatchedStatements=true&useSSL=false");
String username = config.getString("Database.MySQL.User"); String username = config.getString("Database.MySQL.User");
String password = config.getString("Database.MySQL.Password"); String password = config.getString("Database.MySQL.Password");

View File

@ -59,16 +59,17 @@ public abstract class Table {
} }
} }
/** /**
* @return @throws SQLException * @return
* @throws SQLException
*/ */
protected Connection getConnection() throws SQLException { protected Connection getConnection() throws SQLException {
return db.getConnection(); return db.getConnection();
} }
/** /**
* @return @throws SQLException * @return
* @throws SQLException
*/ */
public int getVersion() throws SQLException { public int getVersion() throws SQLException {
return db.getVersion(); return db.getVersion();

View File

@ -110,16 +110,8 @@ public class InspectPageParser extends PageParser {
long playtimeDay = AnalysisUtils.getTotalPlaytime(sessionsDay); long playtimeDay = AnalysisUtils.getTotalPlaytime(sessionsDay);
long playtimeWeek = AnalysisUtils.getTotalPlaytime(sessionsWeek); long playtimeWeek = AnalysisUtils.getTotalPlaytime(sessionsWeek);
if (!sessionsDay.isEmpty()) { addValue("sessionLengthLongestDay", !sessionsDay.isEmpty() ? FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength()) : "-");
addValue("sessionLengthLongestDay", FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength())); addValue("sessionLengthLongestWeek", !sessionsWeek.isEmpty() ? FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength()) : "-");
} else {
addValue("sessionLengthLongestDay", "-");
}
if (!sessionsWeek.isEmpty()) {
addValue("sessionLengthLongestWeek", FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength()));
} else {
addValue("sessionLengthLongestWeek", "-");
}
addValue("sessionCountDay", sessionCountDay); addValue("sessionCountDay", sessionCountDay);
addValue("sessionCountWeek", sessionCountWeek); addValue("sessionCountWeek", sessionCountWeek);

View File

@ -7,6 +7,7 @@ package main.java.com.djrapitops.plan.systems.processing.importing.importers;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.systems.processing.importing.ServerImportData; import main.java.com.djrapitops.plan.systems.processing.importing.ServerImportData;
import main.java.com.djrapitops.plan.systems.processing.importing.UserImportData; import main.java.com.djrapitops.plan.systems.processing.importing.UserImportData;
import main.java.com.djrapitops.plan.systems.processing.importing.UserImportRefiner; import main.java.com.djrapitops.plan.systems.processing.importing.UserImportRefiner;
@ -60,6 +61,8 @@ public abstract class Importer {
return; return;
} }
Database db = Plan.getInstance().getDB();
//TODO //TODO
Benchmark.start(benchmarkName); Benchmark.start(benchmarkName);