Change AccountSession to use lombok features
- Change AccountSession to use lombok @Data annotation - Make UUID and created final Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -25,73 +25,15 @@
|
||||
package net.runelite.client.account;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(of = "uuid")
|
||||
public class AccountSession
|
||||
{
|
||||
private UUID uuid;
|
||||
private final UUID uuid;
|
||||
private final Instant created;
|
||||
private String username;
|
||||
private Instant created;
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = 3;
|
||||
hash = 29 * hash + Objects.hashCode(this.uuid);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final AccountSession other = (AccountSession) obj;
|
||||
if (!Objects.equals(this.uuid, other.uuid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public UUID getUuid()
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public Instant getCreated()
|
||||
{
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Instant created)
|
||||
{
|
||||
this.created = created;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,11 +132,7 @@ public class AccountPlugin extends Plugin
|
||||
}
|
||||
|
||||
// Create new session
|
||||
AccountSession session = new AccountSession();
|
||||
session.setUuid(login.getUid());
|
||||
session.setCreated(Instant.now());
|
||||
|
||||
sessionManager.openSession(session);
|
||||
sessionManager.openSession(new AccountSession(login.getUid(), Instant.now()));
|
||||
|
||||
if (!Desktop.isDesktopSupported())
|
||||
{
|
||||
|
||||
@@ -68,10 +68,8 @@ public class ConfigManagerTest
|
||||
@Test
|
||||
public void testGetConfig() throws IOException
|
||||
{
|
||||
AccountSession accountSession = new AccountSession();
|
||||
accountSession.setUuid(UUID.randomUUID());
|
||||
AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now());
|
||||
accountSession.setUsername("test");
|
||||
accountSession.setCreated(Instant.now());
|
||||
|
||||
manager.setConfiguration("test", "key", "moo");
|
||||
|
||||
@@ -82,10 +80,8 @@ public class ConfigManagerTest
|
||||
@Test
|
||||
public void testGetConfigDefault() throws IOException
|
||||
{
|
||||
AccountSession accountSession = new AccountSession();
|
||||
accountSession.setUuid(UUID.randomUUID());
|
||||
AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now());
|
||||
accountSession.setUsername("test");
|
||||
accountSession.setCreated(Instant.now());
|
||||
|
||||
TestConfig conf = manager.getConfig(TestConfig.class);
|
||||
Assert.assertEquals("default", conf.key());
|
||||
@@ -94,10 +90,8 @@ public class ConfigManagerTest
|
||||
@Test
|
||||
public void testSetConfig() throws IOException
|
||||
{
|
||||
AccountSession accountSession = new AccountSession();
|
||||
accountSession.setUuid(UUID.randomUUID());
|
||||
AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now());
|
||||
accountSession.setUsername("test");
|
||||
accountSession.setCreated(Instant.now());
|
||||
|
||||
TestConfig conf = manager.getConfig(TestConfig.class);
|
||||
conf.key("new value");
|
||||
@@ -108,10 +102,8 @@ public class ConfigManagerTest
|
||||
@Test
|
||||
public void testGetConfigDescriptor() throws IOException
|
||||
{
|
||||
AccountSession accountSession = new AccountSession();
|
||||
accountSession.setUuid(UUID.randomUUID());
|
||||
AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now());
|
||||
accountSession.setUsername("test");
|
||||
accountSession.setCreated(Instant.now());
|
||||
|
||||
TestConfig conf = manager.getConfig(TestConfig.class);
|
||||
ConfigDescriptor descriptor = manager.getConfigDescriptor(conf);
|
||||
|
||||
Reference in New Issue
Block a user