Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Gindler committed Aug 17, 2015
1 parent 74cbd7d commit b30a128
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import io.tracee.contextlogger.api.ToStringBuilder;
import io.tracee.contextlogger.api.TraceeContextStringRepresentationBuilder;
import io.tracee.contextlogger.api.WrappedContextLoggerOutput;
import io.tracee.contextlogger.api.internal.ContextLoggerBuilderAccessable;
import io.tracee.contextlogger.api.internal.ContextLoggerBuilderAccessible;
import io.tracee.contextlogger.impl.ContextLoggerConfiguration;

/**
* Abstract to String Builder class.
*/
public abstract class AbstractToStringBuilder<T extends ToStringBuilder> implements ContextLoggerBuilderAccessable {
public abstract class AbstractToStringBuilder<T extends ToStringBuilder> implements ContextLoggerBuilderAccessible {

private final ContextLoggerConfiguration contextLoggerConfiguration;
private TraceeContextStringRepresentationBuilder traceeContextLogBuilder;
Expand Down
97 changes: 48 additions & 49 deletions core/src/main/java/io/tracee/contextlogger/api/ConfigBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,62 @@

/**
* Interface for manual overrides. (Enabling / Disabling of certain logger context data)
* Used to enable fluent API.
* Created by Tobias Gindler on 28.03.14.
* Used to provide a fluent API for configuring the ToStringBuilder.
*/
public interface ConfigBuilder<T extends ToStringBuilder> {

/**
* Enforces profile for a single createStringRepresentation statement.
*
* @param profile the profile to use
* @return this instance
*/
ConfigBuilder<T> enforceProfile(Profile profile);
/**
* Enforces profile for a single createStringRepresentation statement.
*
* @param profile the profile to use
* @return this instance
*/
ConfigBuilder<T> enforceProfile(Profile profile);

/**
* Manually enables context data output for a single createStringRepresentation statement.
*
* @param contexts The context data to be enabled.
* @return This instance
*/
ConfigBuilder<T> enable(String... contexts);
/**
* Manually enables context data output for a single createStringRepresentation statement.
*
* @param contexts The context data to be enabled.
* @return This instance
*/
ConfigBuilder<T> enable(String... contexts);

/**
* Manually disables context data output for a single createStringRepresentation statement.
*
* @param contexts The context data to be disabled.
* @return This instance
*/
ConfigBuilder<T> disable(String... contexts);
/**
* Manually disables context data output for a single createStringRepresentation statement.
*
* @param contexts The context data to be disabled.
* @return This instance
*/
ConfigBuilder<T> disable(String... contexts);

/**
* Manually disables context data output for a single createStringRepresentation statement.
*
* @param types The context data to be disabled.
* @return This instance
*/
ConfigBuilder<T> disableTypes(Class... types);
/**
* Manually disables context data output for a single createStringRepresentation statement.
*
* @param types The context data to be disabled.
* @return This instance
*/
ConfigBuilder<T> disableTypes(Class... types);

/**
* Enforces sorting of passed tracee context provider instances. Other instances will be prepended in passed order.
*
* @return This instance
*/
ConfigBuilder<T> enforceOrder();
/**
* Enforces sorting of passed tracee context provider instances. Other instances will be prepended in passed order.
*
* @return This instance
*/
ConfigBuilder<T> enforceOrder();

/**
* Closes configuration.
*
* @return This instance cast as a ContextLoggerBuilder.
*/
T apply();
/**
* Closes configuration.
*
* @return This instance cast as a ContextLoggerBuilder.
*/
T apply();

/**
* Manually defines the OutputWriterConfiguration to use.
*
* @param outputWriterConfiguration the outputWriterConfiguration to use
* @return
*/
ConfigBuilder<T> enforceOutputWriterConfiguration(BasicOutputWriterConfiguration outputWriterConfiguration);
/**
* Manually defines the OutputWriterConfiguration to use.
*
* @param outputWriterConfiguration the outputWriterConfiguration to use
* @return
*/
ConfigBuilder<T> enforceOutputWriterConfiguration(BasicOutputWriterConfiguration outputWriterConfiguration);

}
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
package io.tracee.contextlogger.api;

import java.util.Map;
import java.util.Set;

import io.tracee.contextlogger.contextprovider.api.Profile;
import io.tracee.contextlogger.outputgenerator.writer.OutputWriterConfiguration;

import java.util.Map;
import java.util.Set;

/**
* Annotation to mark class as toJson builder implementations.
* Created by Tobias Gindler, holisticon AG on 20.03.14.
* Annotation to mark class as to string representation builder implementations.
*/
public interface TraceeContextStringRepresentationBuilder {

Set<Class> getWrapperClasses();
Set<Class> getWrapperClasses();

void setWrapperClasses(final Set<Class> wrapperClasses);
void setWrapperClasses(final Set<Class> wrapperClasses);

boolean getEnforceOrder();
boolean getEnforceOrder();

void setEnforceOrder(final boolean keepOrder);
void setEnforceOrder(final boolean keepOrder);

String createStringRepresentation(final Object... instancesToLog);
String createStringRepresentation(final Object... instancesToLog);

void setOutputWriterConfiguration(final OutputWriterConfiguration outputWriterConfiguration);
void setOutputWriterConfiguration(final OutputWriterConfiguration outputWriterConfiguration);

void setManualContextOverrides(final Map<String, Boolean> manualContextOverrides);
void setManualContextOverrides(final Map<String, Boolean> manualContextOverrides);

Map<String, Boolean> getManualContextOverrides();
Map<String, Boolean> getManualContextOverrides();

TraceeContextStringRepresentationBuilder cloneStringRepresentationBuilder();
TraceeContextStringRepresentationBuilder cloneStringRepresentationBuilder();

void setProfile(final Profile profile);
void setProfile(final Profile profile);

Profile getProfile();
Profile getProfile();

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.tracee.contextlogger.api.internal;

import io.tracee.contextlogger.api.ContextLogger;
import io.tracee.contextlogger.api.TraceeContextStringRepresentationBuilder;
import io.tracee.contextlogger.impl.ContextLoggerConfiguration;

/**
* Marks a class that a {@link TraceeContextStringRepresentationBuilder} can be added.
* Created by Tobias Gindler on 19.06.14.
*/
public interface ContextLoggerBuilderAccessible extends ContextLogger {

/**
* Used to apply the string representation builder.
*
* @param stringRepresentationBuilder the string representation builder to be applied
*/
void setStringRepresentationBuilder(final TraceeContextStringRepresentationBuilder stringRepresentationBuilder);

/**
* Gets the context logger configuration.
*/
ContextLoggerConfiguration getContextLoggerConfiguration();

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.tracee.contextlogger.contextprovider.api.WrappedContextData;

/**
* Class to store class to wrapper mapppings.
* Class to store class to wrapper mappings.
*/
public final class TypeToWrapper {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.tracee.contextlogger.api.ConfigBuilder;
import io.tracee.contextlogger.api.ToStringBuilder;
import io.tracee.contextlogger.api.internal.Configuration;
import io.tracee.contextlogger.api.internal.ContextLoggerBuilderAccessable;
import io.tracee.contextlogger.api.internal.ContextLoggerBuilderAccessible;
import io.tracee.contextlogger.contextprovider.api.Profile;
import io.tracee.contextlogger.outputgenerator.TraceeContextStringRepresentationBuilderImpl;
import io.tracee.contextlogger.outputgenerator.writer.BasicOutputWriterConfiguration;
Expand All @@ -19,7 +19,7 @@
*/
public class ConfigBuilderImpl<T extends ToStringBuilder> implements Configuration<T> {

private final ContextLoggerBuilderAccessable contextLogger;
private final ContextLoggerBuilderAccessible contextLogger;
private final ContextLoggerConfiguration contextLoggerConfiguration;

private Profile profile = null;
Expand All @@ -30,10 +30,10 @@ public class ConfigBuilderImpl<T extends ToStringBuilder> implements Configurati

private OutputWriterConfiguration outputWriterConfiguration = BasicOutputWriterConfiguration.JSON_INTENDED;

public ConfigBuilderImpl(ContextLoggerBuilderAccessable traceeContextLoggerBuilderAccessable) {
public ConfigBuilderImpl(ContextLoggerBuilderAccessible traceeContextLoggerBuilderAccessible) {

this.contextLogger = traceeContextLoggerBuilderAccessable;
this.contextLoggerConfiguration = traceeContextLoggerBuilderAccessable.getContextLoggerConfiguration();
this.contextLogger = traceeContextLoggerBuilderAccessible;
this.contextLoggerConfiguration = traceeContextLoggerBuilderAccessible.getContextLoggerConfiguration();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

/**
* A Singleton that holds the static configuration data.
* Created by Tobias Gindler, holisticon AG on 28.03.14.
*/
public class ContextLoggerConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
/**
* Wrapper class for methods and their {@link io.tracee.contextlogger.contextprovider.api.TraceeContextProviderMethod} annotations.
* Used for sorting (by {@link MethodAnnotationPairComparator}) and other tasks.
* <p/>
* Created by Tobias Gindler, holisticon AG on 14.03.14.
*/
public class MethodAnnotationPair {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

/**
* Comparator to sort {@link MethodAnnotationPair} instances.
* Created by Tobias Gindler, holisticon AG on 14.03.14.
*/
public final class MethodAnnotationPairComparator implements Comparator<MethodAnnotationPair> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.tracee.contextlogger.api.ConfigBuilder;
import io.tracee.contextlogger.api.ContextLogger;
import io.tracee.contextlogger.api.internal.Configuration;
import io.tracee.contextlogger.api.internal.ContextLoggerBuilderAccessable;
import io.tracee.contextlogger.api.internal.ContextLoggerBuilderAccessible;
import io.tracee.contextlogger.contextprovider.api.Profile;

/**
Expand All @@ -21,13 +21,13 @@
*/
public class ConfigBuilderImplTest {

ContextLoggerBuilderAccessable contextLogger;
ContextLoggerBuilderAccessible contextLogger;
ConfigBuilder<ContextLogger> configBuilder;

@Before
public void init() {

contextLogger = Mockito.mock(ContextLoggerBuilderAccessable.class);
contextLogger = Mockito.mock(ContextLoggerBuilderAccessible.class);
Mockito.when(contextLogger.getContextLoggerConfiguration()).thenReturn(ContextLoggerConfiguration.getOrCreateContextLoggerConfiguration());

configBuilder = new ConfigBuilderImpl(contextLogger);
Expand Down

0 comments on commit b30a128

Please sign in to comment.