Skip to content
This repository was archived by the owner on Jan 8, 2023. It is now read-only.

Commit dee1de9

Browse files
committed
Delombok and more proper javadoc
1 parent d62fb3a commit dee1de9

File tree

7 files changed

+107
-28
lines changed

7 files changed

+107
-28
lines changed

pom.xml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,31 @@
9898
</execution>
9999
</executions>
100100
</plugin>
101+
<plugin>
102+
<groupId>org.projectlombok</groupId>
103+
<artifactId>lombok-maven-plugin</artifactId>
104+
<version>1.16.20.0</version>
105+
<executions>
106+
<execution>
107+
<id>delombok</id>
108+
<phase>generate-sources</phase>
109+
<goals>
110+
<goal>delombok</goal>
111+
</goals>
112+
</execution>
113+
</executions>
114+
<configuration>
115+
<sourceDirectory>src/main/java</sourceDirectory>
116+
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
117+
<addOutputDirectory>false</addOutputDirectory>
118+
</configuration>
119+
</plugin>
101120
<plugin>
102121
<groupId>org.apache.maven.plugins</groupId>
103122
<artifactId>maven-javadoc-plugin</artifactId>
104123
<version>3.0.0-M1</version>
105124
<configuration>
106-
<show>private</show>
107-
<sourceFileExcludes>
108-
<sourceFileExclude>io/github/spair/byond/dmi/MetaExtractor.java</sourceFileExclude>
109-
<sourceFileExclude>io/github/spair/byond/dmi/StateExtractor.java</sourceFileExclude>
110-
</sourceFileExcludes>
125+
<sourcepath>target/delombok</sourcepath>
111126
</configuration>
112127
<executions>
113128
<execution>

src/main/checkstyle.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
<property name="message" value="Line has trailing spaces."/>
6969
</module>
7070

71+
<module name="SuppressWarningsFilter" />
72+
7173
<!-- Checks for Headers -->
7274
<!-- See http://checkstyle.sf.net/config_header.html -->
7375
<!-- <module name="Header"> -->
@@ -77,6 +79,8 @@
7779

7880
<module name="TreeWalker">
7981

82+
<module name="SuppressWarningsHolder" />
83+
8084
<!-- Checks for Javadoc comments. -->
8185
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
8286
<!-- <module name="JavadocMethod"/> -->

src/main/java/io/github/spair/byond/dmi/Dmi.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313

