Skip to content

Commit

Permalink
refactor: use lombok in a few other places
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Jan 25, 2024
1 parent 2e3db2f commit 9fc9e8c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.*;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
Expand Down
23 changes: 0 additions & 23 deletions common/src/main/java/net/william278/husksync/config/Locales.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,6 @@ public static String escapeText(@NotNull String string) {
return value.toString().replace("__", "_\\_");
}

@NotNull
public String truncateText(@NotNull String string, int truncateAfter) {
if (string.isBlank()) {
return string;
}
return string.length() > truncateAfter ? string.substring(0, truncateAfter) + "…" : string;
}

@NotNull
public String getNotApplicable() {
return getRawLocale("not_applicable").orElse("N/A");
}

@NotNull
public String getListJoiner() {
return getRawLocale("list_separator").orElse(", ");
}

@NotNull
public String getNone() {
return getRawLocale("none").orElse("(none)");
}

/**
* Returns the base list options to use for a paginated chat list
*
Expand Down
56 changes: 25 additions & 31 deletions common/src/main/java/net/william278/husksync/data/DataSnapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import de.themoep.minedown.adventure.MineDown;
import lombok.Getter;
import lombok.Setter;
import net.william278.desertwell.util.Version;
import net.william278.husksync.HuskSync;
import net.william278.husksync.adapter.Adaptable;
Expand Down Expand Up @@ -52,6 +54,21 @@ public class DataSnapshot {
@SerializedName("id")
protected UUID id;

/**
* -- GETTER --
* Get whether the snapshot is pinned
*
* @return Whether the snapshot is pinned
*
* -- SETTER --
* Set whether the snapshot is pinned
*
* @param pinned Whether the snapshot is pinned
*
*/
@Setter
@Getter
@SerializedName("pinned")
protected boolean pinned;

Expand All @@ -70,6 +87,14 @@ public class DataSnapshot {
@SerializedName("platform_type")
protected String platformType;

/**
* -- GETTER --
* Get the format version of the snapshot (indicating the version of HuskSync that created it)
*
* @return The format version of the snapshot
*
*/
@Getter
@SerializedName("format_version")
protected int formatVersion;

Expand Down Expand Up @@ -168,26 +193,6 @@ public String getShortId() {
return id.toString().substring(0, 8);
}

/**
* Get whether the snapshot is pinned
*
* @return Whether the snapshot is pinned
* @since 3.0
*/
public boolean isPinned() {
return pinned;
}

/**
* Set whether the snapshot is pinned
*
* @param pinned Whether the snapshot is pinned
* @since 3.0
*/
public void setPinned(boolean pinned) {
this.pinned = pinned;
}

/**
* Get why the snapshot was created
*
Expand Down Expand Up @@ -255,16 +260,6 @@ public String getPlatformType() {
return platformType;
}

/**
* Get the format version of the snapshot (indicating the version of HuskSync that created it)
*
* @return The format version of the snapshot
* @since 3.0
*/
public int getFormatVersion() {
return formatVersion;
}

/**
* A packed {@link DataSnapshot} that has not been deserialized.
*
Expand Down Expand Up @@ -304,7 +299,6 @@ data, getMinecraftVersion(), platformType, formatVersion
);
}

@NotNull
@ApiStatus.Internal
public byte[] asBytes(@NotNull HuskSync plugin) throws DataAdapter.AdaptionException {
return plugin.getDataAdapter().toBytes(this);
Expand Down

0 comments on commit 9fc9e8c

Please sign in to comment.