|
17 | 17 | @SuppressWarnings("WeakerAccess") |
18 | 18 | public class Dmi { |
19 | 19 |
|
20 | | - /** |
21 | | - * The number of states one Dmi file can store. More states than that value won't work properly. |
22 | | - */ |
| 20 | + /** The number of states one Dmi file can store. More states than that value won't work properly. */ |
23 | 21 | public static final int MAX_STATES = 512; |
24 | 22 |
|
25 | 23 | private String name = ""; |
@@ -52,40 +50,43 @@ public void addState(final DmiState dmiState) { |
52 | 50 | } |
53 | 51 |
|
54 | 52 | /** |
55 | | - * Returns state with provided name or null if wasn't found. |
| 53 | + * Returns state with provided name or empty optional if not found. |
56 | 54 | * |
57 | 55 | * @param stateName state name to search |
58 | | - * @return {@link DmiState} instance or null if wasn't found |
| 56 | + * @return {@link DmiState} instance or empty optional if not found |
59 | 57 | */ |
60 | 58 | public Optional<DmiState> getState(final String stateName) { |
61 | 59 | return Optional.ofNullable(states.get(stateName)); |
62 | 60 | } |
63 | 61 |
|
64 | 62 | /** |
65 | | - * Returns the first sprite of state with provided name or null if wasn't found. |
| 63 | + * Returns the first sprite of state with provided name or empty optional if not found. |
66 | 64 | * |
67 | 65 | * @param stateName state name to search |
68 | | - * @return {@link DmiSprite} instance or null if wasn't found |
| 66 | + * @return {@link DmiSprite} instance or empty optional if not found |
69 | 67 | */ |
70 | 68 | public Optional<DmiSprite> getStateSprite(final String stateName) { |
71 | 69 | return getState(stateName).flatMap(DmiState::getSprite); |
72 | 70 | } |
73 | 71 |
|
74 | 72 | /** |
75 | | - * Returns the first sprite of state with provided name and dir or null if wasn't found. |
| 73 | + * Returns sprite of state with provided name and dir or empty optional if not found. |
76 | 74 | * |
77 | 75 | * @param stateName state name to search |
78 | | - * @return {@link DmiSprite} instance or null if wasn't found |
| 76 | + * @param dir dir value to search |
| 77 | + * @return {@link DmiSprite} instance or empty optional if not found |
79 | 78 | */ |
80 | 79 | public Optional<DmiSprite> getStateSprite(final String stateName, final SpriteDir dir) { |
81 | 80 | return getState(stateName).flatMap(s -> s.getSprite(dir)); |
82 | 81 | } |
83 | 82 |
|
84 | 83 | /** |
85 | | - * Returns sprite of state with provided name, dir and frame or null if wasn't found. |
| 84 | + * Returns sprite of state with provided name, dir and frame or empty optional if not found. |
86 | 85 | * |
87 | 86 | * @param stateName state name to search |
88 | | - * @return {@link DmiSprite} instance or null if wasn't found |
| 87 | + * @param dir dir value to search |
| 88 | + * @param frame dir number to search |
| 89 | + * @return {@link DmiSprite} instance or empty optional if not found |
89 | 90 | */ |
90 | 91 | public Optional<DmiSprite> getStateSprite(final String stateName, final SpriteDir dir, final int frame) { |
91 | 92 | return getState(stateName).flatMap(s -> s.getSprite(dir, frame)); |
|
0 commit comments