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;
import main.java.com.djrapitops.plan.utilities.html.Html;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.Serializable;
import java.util.*;
@ -289,40 +290,35 @@ public abstract class PluginData {
&& 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
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final PluginData other = (PluginData) obj;
return this.analysisOnly == other.analysisOnly
&& Objects.equals(this.placeholder, other.placeholder)
&& Objects.equals(this.sourcePlugin, other.sourcePlugin)
&& Objects.equals(this.analysisTypes, other.analysisTypes);
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PluginData that = (PluginData) o;
return analysisOnly == that.analysisOnly &&
Objects.equals(analysisTypes, that.analysisTypes) &&
Objects.equals(placeholder, that.placeholder) &&
Objects.equals(sourcePlugin, that.sourcePlugin) &&
Objects.equals(icon, that.icon) &&
Objects.equals(prefix, that.prefix) &&
Objects.equals(suffix, that.suffix);
}
@Override
public final int hashCode() {
int hash = 5;
hash = 47 * hash + Objects.hashCode(this.placeholder);
hash = 47 * hash + Objects.hashCode(this.sourcePlugin);
hash = 47 * hash + (this.analysisOnly ? 1 : 0);
hash = 47 * hash + Objects.hashCode(this.prefix);
hash = 47 * hash + Objects.hashCode(this.suffix);
hash = 47 * hash + Objects.hashCode(this.analysisTypes);
return hash;
public int hashCode() {
return Objects.hash(analysisTypes, placeholder, sourcePlugin, analysisOnly, icon, prefix, suffix);
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("analysisTypes", analysisTypes)
.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) {
state = newState;
}
Long currentTime = times.get(state);
if (currentTime == null) {
currentTime = 0L;
}
Long currentTime = times.getOrDefault(state, 0L);
long diff = playTime - lastStateChange;
times.put(state, currentTime + Math.abs(diff));
state = newState;

View File

@ -40,7 +40,7 @@ public class MySQLDB extends SQLDB {
String port = config.getInt("Database.MySQL.Port").toString();
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 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 {
return db.getConnection();
}
/**
* @return @throws SQLException
* @return
* @throws SQLException
*/
public int getVersion() throws SQLException {
return db.getVersion();

View File

@ -110,16 +110,8 @@ public class InspectPageParser extends PageParser {
long playtimeDay = AnalysisUtils.getTotalPlaytime(sessionsDay);
long playtimeWeek = AnalysisUtils.getTotalPlaytime(sessionsWeek);
if (!sessionsDay.isEmpty()) {
addValue("sessionLengthLongestDay", FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength()));
} else {
addValue("sessionLengthLongestDay", "-");
}
if (!sessionsWeek.isEmpty()) {
addValue("sessionLengthLongestWeek", FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength()));
} else {
addValue("sessionLengthLongestWeek", "-");
}
addValue("sessionLengthLongestDay", !sessionsDay.isEmpty() ? FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength()) : "-");
addValue("sessionLengthLongestWeek", !sessionsWeek.isEmpty() ? FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength()) : "-");
addValue("sessionCountDay", sessionCountDay);
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 main.java.com.djrapitops.plan.Log;
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.UserImportData;
import main.java.com.djrapitops.plan.systems.processing.importing.UserImportRefiner;
@ -60,6 +61,8 @@ public abstract class Importer {
return;
}
Database db = Plan.getInstance().getDB();
//TODO
Benchmark.start(benchmarkName);