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

Remove package prefix and move logging specific code to logging #339

Merged
merged 1 commit into from
Dec 19, 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
3 changes: 0 additions & 3 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
plugins {
id 'java-library'
id 'java-test-fixtures'
}

dependencies {
// https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path
implementation "com.jayway.jsonpath:json-path:$jsonPathVersion"
implementation 'org.pcollections:pcollections:4.0.1'
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package echopraxia.spi;
package echopraxia.api;

import echopraxia.api.Attribute;
import echopraxia.api.AttributeKey;
import echopraxia.api.Attributes;
import echopraxia.api.Field;
import java.util.Collection;
import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package echopraxia.spi;
package echopraxia.api;

import echopraxia.api.*;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package echopraxia.spi;
package echopraxia.api;

import static echopraxia.spi.PresentationHintAttributes.*;

import echopraxia.api.*;
import java.util.List;
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -44,12 +41,16 @@ public String formatField(@NotNull Field field) {
// if the field has elided, tostringvalue, abbreviateafter, or ascardinal,
// it should apply to the value instead.
Attributes collectValueAttributes(Attributes fa, Attributes valueAttributes) {
if (fa.containsKey(ABBREVIATE_AFTER)) {
return valueAttributes.plus(abbreviateAfter(fa.get(ABBREVIATE_AFTER)));
} else if (fa.containsKey(AS_CARDINAL)) {
return valueAttributes.plus(asCardinal());
} else if (fa.containsKey(TOSTRING_VALUE)) {
return valueAttributes.plus(withToStringValue(fa.get(TOSTRING_VALUE)));
if (fa.containsKey(PresentationHintAttributes.ABBREVIATE_AFTER)) {
return valueAttributes.plus(
PresentationHintAttributes.abbreviateAfter(
fa.get(PresentationHintAttributes.ABBREVIATE_AFTER)));
} else if (fa.containsKey(PresentationHintAttributes.AS_CARDINAL)) {
return valueAttributes.plus(PresentationHintAttributes.asCardinal());
} else if (fa.containsKey(PresentationHintAttributes.TOSTRING_VALUE)) {
return valueAttributes.plus(
PresentationHintAttributes.withToStringValue(
fa.get(PresentationHintAttributes.TOSTRING_VALUE)));
} else {
return valueAttributes;
}
Expand Down Expand Up @@ -181,11 +182,11 @@ private void formatName(
}

private static boolean isToStringFormat(Attributes attributes) {
return attributes.containsKey(TOSTRING_FORMAT);
return attributes.containsKey(PresentationHintAttributes.TOSTRING_FORMAT);
}

private static @Nullable FieldVisitor getToStringFormat(Attributes attributes) {
return attributes.get(TOSTRING_FORMAT);
return attributes.get(PresentationHintAttributes.TOSTRING_FORMAT);
}

private static boolean isDisplayName(@NotNull Attributes attributes) {
Expand All @@ -197,15 +198,15 @@ private static boolean isDisplayName(@NotNull Attributes attributes) {
}

private boolean isAbbreviateAfter(@NotNull Attributes attributes) {
return attributes.containsKey(ABBREVIATE_AFTER);
return attributes.containsKey(PresentationHintAttributes.ABBREVIATE_AFTER);
}

private static @Nullable Integer getAbbreviateAfter(@NotNull Attributes attributes) {
return attributes.get(ABBREVIATE_AFTER);
return attributes.get(PresentationHintAttributes.ABBREVIATE_AFTER);
}

private boolean isAsCardinal(@NotNull Attributes attributes) {
return attributes.containsKey(AS_CARDINAL);
return attributes.containsKey(PresentationHintAttributes.AS_CARDINAL);
}

private boolean isValueOnly(Attributes attributes) {
Expand All @@ -217,10 +218,10 @@ private boolean isElided(Attributes attributes) {
}

private boolean isToStringValue(Attributes attributes) {
return attributes.containsKey(TOSTRING_VALUE);
return attributes.containsKey(PresentationHintAttributes.TOSTRING_VALUE);
}

private String getToStringValue(Attributes attributes) {
return attributes.get(TOSTRING_VALUE);
return attributes.get(PresentationHintAttributes.TOSTRING_VALUE);
}
}
2 changes: 0 additions & 2 deletions api/src/main/java/echopraxia/api/Field.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package echopraxia.api;

import echopraxia.spi.DefaultField;
import echopraxia.spi.PresentationHintAttributes;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.atomic.LongAdder;
Expand Down
3 changes: 1 addition & 2 deletions api/src/main/java/echopraxia/api/FieldBuilder.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package echopraxia.api;

import static echopraxia.spi.FieldConstants.EXCEPTION;
import static echopraxia.api.FieldConstants.EXCEPTION;

import echopraxia.spi.DefaultField;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package echopraxia.spi;
package echopraxia.api;

import java.util.ResourceBundle;

Expand Down
3 changes: 0 additions & 3 deletions api/src/main/java/echopraxia/api/PresentationField.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
package echopraxia.api;

import echopraxia.spi.AttributesAware;
import echopraxia.spi.PresentationHints;

public interface PresentationField
extends Field, PresentationHints<PresentationField>, AttributesAware<PresentationField> {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package echopraxia.api;

import static echopraxia.spi.FieldConstants.EXCEPTION;
import static echopraxia.api.FieldConstants.EXCEPTION;

import echopraxia.spi.DefaultField;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package echopraxia.spi;
package echopraxia.api;

import echopraxia.api.*;
import echopraxia.api.Attribute;
import echopraxia.api.AttributeKey;
import echopraxia.api.Attributes;
import echopraxia.api.FieldVisitor;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package echopraxia.spi;
package echopraxia.api;

import echopraxia.api.Field;
import echopraxia.api.FieldVisitor;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
1 change: 0 additions & 1 deletion api/src/main/java/echopraxia/api/SimpleFieldVisitor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package echopraxia.api;

import echopraxia.spi.DefaultField;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
Expand Down
1 change: 0 additions & 1 deletion api/src/main/java/echopraxia/api/ToStringFormatter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package echopraxia.api;

import echopraxia.spi.DefaultToStringFormatter;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
1 change: 0 additions & 1 deletion api/src/main/java/echopraxia/api/Value.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package echopraxia.api;

import echopraxia.spi.PresentationHintAttributes;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
Expand Down
1 change: 0 additions & 1 deletion api/src/test/java/echopraxia/api/AbbreviateAfterTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.assertj.core.api.Assertions.assertThat;

import echopraxia.spi.PresentationHintAttributes;
import org.junit.jupiter.api.Test;

public class AbbreviateAfterTests {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package echopraxia.spi;
package echopraxia.api;

import static org.assertj.core.api.Assertions.assertThat;

import echopraxia.api.Field;
import echopraxia.api.Value;
import org.junit.jupiter.api.Test;

public class AbbreviationTests {
Expand Down
4 changes: 1 addition & 3 deletions api/src/test/java/echopraxia/api/CardinalTests.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package echopraxia.api;

import static echopraxia.spi.PresentationHintAttributes.asCardinal;
import static echopraxia.api.PresentationHintAttributes.asCardinal;
import static org.assertj.core.api.Assertions.assertThat;

import echopraxia.spi.DefaultField;
import echopraxia.spi.PresentationHintAttributes;
import java.util.UUID;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package echopraxia.spi;
package echopraxia.api;

import static echopraxia.spi.PresentationHintAttributes.withDisplayName;
import static echopraxia.api.PresentationHintAttributes.withDisplayName;
import static org.assertj.core.api.Assertions.assertThat;

import echopraxia.api.*;
import echopraxia.api.Attributes;
import echopraxia.api.Field;
import echopraxia.api.Value;
import org.junit.jupiter.api.Test;

public class DisplayNameTests {
Expand Down
2 changes: 0 additions & 2 deletions api/src/test/java/echopraxia/api/ElidedTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import static echopraxia.api.Value.string;
import static org.assertj.core.api.Assertions.assertThat;

import echopraxia.spi.DefaultField;
import echopraxia.spi.PresentationHintAttributes;
import java.util.List;
import org.junit.jupiter.api.Test;

Expand Down
1 change: 0 additions & 1 deletion api/src/test/java/echopraxia/api/EqualityTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.assertj.core.api.Assertions.assertThat;

import echopraxia.spi.DefaultField;
import java.math.BigDecimal;
import java.util.List;
import org.junit.jupiter.api.Test;
Expand Down
1 change: 0 additions & 1 deletion api/src/test/java/echopraxia/api/ToStringFormatTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static echopraxia.api.Value.string;
import static org.assertj.core.api.Assertions.assertThat;

import echopraxia.spi.DefaultField;
import java.time.Duration;
import java.util.*;
import org.jetbrains.annotations.NotNull;
Expand Down
2 changes: 1 addition & 1 deletion api/src/test/java/echopraxia/api/ToStringValueTests.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package echopraxia.api;

import static echopraxia.spi.PresentationHintAttributes.withToStringValue;
import static echopraxia.api.PresentationHintAttributes.withToStringValue;
import static org.assertj.core.api.Assertions.assertThat;

import java.time.Duration;
Expand Down
1 change: 0 additions & 1 deletion api/src/test/resources/echopraxia.properties

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion async/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
api project(":api")
api project(":logging")

jmhImplementation project(":logstash")

Expand Down
9 changes: 4 additions & 5 deletions async/src/main/java/echopraxia/async/AsyncLogger.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package echopraxia.async;

import echopraxia.api.*;
import echopraxia.api.Condition;
import echopraxia.api.FieldBuilderResult;
import echopraxia.api.LoggerHandle;
import echopraxia.spi.AbstractLoggerSupport;
import echopraxia.spi.CoreLogger;
import echopraxia.logging.api.Condition;
import echopraxia.logging.api.LoggerHandle;
import echopraxia.logging.spi.AbstractLoggerSupport;
import echopraxia.logging.spi.CoreLogger;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Function;
Expand Down
6 changes: 3 additions & 3 deletions async/src/main/java/echopraxia/async/AsyncLoggerFactory.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package echopraxia.async;

import echopraxia.api.PresentationFieldBuilder;
import echopraxia.spi.Caller;
import echopraxia.spi.CoreLogger;
import echopraxia.spi.CoreLoggerFactory;
import echopraxia.logging.spi.Caller;
import echopraxia.logging.spi.CoreLogger;
import echopraxia.logging.spi.CoreLoggerFactory;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
4 changes: 2 additions & 2 deletions async/src/main/java/echopraxia/async/AsyncLoggerMethods.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package echopraxia.async;

import echopraxia.api.Condition;
import echopraxia.api.FieldBuilderResult;
import echopraxia.api.LoggerHandle;
import echopraxia.logging.api.Condition;
import echopraxia.logging.api.LoggerHandle;
import java.util.function.Consumer;
import java.util.function.Function;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package echopraxia.async;

import static echopraxia.api.Level.*;
import static echopraxia.api.FieldConstants.EXCEPTION;
import static echopraxia.api.Value.exception;
import static echopraxia.spi.FieldConstants.EXCEPTION;
import static echopraxia.logging.api.Level.*;

import echopraxia.api.*;
import echopraxia.api.Condition;
import echopraxia.api.Field;
import echopraxia.api.FieldBuilderResult;
import echopraxia.api.LoggerHandle;
import echopraxia.spi.DefaultMethodsSupport;
import echopraxia.logging.api.Condition;
import echopraxia.logging.api.LoggerHandle;
import echopraxia.logging.spi.DefaultMethodsSupport;
import java.util.function.Consumer;
import java.util.function.Function;
import org.jetbrains.annotations.NotNull;
Expand Down
2 changes: 1 addition & 1 deletion diff/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
api project(":api")
api project(":logging")
api project(":jackson")

// https://github.com/flipkart-incubator/zjsonpatch/
Expand Down
12 changes: 6 additions & 6 deletions diff/src/test/java/echopraxia/diff/DiffFieldBuilderTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import echopraxia.Logger;
import echopraxia.LoggerFactory;
import echopraxia.api.*;
import echopraxia.api.DefaultField;
import echopraxia.api.Field;
import echopraxia.api.FieldBuilder;
import echopraxia.api.Value;
import echopraxia.spi.DefaultField;
import echopraxia.logger.Logger;
import echopraxia.logger.LoggerFactory;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -21,8 +20,7 @@ public class DiffFieldBuilderTests {

@Test
public void testLogger() {
Logger<PersonFieldBuilder> logger =
LoggerFactory.getLogger().withFieldBuilder(PersonFieldBuilder.instance);
Logger<PersonFieldBuilder> logger = LoggerFactory.getLogger(PersonFieldBuilder.instance);

Person before = new Person("Eloise", 1);
Person after = before.withName("Will");
Expand All @@ -31,6 +29,8 @@ public void testLogger() {

ListAppender<ILoggingEvent> listAppender = getListAppender();
List<ILoggingEvent> list = listAppender.list;
assertThat(list).isNotEmpty();

ILoggingEvent event = list.get(0);
assertThat(event.getFormattedMessage())
.isEqualTo("personDiff=[{op=replace, path=/name, value=Will}]");
Expand Down
Loading
Loading