Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use static inner classes #4002

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ private Set<Connection> copyConnections(Set<Connection> connections) {
return result;
}

class OutputRef {
static class OutputRef {

private final String moduleId;
private final String outputName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void testMultiServiceAnnotationActions() {
}

@ActionScope(name = "binding.test")
private class TestActionProvider implements AnnotatedActions {
private static class TestActionProvider implements AnnotatedActions {

@RuleAction(label = ACTION_LABEL, description = ACTION_DESCRIPTION, visibility = Visibility.HIDDEN, tags = {
"tag1", "tag2" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void testMultiServiceAnnotationActions() {
}

@ThingActionsScope(name = "test")
private class TestThingActionProvider implements ThingActions {
private static class TestThingActionProvider implements ThingActions {

private @Nullable ThingHandler handler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void testGetBeanFieldFromList() {
ReferenceResolver.splitReferenceToTokens("[2].value")));
}

public class B1<T> {
public static class B1<T> {
@SuppressWarnings("unused")
private final T value;

Expand All @@ -259,7 +259,7 @@ public B1(T value) {
}
}

public class B2<T> {
public static class B2<T> {
public T value;

public B2(T value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class XmlDocumentReaderTest {

private static final String OHC_PACKAGE_PREFIX = "org.openhab.core.";

private class ConfigDescriptionReader extends XmlDocumentReader<ConfigDescription> {
private static class ConfigDescriptionReader extends XmlDocumentReader<ConfigDescription> {
@Override
protected void registerConverters(XStream xstream) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private <T> Set<T> setDifference(Set<T> set1, Set<T> set2) {
/**
* Delta between two subsequent scan results.
*/
class Delta<T> {
static class Delta<T> {

private final Set<T> added;
private final Set<T> removed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ protected DiscoveryResult getLocalizedDiscoveryResult(final DiscoveryResult disc
/**
* Utility class to parse the key with parameters into the key and optional arguments.
*/
private final class ParsedKey {
private static final class ParsedKey {

private static final int LIMIT = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ private ParseLineResult parseLine(final String filePath, final String line) {
* Represents a result of parseLine().
*/
@NonNullByDefault
private class ParseLineResult {
private static class ParseLineResult {
public @Nullable String pid;
public @Nullable String property;
public @Nullable Object value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class LogHandler implements RESTResource {
/**
* Container for a log message
*/
public class LogMessage {
public static class LogMessage {
public long timestamp;
public @Nullable String severity;
public @Nullable URL url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ private void configureSitemapProviderMock() {
when(sitemapProviderMock.getSitemap(SITEMAP_MODEL_NAME)).thenReturn(defaultSitemapMock);
}

private class TestItem extends GenericItem {
private static class TestItem extends GenericItem {

public TestItem(String name) {
super("Number", name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void shouldCreateSuccessResponseWithLargeStreamEntity() throws IOExceptio
}

@SuppressWarnings("unused")
private final class LargeEntity {
private static final class LargeEntity {

private List<BigDecimal> randoms = getRandoms();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private String inputStreamToString(InputStream in) throws IOException {
}

@SuppressWarnings("unused")
private class DummyObject {
private static class DummyObject {
private final String key;
private final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public enum MqttVersion {
* The callback will interact with the {@link AbstractReconnectStrategy} as well as inform registered
* {@link MqttConnectionObserver}s.
*/
public class ConnectionCallback implements MqttClientConnectedListener, MqttClientDisconnectedListener {
public static class ConnectionCallback implements MqttClientConnectedListener, MqttClientDisconnectedListener {
private final MqttBrokerConnection connection;
private final Runnable cancelTimeoutFuture;
private CompletableFuture<Boolean> future = new CompletableFuture<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public void updated(Item oldItem, Item item) {
processItem(item);
}

private class SemanticTagRegistryChangeListener implements RegistryChangeListener<SemanticTag> {
private static class SemanticTagRegistryChangeListener implements RegistryChangeListener<SemanticTag> {

private SemanticsMetadataProvider provider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private String getTranslationForClass(String i18nConstant, Locale locale, Class<
/**
* Utility class to parse the thing status description into the text reference and optional arguments.
*/
private final class ParsedDescription {
private static final class ParsedDescription {

private static final int LIMIT = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class StateChannelTypeBuilderImpl extends AbstractChannelTypeBuilder<StateChannelTypeBuilder>
implements StateChannelTypeBuilder {

private class StateChannelTypeImpl extends ChannelType {
private static class StateChannelTypeImpl extends ChannelType {
private StateChannelTypeImpl(ChannelTypeUID uid, boolean advanced, String itemType, String label,
@Nullable String description, @Nullable String category, @Nullable Set<String> tags,
@Nullable StateDescription state, @Nullable CommandDescription commandDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class TriggerChannelTypeBuilderImpl extends AbstractChannelTypeBuilder<TriggerChannelTypeBuilder>
implements TriggerChannelTypeBuilder {

private class TriggerChannelTypeImpl extends ChannelType {
private static class TriggerChannelTypeImpl extends ChannelType {
TriggerChannelTypeImpl(ChannelTypeUID uid, boolean advanced, String label, @Nullable String description,
@Nullable String category, @Nullable Set<String> tags, @Nullable EventDescription event,
@Nullable URI configDescriptionURI) throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private void assertThatUpdateResultEventIsValid(Event event, @Nullable String ex
assertThat(fpiEvent.getFirmwareUpdateResultInfo().getResult(), is(expectedResult));
}

class DummyFirmwareHandler implements FirmwareUpdateHandler {
static class DummyFirmwareHandler implements FirmwareUpdateHandler {

@Override
public Thing getThing() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ protected List<String> getFilenames(String[] validExtensions) {
return Arrays.stream(path.listFiles(new FileExtensionsFilter(validExtensions))).map(File::getName).toList();
}

protected class FileExtensionsFilter implements FilenameFilter {
protected static class FileExtensionsFilter implements FilenameFilter {

private final String[] validExtensions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@NonNullByDefault
public class StateDescriptionFragmentImpl implements StateDescriptionFragment {

private class StateDescriptionImpl extends StateDescription {
private static class StateDescriptionImpl extends StateDescription {
StateDescriptionImpl(@Nullable BigDecimal minimum, @Nullable BigDecimal maximum, @Nullable BigDecimal step,
@Nullable String pattern, boolean readOnly, @Nullable List<StateOption> options) {
super(minimum, maximum, step, pattern, readOnly, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void testCountFunction() {
assertEquals(new DecimalType("2"), state);
}

private class TestItem extends GenericItem {
private static class TestItem extends GenericItem {

public TestItem(String name, State state) {
super("Test", name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void testEarliestFunction() {
assertTrue(expectedDateTime.isEqual(((DateTimeType) state).getZonedDateTime()));
}

private class TestItem extends GenericItem {
private static class TestItem extends GenericItem {

public TestItem(String name, State state) {
super("Test", name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public java.util.Set<String> getSubscribedEventTypes() {
});
}

class TestItemProvider implements ItemProvider {
static class TestItemProvider implements ItemProvider {
private final Collection<Item> items;

TestItemProvider(Collection<Item> items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ public void assertThatResultWithLaterAddedThingTypeIsAdded() throws ExecutionExc
assertThat(future.get(), is(true));
}

class DummyThingHandlerFactory extends BaseThingHandlerFactory {
static class DummyThingHandlerFactory extends BaseThingHandlerFactory {

public DummyThingHandlerFactory(ComponentContext context) {
super.activate(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void setUp() throws IOException, InvalidSyntaxException {
configDispatcher = new ConfigDispatcher(configAdmin);
}

private class CopyDirectoryRecursive extends SimpleFileVisitor<Path> {
private static class CopyDirectoryRecursive extends SimpleFileVisitor<Path> {
private final Path sourceDir;
private final Path targetDir;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void afterEach() throws Exception {
managedThingProvider.getAll().forEach(t -> managedThingProvider.remove(t.getUID()));
}

class SimpleThingHandlerFactory extends BaseThingHandlerFactory {
static class SimpleThingHandlerFactory extends BaseThingHandlerFactory {
private final Set<ThingHandler> handlers = new HashSet<>();

@Override
Expand Down Expand Up @@ -180,7 +180,7 @@ public void updateConfiguration(Configuration configuration) {
}
}

class SimpleBridgeHandler extends BaseBridgeHandler {
static class SimpleBridgeHandler extends BaseBridgeHandler {

SimpleBridgeHandler(Bridge bridge) {
super(bridge);
Expand Down Expand Up @@ -434,7 +434,7 @@ public Collection<ConfigStatusMessage> getConfigStatus() {
}
}

class YetAnotherThingHandlerFactory extends BaseThingHandlerFactory {
static class YetAnotherThingHandlerFactory extends BaseThingHandlerFactory {

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@NonNullByDefault
public class ThingEventOSGiTest extends JavaOSGiTest {

class ThingEventSubscriber implements EventSubscriber {
static class ThingEventSubscriber implements EventSubscriber {

private @Nullable Event lastReceivedEvent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void setThingStatusInfo(Thing thing, ThingStatusInfo thingStatusInfo) {
((SimpleThingHandler) thing.getHandler()).setThingStatusInfo(thingStatusInfo);
}

private class SimpleThingHandlerFactory extends BaseThingHandlerFactory {
private static class SimpleThingHandlerFactory extends BaseThingHandlerFactory {

@Override
public void activate(ComponentContext componentContext) {
Expand All @@ -294,7 +294,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
}
}

private class SimpleThingHandler extends AbstractThingHandler {
private static class SimpleThingHandler extends AbstractThingHandler {

SimpleThingHandler(Thing thing) {
super(thing);
Expand All @@ -316,7 +316,7 @@ public void setThingStatusInfo(ThingStatusInfo thingStatusInfo) {
}
}

private abstract class AbstractThingHandler extends BaseThingHandler {
private abstract static class AbstractThingHandler extends BaseThingHandler {
public AbstractThingHandler(Thing thing) {
super(thing);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static class MalfunctioningDynamicCommandDescriptionProvider extends BaseDynamic
}
}

class TestThingHandlerFactory extends BaseThingHandlerFactory {
static class TestThingHandlerFactory extends BaseThingHandlerFactory {

@Override
public void activate(final ComponentContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ static class TestMalfunctioningDynamicStateDescriptionProvider extends BaseDynam
}
}

class TestThingHandlerFactory extends BaseThingHandlerFactory {
static class TestThingHandlerFactory extends BaseThingHandlerFactory {

@Override
public void activate(final ComponentContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
@NonNullByDefault
public class CommunicationManagerOSGiTest extends JavaOSGiTest {

private class ItemChannelLinkRegistryAdvanced extends ItemChannelLinkRegistry {
private static class ItemChannelLinkRegistryAdvanced extends ItemChannelLinkRegistry {
public ItemChannelLinkRegistryAdvanced(ThingRegistry thingRegistry, ItemRegistry itemRegistry) {
super(thingRegistry, itemRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private void registerChannelTypes(ChannelTypeUID... channelTypeUIDs) {
registerService(channelTypeRegistry);
}

class TestThingHandlerFactory extends BaseThingHandlerFactory {
static class TestThingHandlerFactory extends BaseThingHandlerFactory {
Logger logger = LoggerFactory.getLogger(TestThingHandlerFactory.class);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class LinkEventOSGiTest extends JavaOSGiTest {
private @NonNullByDefault({}) ItemChannelLinkRegistry itemChannelLinkRegistry;
private @NonNullByDefault({}) ItemChannelLinkEventSubscriber eventSubscriber;

class ItemChannelLinkEventSubscriber implements EventSubscriber {
static class ItemChannelLinkEventSubscriber implements EventSubscriber {

private @Nullable Event lastReceivedEvent;

Expand Down