From 7151e69e9cafaccef870c3b2161da00c933a2fb9 Mon Sep 17 00:00:00 2001 From: mbax Date: Thu, 23 Jul 2020 00:48:02 -0400 Subject: [PATCH] Just some code cleanup --- .../org/kitteh/irc/client/library/Client.java | 2 +- .../library/command/ChannelModeCommand.java | 2 +- .../irc/client/library/command/Command.java | 2 +- .../library/defaults/DefaultBuilder.java | 36 ++++++------ .../isupport/DefaultISupportMaxList.java | 2 +- .../isupport/DefaultISupportPrefix.java | 2 +- .../element/mode/DefaultModeStatusList.java | 4 +- .../defaults/feature/DefaultActorTracker.java | 4 +- .../feature/DefaultMessageTagManager.java | 2 +- .../feature/FilteringSubscriptionFactory.java | 2 +- .../feature/network/NettyConnection.java | 2 +- .../feature/network/NettyNetworkHandler.java | 20 +++---- .../defaults/listener/DefaultCapListener.java | 10 ++-- .../ClientConnectionEndedEvent.java | 2 +- .../library/feature/CapabilityManager.java | 4 +- .../client/library/feature/CaseMapping.java | 6 +- .../auth/SaslEcdsaNist256PChallenge.java | 2 +- .../library/feature/sts/StsHandler.java | 4 +- .../sts/StsPropertiesStorageManager.java | 4 +- .../feature/twitch/TwitchDelaySender.java | 4 +- .../library/feature/twitch/TwitchSupport.java | 56 +++++++++---------- .../feature/twitch/messagetag/Badges.java | 2 +- .../feature/twitch/messagetag/Emotes.java | 2 +- .../kitteh/irc/client/library/util/CISet.java | 2 +- .../irc/client/library/util/CtcpUtil.java | 32 +++++------ .../irc/client/library/util/Format.java | 12 ++-- .../irc/client/library/util/HostWithPort.java | 8 +-- .../irc/client/library/util/StringUtil.java | 2 +- .../irc/client/library/util/StsUtil.java | 2 +- .../irc/client/library/util/Version.java | 2 +- 30 files changed, 118 insertions(+), 118 deletions(-) diff --git a/src/main/java/org/kitteh/irc/client/library/Client.java b/src/main/java/org/kitteh/irc/client/library/Client.java index 6dd4952bd..fe90f21aa 100644 --- a/src/main/java/org/kitteh/irc/client/library/Client.java +++ b/src/main/java/org/kitteh/irc/client/library/Client.java @@ -149,7 +149,7 @@ enum SecurityType { /** * TLS disabled. */ - INSECURE; + INSECURE } /** diff --git a/src/main/java/org/kitteh/irc/client/library/command/ChannelModeCommand.java b/src/main/java/org/kitteh/irc/client/library/command/ChannelModeCommand.java index 758acc144..7cbab84cb 100644 --- a/src/main/java/org/kitteh/irc/client/library/command/ChannelModeCommand.java +++ b/src/main/java/org/kitteh/irc/client/library/command/ChannelModeCommand.java @@ -125,7 +125,7 @@ public synchronized void execute() { parameterModesPerLine = modes.get().getInteger(); } if (parameterModesPerLine < 1) { - parameterModesPerLine = PARAMETER_MODES_PER_LINE; + parameterModesPerLine = ChannelModeCommand.PARAMETER_MODES_PER_LINE; } List> queue = new ArrayList<>(); int currentParamModes = 0; diff --git a/src/main/java/org/kitteh/irc/client/library/command/Command.java b/src/main/java/org/kitteh/irc/client/library/command/Command.java index 5e69d8158..ca3c43eeb 100644 --- a/src/main/java/org/kitteh/irc/client/library/command/Command.java +++ b/src/main/java/org/kitteh/irc/client/library/command/Command.java @@ -39,7 +39,7 @@ */ public abstract class Command> implements ClientLinked { public class Tags { - private List tags = new ArrayList<>(); + private final List tags = new ArrayList<>(); public Tags add(@NonNull MessageTag tag) { this.tags.add(Sanity.nullCheck(tag, "Tag")); diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/DefaultBuilder.java b/src/main/java/org/kitteh/irc/client/library/defaults/DefaultBuilder.java index 98124a1bb..8cb864b7f 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/DefaultBuilder.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/DefaultBuilder.java @@ -248,19 +248,19 @@ private class WebIrcImpl implements WebIrc, WebIrc.Hostname, WebIrc.Gateway, Web private class ManagementImpl implements Management { @Override public @NonNull Management actorTracker(@Nullable Function supplier) { - DefaultBuilder.this.actorTracker = (supplier != null) ? supplier : DEFAULT_ACTOR_TRACKER; + DefaultBuilder.this.actorTracker = (supplier != null) ? supplier : DefaultBuilder.DEFAULT_ACTOR_TRACKER; return this; } @Override public @NonNull Management authManager(@Nullable Function supplier) { - DefaultBuilder.this.authManager = (supplier != null) ? supplier : DEFAULT_AUTH_MANAGER; + DefaultBuilder.this.authManager = (supplier != null) ? supplier : DefaultBuilder.DEFAULT_AUTH_MANAGER; return this; } @Override public @NonNull Management capabilityManager(@Nullable Function supplier) { - DefaultBuilder.this.capabilityManager = (supplier != null) ? supplier : DEFAULT_CAPABILITY_MANAGER; + DefaultBuilder.this.capabilityManager = (supplier != null) ? supplier : DefaultBuilder.DEFAULT_CAPABILITY_MANAGER; return this; } @@ -272,19 +272,19 @@ private class ManagementImpl implements Management { @Override public @NonNull Management eventManager(@Nullable Function supplier) { - DefaultBuilder.this.eventManager = (supplier != null) ? supplier : DEFAULT_EVENT_MANAGER; + DefaultBuilder.this.eventManager = (supplier != null) ? supplier : DefaultBuilder.DEFAULT_EVENT_MANAGER; return this; } @Override public @NonNull Management eventListeners(@Nullable List listenerSuppliers) { - DefaultBuilder.this.eventListeners = (listenerSuppliers != null) ? listenerSuppliers : DEFAULT_EVENT_LISTENERS; + DefaultBuilder.this.eventListeners = (listenerSuppliers != null) ? listenerSuppliers : DefaultBuilder.DEFAULT_EVENT_LISTENERS; return this; } @Override public @NonNull Management iSupportManager(@Nullable Function supplier) { - DefaultBuilder.this.iSupportManager = (supplier != null) ? supplier : DEFAULT_ISUPPORT_MANAGER; + DefaultBuilder.this.iSupportManager = (supplier != null) ? supplier : DefaultBuilder.DEFAULT_ISUPPORT_MANAGER; return this; } @@ -296,7 +296,7 @@ private class ManagementImpl implements Management { @Override public @NonNull Management messageTagManager(@Nullable Function supplier) { - DefaultBuilder.this.messageTagManager = (supplier != null) ? supplier : DEFAULT_MESSAGE_TAG_MANAGER; + DefaultBuilder.this.messageTagManager = (supplier != null) ? supplier : DefaultBuilder.DEFAULT_MESSAGE_TAG_MANAGER; return this; } @@ -308,7 +308,7 @@ private class ManagementImpl implements Management { @Override public @NonNull Management serverInfo(@Nullable Function supplier) { - DefaultBuilder.this.serverInfo = (supplier != null) ? supplier : DEFAULT_SERVER_INFO; + DefaultBuilder.this.serverInfo = (supplier != null) ? supplier : DefaultBuilder.DEFAULT_SERVER_INFO; return this; } @@ -342,7 +342,7 @@ private class ManagementImpl implements Management { private @Nullable String bindHost; private int bindPort; - private HostWithPort serverHostWithPort = HostWithPort.of(DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT); + private HostWithPort serverHostWithPort = HostWithPort.of(DefaultBuilder.DEFAULT_SERVER_HOST, DefaultBuilder.DEFAULT_SERVER_PORT); private @Nullable String serverPassword = null; private boolean secure = true; private @Nullable Path secureKeyCertChain = null; @@ -371,17 +371,17 @@ private class ManagementImpl implements Management { private @Nullable String webircGateway = null; // Management - private Function actorTracker = DEFAULT_ACTOR_TRACKER; - private Function authManager = DEFAULT_AUTH_MANAGER; - private Function capabilityManager = DEFAULT_CAPABILITY_MANAGER; + private Function actorTracker = DefaultBuilder.DEFAULT_ACTOR_TRACKER; + private Function authManager = DefaultBuilder.DEFAULT_AUTH_MANAGER; + private Function capabilityManager = DefaultBuilder.DEFAULT_CAPABILITY_MANAGER; private @Nullable DefaultMessageMap defaultMessageMap = null; - private Function eventManager = DEFAULT_EVENT_MANAGER; - private List eventListeners = DEFAULT_EVENT_LISTENERS; - private Function iSupportManager = DEFAULT_ISUPPORT_MANAGER; - private Function messageSendingQueue = DEFAULT_MESSAGE_SENDING_QUEUE; - private Function messageTagManager = DEFAULT_MESSAGE_TAG_MANAGER; + private Function eventManager = DefaultBuilder.DEFAULT_EVENT_MANAGER; + private List eventListeners = DefaultBuilder.DEFAULT_EVENT_LISTENERS; + private Function iSupportManager = DefaultBuilder.DEFAULT_ISUPPORT_MANAGER; + private Function messageSendingQueue = DefaultBuilder.DEFAULT_MESSAGE_SENDING_QUEUE; + private Function messageTagManager = DefaultBuilder.DEFAULT_MESSAGE_TAG_MANAGER; private NetworkHandler networkHandler = NettyNetworkHandler.getInstance(); - private Function serverInfo = DEFAULT_SERVER_INFO; + private Function serverInfo = DefaultBuilder.DEFAULT_SERVER_INFO; private @Nullable StsStorageManager stsStorageManager = null; @Override diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/element/isupport/DefaultISupportMaxList.java b/src/main/java/org/kitteh/irc/client/library/defaults/element/isupport/DefaultISupportMaxList.java index 710be866a..8e57f33de 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/element/isupport/DefaultISupportMaxList.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/element/isupport/DefaultISupportMaxList.java @@ -40,7 +40,7 @@ public class DefaultISupportMaxList extends DefaultISupportParameterValueRequire /** * Default implementation of {@link MaxList.LimitData}. */ - public class DefaultLimitData implements MaxList.LimitData { + public static class DefaultLimitData implements MaxList.LimitData { private final int limit; private final Set modes; diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/element/isupport/DefaultISupportPrefix.java b/src/main/java/org/kitteh/irc/client/library/defaults/element/isupport/DefaultISupportPrefix.java index 6ad88ae5c..a834c69aa 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/element/isupport/DefaultISupportPrefix.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/element/isupport/DefaultISupportPrefix.java @@ -54,7 +54,7 @@ public class DefaultISupportPrefix extends DefaultISupportParameterValueRequired */ public DefaultISupportPrefix(@NonNull Client client, @NonNull String name, @Nullable String value) { super(client, name, value); - Matcher matcher = PATTERN.matcher(value); + Matcher matcher = DefaultISupportPrefix.PATTERN.matcher(value); if (!matcher.find()) { throw new KittehServerISupportException(name, "Data does not match expected pattern"); } diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/element/mode/DefaultModeStatusList.java b/src/main/java/org/kitteh/irc/client/library/defaults/element/mode/DefaultModeStatusList.java index 1b8f3cbb9..200cc9598 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/element/mode/DefaultModeStatusList.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/element/mode/DefaultModeStatusList.java @@ -62,7 +62,7 @@ public class DefaultModeStatusList implements ModeStatusL Map modes = new HashMap<>(); client.getServerInfo().getChannelModes().forEach(mode -> modes.put(mode.getChar(), mode)); client.getServerInfo().getChannelUserModes().forEach(mode -> modes.put(mode.getChar(), mode)); - return from(string, modes); + return DefaultModeStatusList.from(string, modes); } /** @@ -73,7 +73,7 @@ public class DefaultModeStatusList implements ModeStatusL * @return list */ public static @NonNull DefaultModeStatusList fromUser(@NonNull Client client, @NonNull String string) { - return from(string, client.getServerInfo().getUserModes().stream().collect(Collectors.toMap(UserMode::getChar, Function.identity()))); + return DefaultModeStatusList.from(string, client.getServerInfo().getUserModes().stream().collect(Collectors.toMap(UserMode::getChar, Function.identity()))); } private static @NonNull DefaultModeStatusList from(@NonNull String string, @NonNull Map modes) { diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/feature/DefaultActorTracker.java b/src/main/java/org/kitteh/irc/client/library/defaults/feature/DefaultActorTracker.java index 8a689d87a..58c5fc024 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/feature/DefaultActorTracker.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/feature/DefaultActorTracker.java @@ -466,14 +466,14 @@ public DefaultActorTracker(Client.@NonNull WithManagement client) { } else if (this.client.getServerInfo().isValidChannel(name)) { return new IrcChannel(name).snapshot(); } - if (name.isEmpty() || SERVER_PATTERN.matcher(name).matches()) { + if (name.isEmpty() || DefaultActorTracker.SERVER_PATTERN.matcher(name).matches()) { return new IrcServer(name).snapshot(); } return new IrcActor(name).snapshot(); } private IrcUser getUserByName(@NonNull String name) { - Matcher nickMatcher = NICK_PATTERN.matcher(name); + Matcher nickMatcher = DefaultActorTracker.NICK_PATTERN.matcher(name); if (nickMatcher.matches()) { String nick = nickMatcher.group(1); IrcUser user = this.trackedUsers.get(nick); diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/feature/DefaultMessageTagManager.java b/src/main/java/org/kitteh/irc/client/library/defaults/feature/DefaultMessageTagManager.java index cb7230292..353d6536d 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/feature/DefaultMessageTagManager.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/feature/DefaultMessageTagManager.java @@ -144,7 +144,7 @@ public DefaultMessageTagManager(Client.WithManagement client) { private @NonNull String getTagValue(@NonNull String tag) { StringBuilder builder = new StringBuilder(tag.length()); int currentIndex = 0; - Matcher matcher = TAG_ESCAPE.matcher(tag); + Matcher matcher = DefaultMessageTagManager.TAG_ESCAPE.matcher(tag); while (matcher.find()) { if (matcher.start() > currentIndex) { builder.append(tag, currentIndex, matcher.start()); diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/feature/FilteringSubscriptionFactory.java b/src/main/java/org/kitteh/irc/client/library/defaults/feature/FilteringSubscriptionFactory.java index 39b83b104..0b1bee57b 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/feature/FilteringSubscriptionFactory.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/feature/FilteringSubscriptionFactory.java @@ -91,7 +91,7 @@ public void dispatch(MessagePublication publication, Object message, Iterable li } } - private final class FilterProcessorWrapper { + private static final class FilterProcessorWrapper { private final Annotation[] annotations; private final FilterProcessor filterProcessor; diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/feature/network/NettyConnection.java b/src/main/java/org/kitteh/irc/client/library/defaults/feature/network/NettyConnection.java index 8fa9c28a7..29bd3331e 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/feature/network/NettyConnection.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/feature/network/NettyConnection.java @@ -155,7 +155,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { }); // Inbound - this.channel.pipeline().addLast("[INPUT] Line splitter", new DelimiterBasedFrameDecoder(MAX_LINE_LENGTH, Unpooled.wrappedBuffer(new byte[]{(byte) '\r', (byte) '\n'}))); + this.channel.pipeline().addLast("[INPUT] Line splitter", new DelimiterBasedFrameDecoder(NettyConnection.MAX_LINE_LENGTH, Unpooled.wrappedBuffer(new byte[]{(byte) '\r', (byte) '\n'}))); this.channel.pipeline().addLast("[INPUT] String decoder", new StringDecoder(CharsetUtil.UTF_8)); this.channel.pipeline().addLast("[INPUT] Send to client", new SimpleChannelInboundHandler() { @Override diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/feature/network/NettyNetworkHandler.java b/src/main/java/org/kitteh/irc/client/library/defaults/feature/network/NettyNetworkHandler.java index e93d586fc..baebc6196 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/feature/network/NettyNetworkHandler.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/feature/network/NettyNetworkHandler.java @@ -65,7 +65,7 @@ public class NettyNetworkHandler implements NetworkHandler { * @return instance */ public static @NonNull NettyNetworkHandler getInstance() { - return instance; + return NettyNetworkHandler.instance; } private @Nullable EventLoopGroup eventLoopGroup; @@ -82,12 +82,12 @@ private NettyNetworkHandler() { * @param client client for whom to remove the connection */ private synchronized void removeClientConnection(Client.@NonNull WithManagement client) { - clients.remove(client); - if (clients.isEmpty()) { - if (eventLoopGroup != null) { - eventLoopGroup.shutdownGracefully(); + this.clients.remove(client); + if (this.clients.isEmpty()) { + if (this.eventLoopGroup != null) { + this.eventLoopGroup.shutdownGracefully(); } - eventLoopGroup = null; + this.eventLoopGroup = null; } } @@ -104,13 +104,13 @@ private synchronized void removeClientConnection(Client.@NonNull WithManagement } } - if (eventLoopGroup == null) { - eventLoopGroup = new NioEventLoopGroup(); + if (this.eventLoopGroup == null) { + this.eventLoopGroup = new NioEventLoopGroup(); } final Bootstrap bootstrap = new Bootstrap() .channel(NioSocketChannel.class) - .group(eventLoopGroup) + .group(this.eventLoopGroup) .handler(new ChannelInitializer() { @Override public void initChannel(SocketChannel channel) { @@ -144,7 +144,7 @@ public void initChannel(SocketChannel channel) { } NettyConnection clientConnection = new NettyConnection(client, bootstrap.connect(server, bind), this::removeClientConnection); - clients.add(client); + this.clients.add(client); return clientConnection; } diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/listener/DefaultCapListener.java b/src/main/java/org/kitteh/irc/client/library/defaults/listener/DefaultCapListener.java index 617a6467d..f0d8fa72c 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/listener/DefaultCapListener.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/listener/DefaultCapListener.java @@ -78,14 +78,14 @@ public void cap(ClientReceiveCommandEvent event) { } CapabilityNegotiationResponseEvent responseEvent = null; int capabilityListIndex; - if ("*".equals(event.getParameters().get(CAPABILITY_LIST_INDEX_DEFAULT))) { + if ("*".equals(event.getParameters().get(DefaultCapListener.CAPABILITY_LIST_INDEX_DEFAULT))) { if (event.getParameters().size() < 4) { this.trackException(event, "CAP message too short"); return; } - capabilityListIndex = CAPABILITY_LIST_INDEX_DEFAULT + 1; + capabilityListIndex = DefaultCapListener.CAPABILITY_LIST_INDEX_DEFAULT + 1; } else { - capabilityListIndex = CAPABILITY_LIST_INDEX_DEFAULT; + capabilityListIndex = DefaultCapListener.CAPABILITY_LIST_INDEX_DEFAULT; } List capabilityStateList = Arrays.stream(event.getParameters().get(capabilityListIndex).split(" ")).filter(string -> !string.isEmpty()).map(capability -> new DefaultCapabilityState(this.getClient(), capability)).collect(Collectors.toCollection(ArrayList::new)); switch (event.getParameters().get(1).toLowerCase()) { @@ -96,7 +96,7 @@ public void cap(ClientReceiveCommandEvent event) { break; case "list": this.capListMessages.add(event.getServerMessage()); - if (capabilityListIndex != CAPABILITY_LIST_INDEX_DEFAULT) { + if (capabilityListIndex != DefaultCapListener.CAPABILITY_LIST_INDEX_DEFAULT) { this.capList.addAll(capabilityStateList); } else { List states; @@ -113,7 +113,7 @@ public void cap(ClientReceiveCommandEvent event) { break; case "ls": this.capLsMessages.add(event.getServerMessage()); - if (capabilityListIndex != CAPABILITY_LIST_INDEX_DEFAULT) { + if (capabilityListIndex != DefaultCapListener.CAPABILITY_LIST_INDEX_DEFAULT) { this.capLs.addAll(capabilityStateList); } else { List states; diff --git a/src/main/java/org/kitteh/irc/client/library/event/connection/ClientConnectionEndedEvent.java b/src/main/java/org/kitteh/irc/client/library/event/connection/ClientConnectionEndedEvent.java index 88a68088f..f32481324 100644 --- a/src/main/java/org/kitteh/irc/client/library/event/connection/ClientConnectionEndedEvent.java +++ b/src/main/java/org/kitteh/irc/client/library/event/connection/ClientConnectionEndedEvent.java @@ -44,7 +44,7 @@ public abstract class ClientConnectionEndedEvent extends ClientEventBase impleme private final boolean canReconnect; private final @Nullable Throwable cause; - private int reconnectionDelayMillis = DEFAULT_RECONNECTION_DELAY_MILLIS; + private int reconnectionDelayMillis = ClientConnectionEndedEvent.DEFAULT_RECONNECTION_DELAY_MILLIS; private boolean attemptReconnect; /** diff --git a/src/main/java/org/kitteh/irc/client/library/feature/CapabilityManager.java b/src/main/java/org/kitteh/irc/client/library/feature/CapabilityManager.java index bb081e7b8..bd0660e67 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/CapabilityManager.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/CapabilityManager.java @@ -170,13 +170,13 @@ private Defaults() { * @return all capability names */ public static List getDefaults() { - return DEFAULTS; + return Defaults.DEFAULTS; } static { DEFAULTS = Collections.unmodifiableList(Arrays.stream(Defaults.class.getDeclaredFields()) .filter(field -> Modifier.isPublic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) - .map(Defaults::getStringForCapabilityField).collect(Collectors.toCollection(SUPPLIER))); + .map(Defaults::getStringForCapabilityField).collect(Collectors.toCollection(Defaults.SUPPLIER))); } /** diff --git a/src/main/java/org/kitteh/irc/client/library/feature/CaseMapping.java b/src/main/java/org/kitteh/irc/client/library/feature/CaseMapping.java index f7867a2f9..b9c1b8e0d 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/CaseMapping.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/CaseMapping.java @@ -51,8 +51,8 @@ public enum CaseMapping { private static final Map nameMap = new HashMap<>(); static { - for (CaseMapping caseMapping : values()) { - nameMap.put(caseMapping.name().replace('_', '-'), caseMapping); + for (CaseMapping caseMapping : CaseMapping.values()) { + CaseMapping.nameMap.put(caseMapping.name().replace('_', '-'), caseMapping); } } @@ -63,7 +63,7 @@ public enum CaseMapping { * @return the matching CaseMapping if one exists */ public static @NonNull Optional getByName(@Nullable String name) { - return (name == null) ? Optional.empty() : Optional.ofNullable(nameMap.get(name.toUpperCase())); + return (name == null) ? Optional.empty() : Optional.ofNullable(CaseMapping.nameMap.get(name.toUpperCase())); } private final char upperbound; diff --git a/src/main/java/org/kitteh/irc/client/library/feature/auth/SaslEcdsaNist256PChallenge.java b/src/main/java/org/kitteh/irc/client/library/feature/auth/SaslEcdsaNist256PChallenge.java index 7663eb254..222ef54a0 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/auth/SaslEcdsaNist256PChallenge.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/auth/SaslEcdsaNist256PChallenge.java @@ -101,7 +101,7 @@ public void authenticate(ClientReceiveCommandEvent event) { } else { String challenge = event.getParameters().get(0); try { - base64 = sign(SaslEcdsaNist256PChallenge.this.privateKey, challenge); + base64 = SaslEcdsaNist256PChallenge.sign(SaslEcdsaNist256PChallenge.this.privateKey, challenge); } catch (Exception e) { throw new RuntimeException(e); // TODO make this better } diff --git a/src/main/java/org/kitteh/irc/client/library/feature/sts/StsHandler.java b/src/main/java/org/kitteh/irc/client/library/feature/sts/StsHandler.java index 4b40befbe..08594c33e 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/sts/StsHandler.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/sts/StsHandler.java @@ -47,7 +47,7 @@ public class StsHandler { * Draft prepend for capability. */ public static final String DRAFT = "draft/"; - private static final Predicate STS_CAPABILITY_PREDICATE = c -> c.getName().equals(DRAFT + "sts") || c.getName().equals("sts"); + private static final Predicate STS_CAPABILITY_PREDICATE = c -> c.getName().equals(StsHandler.DRAFT + "sts") || c.getName().equals("sts"); private final StsMachine machine; private final Client.WithManagement client; private boolean isSecure; @@ -96,7 +96,7 @@ public void onCapLs(CapabilitiesSupportedListEvent event) { public void onCapNew(CapabilitiesNewSupportedEvent event) { // stability not a concern, only one or zero result(s) final Optional potentialStsCapability = event.getNewCapabilities().stream() - .filter(STS_CAPABILITY_PREDICATE).findAny(); + .filter(StsHandler.STS_CAPABILITY_PREDICATE).findAny(); if (!potentialStsCapability.isPresent()) { // get out if we can't do anything useful here diff --git a/src/main/java/org/kitteh/irc/client/library/feature/sts/StsPropertiesStorageManager.java b/src/main/java/org/kitteh/irc/client/library/feature/sts/StsPropertiesStorageManager.java index 73b80555b..7bc02eb60 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/sts/StsPropertiesStorageManager.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/sts/StsPropertiesStorageManager.java @@ -147,7 +147,7 @@ private void pruneEntries() { for (String hostname : this.properties.stringPropertyNames()) { String value = this.properties.getProperty(hostname); String[] components = value.split("; "); - ZonedDateTime dt = ZonedDateTime.parse(components[0], DATE_TIME_FORMATTER); + ZonedDateTime dt = ZonedDateTime.parse(components[0], StsPropertiesStorageManager.DATE_TIME_FORMATTER); if (dt.isBefore(ZonedDateTime.now(ZoneOffset.UTC))) { stagedRemovals.add(hostname); // CME } @@ -195,6 +195,6 @@ private String reserializeData(StsPolicy policy) { * @return the date-time string e.g. 2016-01-01T00:00:00Z */ private String getExpiryFromDuration(long duration) { - return ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(duration).format(DATE_TIME_FORMATTER); + return ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(duration).format(StsPropertiesStorageManager.DATE_TIME_FORMATTER); } } diff --git a/src/main/java/org/kitteh/irc/client/library/feature/twitch/TwitchDelaySender.java b/src/main/java/org/kitteh/irc/client/library/feature/twitch/TwitchDelaySender.java index d1bbc0576..00ade6f4f 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/twitch/TwitchDelaySender.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/twitch/TwitchDelaySender.java @@ -50,7 +50,7 @@ public class TwitchDelaySender extends QueueProcessingThreadSender { * @return supplier */ public static Function getSupplier() { - return getSupplier(false); + return TwitchDelaySender.getSupplier(false); } /** @@ -63,7 +63,7 @@ public static Function getSupplier() { public static Function getSupplier(boolean modOrOpOnly) { return client -> new TwitchDelaySender(client, "TwitchDelay " + (modOrOpOnly ? "Only Mod/Op" : "Standard"), - modOrOpOnly ? MOD_OP_PER_THIRTY_SECONDS : NON_MOD_OP_PER_THIRTY_SECONDS); + modOrOpOnly ? TwitchDelaySender.MOD_OP_PER_THIRTY_SECONDS : TwitchDelaySender.NON_MOD_OP_PER_THIRTY_SECONDS); } /** diff --git a/src/main/java/org/kitteh/irc/client/library/feature/twitch/TwitchSupport.java b/src/main/java/org/kitteh/irc/client/library/feature/twitch/TwitchSupport.java index ca5c8e803..58437de5e 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/twitch/TwitchSupport.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/twitch/TwitchSupport.java @@ -87,7 +87,7 @@ public final class TwitchSupport { * @see TwitchDelaySender */ public static Client addSupport(@NonNull Client client) { - return addSupport(client, false); + return TwitchSupport.addSupport(client, false); } /** @@ -118,33 +118,33 @@ public static Client addSupport(@NonNull Client client, boolean alwaysModOrOp) { ((Client.WithManagement) client).getActorTracker().setQueryChannelInformation(false); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Badges.NAME, Badges.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, BanDuration.NAME, BanDuration.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, BanReason.NAME, BanReason.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Bits.NAME, Bits.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, BroadcasterLang.NAME, BroadcasterLang.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Color.NAME, Color.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, DisplayName.NAME, DisplayName.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Emotes.NAME, Emotes.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, EmoteSets.NAME, EmoteSets.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Id.NAME, Id.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Login.NAME, Login.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, MsgId.NAME, MsgId.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, MsgParamCumulativeMonths.NAME, MsgParamCumulativeMonths.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, MsgParamMonths.NAME, MsgParamMonths.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, MsgParamSubPlan.NAME, MsgParamSubPlan.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, MsgParamSubPlanName.NAME, MsgParamSubPlanName.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Mod.NAME, Mod.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, R9k.NAME, R9k.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, RoomId.NAME, RoomId.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Slow.NAME, Slow.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, SubsOnly.NAME, SubsOnly.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Subscriber.NAME, Subscriber.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, SystemMsg.NAME, SystemMsg.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, Turbo.NAME, Turbo.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, User.NAME, User.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, UserId.NAME, UserId.FUNCTION); - client.getMessageTagManager().registerTagCreator(CAPABILITY_TAGS, UserType.NAME, UserType.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Badges.NAME, Badges.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, BanDuration.NAME, BanDuration.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, BanReason.NAME, BanReason.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Bits.NAME, Bits.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, BroadcasterLang.NAME, BroadcasterLang.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Color.NAME, Color.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, DisplayName.NAME, DisplayName.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Emotes.NAME, Emotes.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, EmoteSets.NAME, EmoteSets.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Id.NAME, Id.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Login.NAME, Login.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, MsgId.NAME, MsgId.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, MsgParamCumulativeMonths.NAME, MsgParamCumulativeMonths.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, MsgParamMonths.NAME, MsgParamMonths.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, MsgParamSubPlan.NAME, MsgParamSubPlan.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, MsgParamSubPlanName.NAME, MsgParamSubPlanName.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Mod.NAME, Mod.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, R9k.NAME, R9k.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, RoomId.NAME, RoomId.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Slow.NAME, Slow.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, SubsOnly.NAME, SubsOnly.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Subscriber.NAME, Subscriber.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, SystemMsg.NAME, SystemMsg.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, Turbo.NAME, Turbo.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, User.NAME, User.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, UserId.NAME, UserId.FUNCTION); + client.getMessageTagManager().registerTagCreator(TwitchSupport.CAPABILITY_TAGS, UserType.NAME, UserType.FUNCTION); return client; } diff --git a/src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/Badges.java b/src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/Badges.java index 9ca35bc35..d1ba03a08 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/Badges.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/Badges.java @@ -100,7 +100,7 @@ private KnownNames() { /** * One badge. */ - public class Badge { + public static class Badge { private final String name; private final String version; diff --git a/src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/Emotes.java b/src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/Emotes.java index 561c0dd10..4f3396ad2 100644 --- a/src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/Emotes.java +++ b/src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/Emotes.java @@ -52,7 +52,7 @@ public class Emotes extends MessageTagManager.DefaultMessageTag { /** * One emote. */ - public class Emote { + public static class Emote { private final int id; private final int firstIndex; private final int lastIndex; diff --git a/src/main/java/org/kitteh/irc/client/library/util/CISet.java b/src/main/java/org/kitteh/irc/client/library/util/CISet.java index 9edaad4cf..8d7d5ef7c 100644 --- a/src/main/java/org/kitteh/irc/client/library/util/CISet.java +++ b/src/main/java/org/kitteh/irc/client/library/util/CISet.java @@ -67,7 +67,7 @@ protected final synchronized String toLowerCase(@NonNull String input) { Set set = new HashSet<>(this.map.values()); this.lastCaseMapping = caseMapping; this.map.clear(); - set.forEach(this::add); + this.addAll(set); } return caseMapping.toLowerCase(input); } diff --git a/src/main/java/org/kitteh/irc/client/library/util/CtcpUtil.java b/src/main/java/org/kitteh/irc/client/library/util/CtcpUtil.java index d497f235b..5d03464fe 100644 --- a/src/main/java/org/kitteh/irc/client/library/util/CtcpUtil.java +++ b/src/main/java/org/kitteh/irc/client/library/util/CtcpUtil.java @@ -62,8 +62,8 @@ public final class CtcpUtil { private static final char CTCP_DELIMITER = '\u0001'; private static final char CTCP_MQUOTE = '\u0016'; - private static final Pattern CTCP_ESCAPABLE_CHAR = Pattern.compile("[\n\r\u0000" + CTCP_DELIMITER + CTCP_MQUOTE + "\\\\]"); - private static final Pattern CTCP_ESCAPED_CHAR = Pattern.compile("([" + CTCP_MQUOTE + "\\\\])(.)"); + private static final Pattern CTCP_ESCAPABLE_CHAR = Pattern.compile("[\n\r\u0000" + CtcpUtil.CTCP_DELIMITER + CtcpUtil.CTCP_MQUOTE + "\\\\]"); + private static final Pattern CTCP_ESCAPED_CHAR = Pattern.compile("([" + CtcpUtil.CTCP_MQUOTE + "\\\\])(.)"); private CtcpUtil() { } @@ -75,17 +75,17 @@ private CtcpUtil() { * @return converted message */ public static @NonNull String fromCtcp(@NonNull String message) { - int secondDelimiter = message.indexOf(CTCP_DELIMITER, 1); + int secondDelimiter = message.indexOf(CtcpUtil.CTCP_DELIMITER, 1); final String ctcpContent = message.substring(1, (secondDelimiter == -1) ? message.length() : secondDelimiter); // Strip the delimiters StringBuilder builder = new StringBuilder(ctcpContent.length()); int currentIndex = 0; - Matcher matcher = CTCP_ESCAPED_CHAR.matcher(ctcpContent); + Matcher matcher = CtcpUtil.CTCP_ESCAPED_CHAR.matcher(ctcpContent); while (matcher.find()) { if (matcher.start() > currentIndex) { builder.append(ctcpContent, currentIndex, matcher.start()); } switch (matcher.group(1)) { - case CTCP_MQUOTE + "": + case CtcpUtil.CTCP_MQUOTE + "": switch (matcher.group(2)) { case "n": builder.append('\n'); @@ -102,7 +102,7 @@ private CtcpUtil() { break; case "\\": if ("a".equals(matcher.group(2))) { - builder.append(CTCP_DELIMITER); + builder.append(CtcpUtil.CTCP_DELIMITER); } else { builder.append(matcher.group(2)); // If not one of the above, disregard the \. If \, it's covered here anyway. } @@ -125,7 +125,7 @@ private CtcpUtil() { * @return true if the message is a CTCP message */ public static boolean isCtcp(@NonNull String message) { - return !message.isEmpty() && (message.charAt(0) == CTCP_DELIMITER); + return !message.isEmpty() && (message.charAt(0) == CtcpUtil.CTCP_DELIMITER); } /** @@ -136,27 +136,27 @@ public static boolean isCtcp(@NonNull String message) { */ public static @NonNull String toCtcp(@NonNull String message) { StringBuilder builder = new StringBuilder(message.length()); - builder.append(CTCP_DELIMITER); + builder.append(CtcpUtil.CTCP_DELIMITER); int currentIndex = 0; - Matcher matcher = CTCP_ESCAPABLE_CHAR.matcher(message); + Matcher matcher = CtcpUtil.CTCP_ESCAPABLE_CHAR.matcher(message); while (matcher.find()) { if (matcher.start() > currentIndex) { builder.append(message, currentIndex, matcher.start()); } switch (matcher.group()) { case "\n": - builder.append(CTCP_MQUOTE).append('n'); + builder.append(CtcpUtil.CTCP_MQUOTE).append('n'); break; case "\r": - builder.append(CTCP_MQUOTE).append('r'); + builder.append(CtcpUtil.CTCP_MQUOTE).append('r'); break; case "\u0000": - builder.append(CTCP_MQUOTE).append('0'); + builder.append(CtcpUtil.CTCP_MQUOTE).append('0'); break; - case CTCP_MQUOTE + "": - builder.append(CTCP_MQUOTE).append(CTCP_MQUOTE); + case CtcpUtil.CTCP_MQUOTE + "": + builder.append(CtcpUtil.CTCP_MQUOTE).append(CtcpUtil.CTCP_MQUOTE); break; - case CTCP_DELIMITER + "": + case CtcpUtil.CTCP_DELIMITER + "": builder.append("\\a"); break; case "\\": @@ -171,7 +171,7 @@ public static boolean isCtcp(@NonNull String message) { if (currentIndex < message.length()) { builder.append(message.substring(currentIndex)); } - builder.append(CTCP_DELIMITER); + builder.append(CtcpUtil.CTCP_DELIMITER); return builder.toString(); } } diff --git a/src/main/java/org/kitteh/irc/client/library/util/Format.java b/src/main/java/org/kitteh/irc/client/library/util/Format.java index 07fcf7665..621b22907 100644 --- a/src/main/java/org/kitteh/irc/client/library/util/Format.java +++ b/src/main/java/org/kitteh/irc/client/library/util/Format.java @@ -131,15 +131,15 @@ public enum Format { Format(int color) { this.color = color; this.isColor = true; - this.toString = COLOR_CHAR + ((color < 10) ? "0" : "") + color; + this.toString = Format.COLOR_CHAR + ((color < 10) ? "0" : "") + color; } /** * Character indicating color. */ public static final char COLOR_CHAR = '\u0003'; - private static final Pattern COLOR_REGEX = Pattern.compile(COLOR_CHAR + "[0-9]{1,2}(?:,[0-9]{1,2})?"); - private static final Pattern FORMAT_REGEX = Pattern.compile("[" + BOLD + RESET + REVERSE + UNDERLINE + ']'); + private static final Pattern COLOR_REGEX = Pattern.compile(Format.COLOR_CHAR + "[0-9]{1,2}(?:,[0-9]{1,2})?"); + private static final Pattern FORMAT_REGEX = Pattern.compile("[" + Format.BOLD + Format.RESET + Format.REVERSE + Format.UNDERLINE + ']'); /** * Strips color and formatting from a given input. @@ -150,7 +150,7 @@ public enum Format { * @see #stripFormatting(String) */ public static @NonNull String stripAll(@NonNull String input) { - return stripColor(stripFormatting(input)); + return Format.stripColor(Format.stripFormatting(input)); } /** @@ -161,7 +161,7 @@ public enum Format { */ public static @NonNull String stripColor(@NonNull String input) { Sanity.nullCheck(input, "Input"); - return COLOR_REGEX.matcher(input).replaceAll(""); + return Format.COLOR_REGEX.matcher(input).replaceAll(""); } /** @@ -172,7 +172,7 @@ public enum Format { */ public static @NonNull String stripFormatting(@NonNull String input) { Sanity.nullCheck(input, "Input"); - return FORMAT_REGEX.matcher(input).replaceAll(""); + return Format.FORMAT_REGEX.matcher(input).replaceAll(""); } /** diff --git a/src/main/java/org/kitteh/irc/client/library/util/HostWithPort.java b/src/main/java/org/kitteh/irc/client/library/util/HostWithPort.java index f39690d9d..69dcd6e03 100644 --- a/src/main/java/org/kitteh/irc/client/library/util/HostWithPort.java +++ b/src/main/java/org/kitteh/irc/client/library/util/HostWithPort.java @@ -48,16 +48,16 @@ public class HostWithPort { * @param port port * @return a HostWithPort with the provided information */ - public static @NonNull HostWithPort of(@NonNull String host, @IntRange(from = PORT_MIN, to = PORT_MAX) int port) { + public static @NonNull HostWithPort of(@NonNull String host, @IntRange(from = HostWithPort.PORT_MIN, to = HostWithPort.PORT_MAX) int port) { Sanity.nullCheck(host, "Host"); - Sanity.truthiness((port >= PORT_MIN) && (port <= PORT_MAX), port + " is not acceptable port number"); + Sanity.truthiness((port >= HostWithPort.PORT_MIN) && (port <= HostWithPort.PORT_MAX), port + " is not acceptable port number"); return new HostWithPort(host, port); } private final String host; private final int port; - private HostWithPort(@NonNull String host, @IntRange(from = PORT_MIN, to = PORT_MAX) int port) { + private HostWithPort(@NonNull String host, @IntRange(from = HostWithPort.PORT_MIN, to = HostWithPort.PORT_MAX) int port) { this.host = host; this.port = port; } @@ -96,7 +96,7 @@ public int getPort() { * @param port new port * @return new instance */ - public @NonNull HostWithPort withPort(@IntRange(from = PORT_MIN, to = PORT_MAX) int port) { + public @NonNull HostWithPort withPort(@IntRange(from = HostWithPort.PORT_MIN, to = HostWithPort.PORT_MAX) int port) { return HostWithPort.of(this.host, port); } diff --git a/src/main/java/org/kitteh/irc/client/library/util/StringUtil.java b/src/main/java/org/kitteh/irc/client/library/util/StringUtil.java index 66b929939..d020325b8 100644 --- a/src/main/java/org/kitteh/irc/client/library/util/StringUtil.java +++ b/src/main/java/org/kitteh/irc/client/library/util/StringUtil.java @@ -88,7 +88,7 @@ private StringUtil() { * @throws IllegalArgumentException for null message */ public static @NonNull String makeRainbow(@NonNull String message) { - return StringUtil.makeRainbow(message, DEFAULT_RAINBOW); + return StringUtil.makeRainbow(message, StringUtil.DEFAULT_RAINBOW); } /** diff --git a/src/main/java/org/kitteh/irc/client/library/util/StsUtil.java b/src/main/java/org/kitteh/irc/client/library/util/StsUtil.java index 0c9f33580..18724d3f6 100644 --- a/src/main/java/org/kitteh/irc/client/library/util/StsUtil.java +++ b/src/main/java/org/kitteh/irc/client/library/util/StsUtil.java @@ -53,7 +53,7 @@ private StsUtil() { * @return an STSStorageManager implementer */ public static @NonNull StsStorageManager getDefaultStorageManager() { - return StsUtil.getDefaultStorageManager(Paths.get(System.getProperty("user.home"), DEFAULT_FILENAME)); + return StsUtil.getDefaultStorageManager(Paths.get(System.getProperty("user.home"), StsUtil.DEFAULT_FILENAME)); } /** diff --git a/src/main/java/org/kitteh/irc/client/library/util/Version.java b/src/main/java/org/kitteh/irc/client/library/util/Version.java index 4b92e89a6..218b30447 100644 --- a/src/main/java/org/kitteh/irc/client/library/util/Version.java +++ b/src/main/java/org/kitteh/irc/client/library/util/Version.java @@ -41,7 +41,7 @@ public final class Version { * @return current KICL version or {@link #MISSINGNO} if somehow not set */ public static @NonNull String getVersion() { - return (Version.VERSION.version == null) ? MISSINGNO : Version.VERSION.version; // Semantic satiation! + return (Version.VERSION.version == null) ? Version.MISSINGNO : Version.VERSION.version; // Semantic satiation! } private Version() {