1414
@Data
1515
@NoArgsConstructor
16-
@SuppressWarnings("WeakerAccess")
1716
public class Dmi {
1817

1918
/**
20-
* The number of states one Dmi file can store. More states than that value won't work properly.
21-
* Default: 512
19+
* <p>The number of states one Dmi file can store. More states than that value won't work properly.
20+
* <p><b>Default:</b> 512
2221
*/
2322
public static final int MAX_STATES = 512;
2423

@@ -49,10 +48,18 @@ public void setStates(@Nonnull final Map<String, DmiState> states) {
4948
checkDuplicates();
5049
}
5150

51+
/**
52+
* Shows if there are states, which have duplicate names in current Dmi.
53+
* @return true if there are duplicates, otherwise false
54+
*/
5255
public boolean isHasDuplicates() {
5356
return !duplicateStatesNames.isEmpty();
5457
}
5558

59+
/**
60+
* Shows if the number of states more than {@link #MAX_STATES}.
61+
* @return true if too many states, otherwise false
62+
*/
5663
public boolean isStateOverflow() {
5764
return states.size() > MAX_STATES;
5865
}

src/main/java/io/github/spair/byond/dmi/DmiComparator.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@
1111
import java.util.function.Function;
1212
import java.util.stream.Collectors;
1313

14+
/**
15+
* Util class to compare two {@link io.github.spair.byond.dmi.Dmi} objects and get result of comparison
16+
* as {@link io.github.spair.byond.dmi.DmiDiff}.
17+
*/
1418
public final class DmiComparator {
1519

20+
/**
21+
* Compares two {@link io.github.spair.byond.dmi.Dmi} objects. One of argument may be null,
22+
* which will be interpreted as if another Dmi created if null is the first parameter or deleted if vice versa.
23+
*
24+
* @param oldDmi old {@link io.github.spair.byond.dmi.Dmi} object or null
25+
* @param newDmi new {@link io.github.spair.byond.dmi.Dmi} object or null
26+
* @return {@link io.github.spair.byond.dmi.DmiDiff} object
27+
*/
1628
@Nonnull
1729
public static DmiDiff compare(@Nullable final Dmi oldDmi, @Nullable final Dmi newDmi) {
1830
DmiDiff dmiDiff = new DmiDiff(getDiffList(oldDmi, newDmi));

src/main/java/io/github/spair/byond/dmi/DmiDiff.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.util.Objects;
1111

1212
@Data
13-
@SuppressWarnings("WeakerAccess")
1413
public class DmiDiff {
1514

1615
@Nullable
@@ -20,11 +19,16 @@ public class DmiDiff {
2019
@Nonnull
2120
private List<DiffEntry> diffEntries;
2221

22+
/**
23+
* Shows that current diff was generated from the same Dmi's.
24+
* @return true, if Dmi's are the same, otherwise false
25+
*/
2326
public boolean isSame() {
2427
return Objects.equals(oldMeta, newMeta) && diffEntries.isEmpty();
2528
}
2629

2730
@Data
31+
@SuppressWarnings("WeakerAccess")
2832
public static class DiffEntry {
2933

3034
@Nonnull

src/main/java/io/github/spair/byond/dmi/DmiSlurper.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313
import java.util.Base64;
1414
import java.util.Map;
1515

16+
/**
17+
* Util class to extract {@link io.github.spair.byond.dmi.Dmi} object from file/base64 string/raw input stream.
18+
*/
1619
public final class DmiSlurper {
1720

21+
/**
22+
* @param dmiFile file to deserialize
23+
* @return {@link io.github.spair.byond.dmi.Dmi} object
24+
*/
1825
@Nonnull
1926
public static Dmi slurpUp(final File dmiFile) {
2027
try (InputStream input = new FileInputStream(dmiFile)) {
@@ -26,6 +33,11 @@ public static Dmi slurpUp(final File dmiFile) {
2633
}
2734
}
2835

36+
/**
37+
* @param dmiName the name of resulted {@link io.github.spair.byond.dmi.Dmi} object
38+
* @param base64content base64 string to deserialize
39+
* @return {@link io.github.spair.byond.dmi.Dmi} object
40+
*/
2941
@Nonnull
3042
public static Dmi slurpUp(final String dmiName, final String base64content) {
3143
try (InputStream input = new ByteArrayInputStream(Base64.getMimeDecoder().decode(base64content))) {
@@ -35,6 +47,11 @@ public static Dmi slurpUp(final String dmiName, final String base64content) {
3547
}
3648
}
3749

50+
/**
51+
* @param dmiName the name of resulted {@link io.github.spair.byond.dmi.Dmi} object
52+
* @param input raw input stream to deserialize
53+
* @return {@link io.github.spair.byond.dmi.Dmi} object
54+
*/
3855
@Nonnull
3956
public static Dmi slurpUp(final String dmiName, final InputStream input) {
4057
try (BufferedInputStream bufferedInput = new BufferedInputStream(input)) {

src/main/java/io/github/spair/byond/dmi/SpriteDir.java

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,65 @@ public enum SpriteDir {
1212
NORTHEAST(5, "NE", 7),
1313
NORTHWEST(9, "NW", 8);
1414

15+
/**
16+
* <p>BYOND representation of dir as int value.
17+
* <ul>
18+
* <li>SOUTH - 2</li>
19+
* <li>NORTH - 1</li>
20+
* <li>EAST - 4</li>
21+
* <li>WEST - 8</li>
22+
* <li>SOUTHEAST - 6</li>
23+
* <li>SOUTHWEST - 10</li>
24+
* <li>NORTHEAST - 5</li>
25+
* <li>NORTHWEST - 9</li>
26+
* </ul>
27+
*/
1528
public final int dirValue;
29+
30+
/**
31+
* <p>Just a shorted string representation of constant values.
32+
* <ul>
33+
* <li>SOUTH - S</li>
34+
* <li>NORTH - N</li>
35+
* <li>EAST - E</li>
36+
* <li>WEST - W</li>
37+
* <li>SOUTHEAST - SE</li>
38+
* <li>SOUTHWEST - SW</li>
39+
* <li>NORTHEAST - NE</li>
40+
* <li>NORTHWEST - NW</li>
41+
* </ul>
42+
*/
1643
public final String shortName;
1744

45+
// Used to sort dirs in BYOND like order.
1846
final int compareWeight;
1947

20-
// During DMI slurping all dirs are passed in `for(i = 0; i <= n; i++)` cycle.
21-
// Those constants are determine the order in which dirs are placed.
22-
private static final int SOUTH_DIR_COUNT = 1;
23-
private static final int NORTH_DIR_COUNT = 2;
24-
private static final int EAST_DIR_COUNT = 3;
25-
private static final int WEST_DIR_COUNT = 4;
26-
private static final int SOUTHEAST_DIR_COUNT = 5;
27-
private static final int SOUTHWEST_DIR_COUNT = 6;
28-
private static final int NORTHEAST_DIR_COUNT = 7;
29-
private static final int NORTHWEST_DIR_COUNT = 8;
30-
3148
SpriteDir(final int dirValue, final String shortName, final int compareWeight) {
3249
this.dirValue = dirValue;
3350
this.shortName = shortName;
3451
this.compareWeight = compareWeight;
3552
}
3653

54+
// During DMI slurping all dirs are passed in `for(i = 0; i <= n; i++)` cycle.
55+
// This method determines the order in which dirs are placed in `.dmi` file.
56+
@SuppressWarnings("checkstyle:MagicNumber")
3757
static SpriteDir valueOf(final int dirCount) {
3858
switch (dirCount) {
39-
case SOUTH_DIR_COUNT:
59+
case 1:
4060
return SOUTH;
41-
case NORTH_DIR_COUNT:
61+
case 2:
4262
return NORTH;
43-
case EAST_DIR_COUNT:
63+
case 3:
4464
return EAST;
45-
case WEST_DIR_COUNT:
65+
case 4:
4666
return WEST;
47-
case SOUTHEAST_DIR_COUNT:
67+
case 5:
4868
return SOUTHEAST;
49-
case SOUTHWEST_DIR_COUNT:
69+
case 6:
5070
return SOUTHWEST;
51-
case NORTHEAST_DIR_COUNT:
71+
case 7:
5272
return NORTHEAST;
53-
case NORTHWEST_DIR_COUNT:
73+
case 8:
5474
return NORTHWEST;
5575
default:
5676
return SOUTH;

0 commit comments

Comments
 (0)