Skip to content

Commit

Permalink
corrected class/method visibilities, internal package (#82)
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Jul 5, 2024
1 parent e26403c commit 54d43a6
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.intellij.openapi.util.text.StringUtil;
import com.redhat.devtools.intellij.telemetry.core.configuration.limits.Filter.EventNameFilter;
import com.redhat.devtools.intellij.telemetry.core.configuration.limits.Filter.EventPropertyFilter;
import com.redhat.devtools.intellij.telemetry.core.service.TelemetryService;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
package com.redhat.devtools.intellij.telemetry.core.service;

import com.intellij.openapi.diagnostic.Logger;
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.IService;

public class FeedbackService implements IService {
class FeedbackService implements IService {

private static final Logger LOGGER = Logger.getInstance(FeedbackService.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@

import com.intellij.openapi.components.Service;
import com.intellij.openapi.project.DumbAware;
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.IService;
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration;
import com.redhat.devtools.intellij.telemetry.core.service.segment.SegmentBroker;
import com.redhat.devtools.intellij.telemetry.core.service.segment.SegmentConfiguration;

@Service
public final class FeedbackServiceFactory implements DumbAware {
final class FeedbackServiceFactory implements DumbAware {

public IService create(IMessageBroker broker) {
return new FeedbackService(broker);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.intellij.telemetry.core;
package com.redhat.devtools.intellij.telemetry.core.service;

import com.intellij.openapi.extensions.PluginDescriptor;
import com.redhat.devtools.intellij.telemetry.core.service.Environment;
import com.redhat.devtools.intellij.telemetry.core.service.Event;

public interface IMessageBroker {
void send(Event event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.intellij.telemetry.core;

import com.redhat.devtools.intellij.telemetry.core.service.Event;
package com.redhat.devtools.intellij.telemetry.core.service;

public interface IService {
void send(Event event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package com.redhat.devtools.intellij.telemetry.core.service;

import com.intellij.openapi.diagnostic.Logger;
import com.redhat.devtools.intellij.telemetry.core.IService;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.util.messages.MessageBusConnection;
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.IService;
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration;
import com.redhat.devtools.intellij.telemetry.core.configuration.limits.EventLimits;
import com.redhat.devtools.intellij.telemetry.core.configuration.limits.IEventLimits;
Expand All @@ -39,7 +37,7 @@ public class TelemetryMessageBuilder {
private final IService telemetryFacade;
private final IService feedbackFacade;

@Deprecated
@Deprecated(forRemoval = true)
public TelemetryMessageBuilder(ClassLoader classLoader) {
this(getDescriptor(classLoader));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.messages.MessageBusConnection;
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.IService;
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration;
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration.ConfigurationChangedListener;
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration.Mode;
Expand All @@ -27,7 +25,7 @@

import static com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration.KEY_MODE;

public class TelemetryService implements IService {
class TelemetryService implements IService {

private static final Logger LOGGER = Logger.getInstance(TelemetryService.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

import com.intellij.openapi.components.Service;
import com.intellij.openapi.project.DumbAware;
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration;
import com.redhat.devtools.intellij.telemetry.core.configuration.limits.IEventLimits;

@Service
public final class TelemetryServiceFactory implements DumbAware {
final class TelemetryServiceFactory implements DumbAware {

public TelemetryService create(TelemetryConfiguration configuration, IEventLimits limits, IMessageBroker broker) {
return new TelemetryService(configuration, limits, broker);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
/**
* Traits that the segment broker sends with am identify event.
*/
public class IdentifyTraits {
class IdentifyTraits {
private final String locale;
private final String timezone;
private final String osName;
private final String osVersion;
private final String osDistribution;

public IdentifyTraits(String locale, String timezone, String osName, String osVersion, String osDistribution) {
IdentifyTraits(String locale, String timezone, String osName, String osVersion, String osDistribution) {
this.locale = locale;
this.timezone = timezone;
this.osName = osName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public class IdentifyTraitsPersistence {

protected IdentifyTraitsPersistence() {}

public synchronized IdentifyTraits get() {
synchronized IdentifyTraits get() {
if (identifyTraits == null) {
this.identifyTraits = deserialize(load(FILE));
}
return identifyTraits;
}

public synchronized void set(IdentifyTraits identifyTraits) {
synchronized void set(IdentifyTraits identifyTraits) {
if (Objects.equals(identifyTraits, this.identifyTraits)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
package com.redhat.devtools.intellij.telemetry.core.service.segment;

import com.intellij.openapi.diagnostic.Logger;
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.service.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.service.Application;
import com.redhat.devtools.intellij.telemetry.core.service.Environment;
import com.redhat.devtools.intellij.telemetry.core.service.Event;
Expand Down Expand Up @@ -53,7 +53,7 @@ public class SegmentBroker implements IMessageBroker {
public static final String PROP_APP_NAME = "app_name";
public static final String PROP_APP_VERSION = "app_version";

enum SegmentType {
private enum SegmentType {
IDENTIFY {
public MessageBuilder toMessage(Event event, Map<String, Object> context, SegmentBroker broker) {
return broker.toMessage(IdentifyMessage.builder(), event, context);
Expand All @@ -73,7 +73,7 @@ public MessageBuilder toMessage(Event event, Map<String, Object> context, Segmen

public abstract MessageBuilder toMessage(Event event, Map<String, Object> context, SegmentBroker broker);

public static SegmentType valueOf(Event.Type eventType) {
static SegmentType valueOf(Event.Type eventType) {
switch (eventType) {
case USER:
return IDENTIFY;
Expand All @@ -91,11 +91,12 @@ public static SegmentType valueOf(Event.Type eventType) {
private final Environment environment;
private final Lazy<Analytics> analytics;

public SegmentBroker(boolean isDebug, String userId, Environment environment, ISegmentConfiguration configuration) {
SegmentBroker(boolean isDebug, String userId, Environment environment, ISegmentConfiguration configuration) {
this(isDebug, userId, IdentifyTraitsPersistence.INSTANCE, environment, configuration, new AnalyticsFactory());
}

public SegmentBroker(
/* for testing purposes */
protected SegmentBroker(
boolean isDebug,
String userId,
IdentifyTraitsPersistence identifyTraitsPersistence,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
package com.redhat.devtools.intellij.telemetry.core.service.segment;

import com.intellij.openapi.extensions.PluginDescriptor;
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.service.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.service.Environment;
import com.redhat.devtools.intellij.telemetry.core.service.IDE;
import com.redhat.devtools.intellij.telemetry.core.service.UserId;

import static com.redhat.devtools.intellij.telemetry.core.IMessageBroker.*;
import static com.redhat.devtools.intellij.telemetry.core.service.IMessageBroker.*;

public class SegmentBrokerFactory implements IMessageBrokerFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class SegmentConfiguration extends CompositeConfiguration implements ISeg

private final ClasspathConfiguration consumerClasspathConfiguration;

public SegmentConfiguration(ClassLoader classLoader) {
SegmentConfiguration(ClassLoader classLoader) {
this(new ClasspathConfiguration(Paths.get(SEGMENT_PROPERTIES), classLoader));
}

protected SegmentConfiguration(ClasspathConfiguration consumerClasspathConfiguration) {
SegmentConfiguration(ClasspathConfiguration consumerClasspathConfiguration) {
this.consumerClasspathConfiguration = consumerClasspathConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ApiStatus.Internal
package com.redhat.devtools.intellij.telemetry.core.service.segment;

import org.jetbrains.annotations.ApiStatus;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package com.redhat.devtools.intellij.telemetry.core.service;

import com.intellij.util.messages.MessageBusConnection;
import com.redhat.devtools.intellij.telemetry.core.IService;
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration;
import com.redhat.devtools.intellij.telemetry.core.configuration.limits.EventLimits;
import com.redhat.devtools.intellij.telemetry.core.service.segment.ISegmentConfiguration;
Expand Down Expand Up @@ -79,7 +78,7 @@ void before() {
IdentifyTraitsPersistence.INSTANCE,
environment,
segmentConfiguration,
key -> analytics);
key -> analytics) {};
TelemetryConfiguration telemetryConfiguration = telemetryConfiguration(TelemetryConfiguration.Mode.DEBUG);

TelemetryService telemetryService = new TelemetryService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import com.intellij.ide.AppLifecycleListener;
import com.intellij.util.messages.MessageBusConnection;
import com.redhat.devtools.intellij.telemetry.core.IService;
import com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.FeedbackServiceFacade;
import com.redhat.devtools.intellij.telemetry.core.util.AnonymizeUtils;
import com.redhat.devtools.intellij.telemetry.core.util.TimeUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package com.redhat.devtools.intellij.telemetry.core.service;

import com.intellij.util.messages.MessageBusConnection;
import com.redhat.devtools.intellij.telemetry.core.IService;
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration;
import com.redhat.devtools.intellij.telemetry.core.configuration.limits.IEventLimits;
import com.redhat.devtools.intellij.telemetry.core.service.segment.SegmentBroker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
******************************************************************************/
package com.redhat.devtools.intellij.telemetry.core.service.segment;

import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.service.IMessageBroker;
import com.redhat.devtools.intellij.telemetry.core.service.Environment;
import com.redhat.devtools.intellij.telemetry.core.service.Event;
import com.segment.analytics.Analytics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.intellij.telemetry.core.configuration;
package com.redhat.devtools.intellij.telemetry.core.service.segment;

import com.redhat.devtools.intellij.telemetry.core.service.segment.SegmentConfiguration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down

0 comments on commit 54d43a6

Please sign in to comment.