Skip to content

Commit

Permalink
chore(text-serializer-json): fix style errors and rebase issus
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed May 15, 2023
1 parent d24330f commit 8d02986
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/net/kyori/adventure/util/Services.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private Services() {
* <p>When used in tandem with {@link #serviceWithFallback(Class)}, classes that implement this interface
* will be ignored in favour of classes that do not implement this interface.</p>
*
* @since 4.13.0
* @since 4.14.0
*/
public interface Fallback {
}
Expand All @@ -89,8 +89,8 @@ public interface Fallback {
* @param type the service type
* @param <P> the service type
* @return a service, or {@link Optional#empty()}
* @since 4.13.0
* @see Fallback
* @since 4.14.0
*/
public static <P> @NotNull Optional<P> serviceWithFallback(final @NotNull Class<P> type) {
final ServiceLoader<P> loader = Services0.loader(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* Implementation of the JSON component serializer provider.
*
* @since 4.13.0
* @since 4.14.0
*/
@ApiStatus.Internal
public final class JsonComponentSerializerProviderImpl implements JsonComponentSerializer.Provider, Services.Fallback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* Constants to aid in the creation and testing of JSON component serializers.
*
* @since 4.13.0
* @since 4.14.0
*/
@ApiStatus.Internal
public final class JsonComponentConstants {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
/**
* A JSON component serializer.
*
* @since 4.13.0
* @since 4.14.0
*/
public interface JsonComponentSerializer extends ComponentSerializer<Component, Component, String> {
/**
* Gets a component serializer for JSON serialization and deserialization.
*
* @return a JSON component serializer
* @since 4.13.0
* @since 4.14.0
*/
static @NotNull JsonComponentSerializer json() {
return JsonComponentSerializerImpl.Instances.INSTANCE;
Expand All @@ -48,7 +48,7 @@ public interface JsonComponentSerializer extends ComponentSerializer<Component,
/**
* A {@link JsonComponentSerializer} service provider.
*
* @since 4.13.0
* @since 4.14.0
*/
@ApiStatus.Internal
@PlatformAPI
Expand All @@ -57,7 +57,7 @@ interface Provider {
* Provides a standard {@link JsonComponentSerializer}.
*
* @return a {@link JsonComponentSerializer}
* @since 4.13.0
* @since 4.14.0
*/
@ApiStatus.Internal
@PlatformAPI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ final class JsonComponentSerializerImpl implements JsonComponentSerializer {
private static final Optional<Provider> SERVICE = Services.serviceWithFallback(Provider.class);

@Override
public @NotNull Component deserialize(@NotNull String input) {
public @NotNull Component deserialize(final @NotNull String input) {
throw new UnsupportedOperationException("No JsonComponentSerializer implementation found");
}

@Override
public @NotNull String serialize(@NotNull Component component) {
public @NotNull String serialize(final @NotNull Component component) {
throw new UnsupportedOperationException("No JsonComponentSerializer implementation found");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* A common abstraction providing an API to serializer components with multiple JSON libraries.
*/
package net.kyori.adventure.text.serializer.json;
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void testDeserializeArray() {
)
);
}

// https://github.com/KyoriPowered/adventure/issues/414
@Test
@SuppressWarnings("deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final Component deserialize(final JsonElement json) {
}

final void testStyle(final Style style, final Consumer<? super JsonObject> consumer) {
testObject(Component.text("", style), object -> {
this.testObject(Component.text("", style), object -> {
object.addProperty(JsonComponentConstants.TEXT, "");
consumer.accept(object);
});
Expand All @@ -59,15 +59,15 @@ final void testStyle(final Style style, final Consumer<? super JsonObject> consu
final void testArray(final Component component, final Consumer<? super JsonArray> consumer) {
final JsonArray json = array(consumer);

assertEquals(json, serialize(component));
assertEquals(component, deserialize(json));
assertEquals(json, this.serialize(component));
assertEquals(component, this.deserialize(json));
}

final void testObject(final Component component, final Consumer<? super JsonObject> consumer) {
final JsonObject json = object(consumer);

assertEquals(json, serialize(component));
assertEquals(component, deserialize(json));
assertEquals(json, this.serialize(component));
assertEquals(component, this.deserialize(json));
}

static JsonArray array(final Consumer<? super JsonArray> consumer) {
Expand Down

0 comments on commit 8d02986

Please sign in to comment.