Skip to content

Commit 835ed73

Browse files
gabizouDeamon5550
authored andcommitted
Fix a few of the checkstyle issues in the data package.
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
1 parent 3f9109b commit 835ed73

File tree

51 files changed

+209
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+209
-174
lines changed

src/main/java/org/spongepowered/api/data/DataManager.java

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,30 @@ public interface DataManager {
6060
*/
6161
<T extends DataSerializable> void registerBuilder(Class<T> clazz, DataBuilder<T> builder);
6262

63+
/**
64+
* Registers a {@link DataContentUpdater} for the desired
65+
* {@link DataSerializable} such that any versioned data may be updated to
66+
* newer versions for the most up to date {@link DataBuilder}.
67+
*
68+
* @param clazz The data serializable class
69+
* @param updater The updater
70+
* @param <T> The type of DataSerializable
71+
*/
6372
<T extends DataSerializable> void registerContentUpdater(Class<T> clazz, DataContentUpdater updater);
6473

74+
/**
75+
* Gets a wrapped fake {@link DataContentUpdater} that may wrap several
76+
* {@link DataContentUpdater}s to translate versioned data from the desired
77+
* {@code fromVersion} to the {@code toVersion}. If the version jump is too
78+
* great or a {@link DataContentUpdater} has not been registered to cover
79+
* the complete jump, {@link Optional#empty()} may be returned.
80+
*
81+
* @param clazz The data serializable class
82+
* @param fromVersion The version converting from
83+
* @param toVersion The version converting to
84+
* @param <T> The type of data serializable
85+
* @return The content updater, if available
86+
*/
6587
<T extends DataSerializable> Optional<DataContentUpdater> getWrappedContentUpdater(Class<T> clazz, int fromVersion, int toVersion);
6688

6789
/**
@@ -76,7 +98,7 @@ public interface DataManager {
7698
* @param <T> The type of data serializable
7799
* @return The builder, if available
78100
*/
79-
<T extends DataSerializable> Optional<DataBuilder<T>> getBuilder(Class<T> clazz);
101+
<T extends DataSerializable> Optional<DataBuilder<T>> getBuilder(Class<T> clazz);
80102

81103
/**
82104
* Attempts to deserialize an instance of the {@link DataSerializable} from
@@ -104,20 +126,6 @@ public interface DataManager {
104126
*/
105127
<T extends ImmutableDataHolder<T>, B extends ImmutableDataBuilder<T, B>> void register(Class<T> holderClass, B builder);
106128

107-
/**
108-
* Attempts to retrieve the builder for the given
109-
* {@link ImmutableDataHolder}.
110-
*
111-
* <p>If the {@link ImmutableDataHolder} was not registered, multiple
112-
* systems could fail to retrieve specific data.</p>
113-
*
114-
* @param holderClass The immutable data holder class
115-
* @param <T> The type of immutable data holder
116-
* @param <B> The type of immutable data builder
117-
* @return The builder, if available
118-
*/
119-
<T extends ImmutableDataHolder<T>, B extends ImmutableDataBuilder<T, B>> Optional<B> getImmutableBuilder(Class<T> holderClass);
120-
121129
/**
122130
* Registers the given {@link DataManipulator} class with it's associated
123131
* {@link DataManipulatorBuilder}. The builder can be used to create new
@@ -126,13 +134,28 @@ public interface DataManager {
126134
* to multiple {@link DataHolder}s.
127135
*
128136
* @param manipulatorClass The class of the data manipulator
129-
* @param immutableManipulatorClass The class of the immutable datamanipulator
137+
* @param immutableManipulatorClass The class of the immutable
138+
* datamanipulator
130139
* @param builder The builder instance of the data manipulator
131140
* @param <T> The type of data manipulator
132141
* @param <I> The type of immutable datamanipulator
133142
*/
134143
<T extends DataManipulator<T, I>, I extends ImmutableDataManipulator<I, T>> void register(Class<? extends T> manipulatorClass,
135-
Class<? extends I> immutableManipulatorClass, DataManipulatorBuilder<T, I> builder);
144+
Class<? extends I> immutableManipulatorClass, DataManipulatorBuilder<T, I> builder);
145+
146+
/**
147+
* Attempts to retrieve the builder for the given
148+
* {@link ImmutableDataHolder}.
149+
*
150+
* <p>If the {@link ImmutableDataHolder} was not registered, multiple
151+
* systems could fail to retrieve specific data.</p>
152+
*
153+
* @param holderClass The immutable data holder class
154+
* @param <T> The type of immutable data holder
155+
* @param <B> The type of immutable data builder
156+
* @return The builder, if available
157+
*/
158+
<T extends ImmutableDataHolder<T>, B extends ImmutableDataBuilder<T, B>> Optional<B> getImmutableBuilder(Class<T> holderClass);
136159

137160
/**
138161
* Attempts to retrieve the builder for the given {@link DataManipulator}.
@@ -146,7 +169,7 @@ <T extends DataManipulator<T, I>, I extends ImmutableDataManipulator<I, T>> void
146169
* @return The builder, if available
147170
*/
148171
<T extends DataManipulator<T, I>, I extends ImmutableDataManipulator<I, T>>
149-
Optional<DataManipulatorBuilder<T, I>> getManipulatorBuilder(Class<T> manipulatorClass);
172+
Optional<DataManipulatorBuilder<T, I>> getManipulatorBuilder(Class<T> manipulatorClass);
150173

151174
/**
152175
* Attempts to retrieve the builder for the given
@@ -161,6 +184,6 @@ <T extends DataManipulator<T, I>, I extends ImmutableDataManipulator<I, T>> void
161184
* @return The DataManipulatorBuilder, if available
162185
*/
163186
<T extends DataManipulator<T, I>, I extends ImmutableDataManipulator<I, T>>
164-
Optional<DataManipulatorBuilder<T, I>> getImmutableManipulatorBuilder(Class<I> immutableManipulatorClass);
187+
Optional<DataManipulatorBuilder<T, I>> getImmutableManipulatorBuilder(Class<I> immutableManipulatorClass);
165188

166189
}

src/main/java/org/spongepowered/api/data/DataQuery.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public final class DataQuery {
5454
* @param separator The separator
5555
* @param path The path
5656
*/
57-
public DataQuery(char separator, String path) {
57+
private DataQuery(char separator, String path) {
5858
this(path.split(Pattern.quote(String.valueOf(separator))));
5959
}
6060

@@ -63,7 +63,7 @@ public DataQuery(char separator, String path) {
6363
*
6464
* @param parts The parts
6565
*/
66-
public DataQuery(String... parts) {
66+
private DataQuery(String... parts) {
6767
this.parts = ImmutableList.copyOf(parts);
6868
}
6969

@@ -72,7 +72,7 @@ public DataQuery(String... parts) {
7272
*
7373
* @param parts The parts
7474
*/
75-
public DataQuery(List<String> parts) {
75+
private DataQuery(List<String> parts) {
7676
this.parts = ImmutableList.copyOf(parts);
7777
}
7878

src/main/java/org/spongepowered/api/data/MemoryDataView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
import org.spongepowered.api.Sponge;
4040
import org.spongepowered.api.data.key.Key;
4141
import org.spongepowered.api.data.value.BaseValue;
42-
import org.spongepowered.api.util.persistence.DataBuilder;
4342
import org.spongepowered.api.util.Coerce;
43+
import org.spongepowered.api.util.persistence.DataBuilder;
4444

4545
import java.util.ArrayList;
4646
import java.util.Arrays;

src/main/java/org/spongepowered/api/data/key/KeyFactory.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ private KeyFactory() {}
6262
* @param <V> The inferred return type
6363
* @return The generated key
6464
*/
65-
public static <E, T extends BaseValue, V extends BaseValue<E>> Key<V> makeSingleKey(final Class<E> elementClass, final Class<T> valueClass, final DataQuery query) {
65+
public static <E, T extends BaseValue, V extends BaseValue<E>> Key<V> makeSingleKey(final Class<E> elementClass, final Class<T> valueClass,
66+
final DataQuery query) {
6667
return new Key<V>() {
6768
@SuppressWarnings("rawtypes")
6869
@Override
@@ -82,7 +83,7 @@ public int hashCode() {
8283

8384
@Override
8485
public String toString() {
85-
return "Key{Value:" + valueClass.getName() + "<" + elementClass + ">, Query: " + query.toString() + "}";
86+
return "Key{Value:" + valueClass.getSimpleName() + "<" + elementClass.getSimpleName() + ">, Query: " + query.toString() + "}";
8687
}
8788
};
8889
}
@@ -116,7 +117,7 @@ public int hashCode() {
116117

117118
@Override
118119
public String toString() {
119-
return "Key{Value:" + "ListValue<" + elementClass + ">, Query: " + query.toString() + "}";
120+
return "Key{Value:" + "ListValue<" + elementClass.getSimpleName() + ">, Query: " + query.toString() + "}";
120121
}
121122
};
122123
}
@@ -150,7 +151,7 @@ public int hashCode() {
150151

151152
@Override
152153
public String toString() {
153-
return "Key{Value:" + "SetValue<" + elementClass + ">, Query: " + query.toString() + "}";
154+
return "Key{Value:" + "SetValue<" + elementClass.getSimpleName() + ">, Query: " + query.toString() + "}";
154155
}
155156
};
156157
}
@@ -187,7 +188,8 @@ public int hashCode() {
187188

188189
@Override
189190
public String toString() {
190-
return "Key{Value:" + "MapValue<" + keyClass + "," + valueclass + ">, Query: " + query.toString() + "}";
191+
return "Key{Value:" + "MapValue<" + keyClass.getSimpleName() + "," + valueclass.getSimpleName() + ">, Query: " + query.toString()
192+
+ "}";
191193
}
192194
};
193195
}

src/main/java/org/spongepowered/api/data/key/Keys.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
import org.spongepowered.api.data.type.WallType;
119119
import org.spongepowered.api.data.type.WireAttachmentType;
120120
import org.spongepowered.api.data.value.immutable.ImmutableBoundedValue;
121-
import org.spongepowered.api.data.value.immutable.ImmutableListValue;
122121
import org.spongepowered.api.data.value.mutable.ListValue;
123122
import org.spongepowered.api.data.value.mutable.MapValue;
124123
import org.spongepowered.api.data.value.mutable.MutableBoundedValue;
@@ -129,7 +128,6 @@
129128
import org.spongepowered.api.data.value.mutable.WeightedCollectionValue;
130129
import org.spongepowered.api.effect.potion.PotionEffect;
131130
import org.spongepowered.api.effect.potion.PotionEffectType;
132-
import org.spongepowered.api.entity.Entity;
133131
import org.spongepowered.api.entity.EntitySnapshot;
134132
import org.spongepowered.api.entity.EntityType;
135133
import org.spongepowered.api.entity.living.Living;
@@ -153,7 +151,6 @@
153151
import org.spongepowered.api.world.Location;
154152
import org.spongepowered.api.world.World;
155153

156-
import java.lang.ref.WeakReference;
157154
import java.time.Instant;
158155
import java.util.UUID;
159156

@@ -488,47 +485,47 @@ public final class Keys {
488485

489486
/**
490487
* Represents the {@link Key} for representing the "enchantments hidden"
491-
* state of a {@link ItemStack}
488+
* state of a {@link ItemStack}.
492489
*
493490
* @see HideData#hideEnchantments()
494491
*/
495492
public static final Key<Value<Boolean>> HIDE_ENCHANTMENTS = null;
496493

497494
/**
498495
* Represents the {@link Key} for representing the "attributes hidden"
499-
* state of a {@link ItemStack}
496+
* state of a {@link ItemStack}.
500497
*
501498
* @see HideData#hideAttributes()
502499
*/
503500
public static final Key<Value<Boolean>> HIDE_ATTRIBUTES = null;
504501

505502
/**
506503
* Represents the {@link Key} for representing the "unbreakable hidden"
507-
* state of a {@link ItemStack}
504+
* state of a {@link ItemStack}.
508505
*
509506
* @see HideData#hideUnbreakable()
510507
*/
511508
public static final Key<Value<Boolean>> HIDE_UNBREAKABLE = null;
512509

513510
/**
514511
* Represents the {@link Key} for representing the "can destroy hidden"
515-
* state of a {@link ItemStack}
512+
* state of a {@link ItemStack}.
516513
*
517514
* @see HideData#hideCanDestroy()
518515
*/
519516
public static final Key<Value<Boolean>> HIDE_CAN_DESTROY = null;
520517

521518
/**
522519
* Represents the {@link Key} for representing the "can place hidden"
523-
* state of a {@link ItemStack}
520+
* state of a {@link ItemStack}.
524521
*
525522
* @see HideData#hideCanPlace()
526523
*/
527524
public static final Key<Value<Boolean>> HIDE_CAN_PLACE = null;
528525

529526
/**
530527
* Represents the {@link Key} for representing the "miscellaneous hidden"
531-
* state of a {@link ItemStack}
528+
* state of a {@link ItemStack}.
532529
*
533530
* @see HideData#hideMiscellaneous()
534531
*/

src/main/java/org/spongepowered/api/data/manipulator/DataManipulatorBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
package org.spongepowered.api.data.manipulator;
2626

2727
import org.spongepowered.api.data.DataHolder;
28-
import org.spongepowered.api.util.persistence.DataBuilder;
2928
import org.spongepowered.api.data.DataManager;
29+
import org.spongepowered.api.util.persistence.DataBuilder;
3030

3131
import java.util.Optional;
3232

src/main/java/org/spongepowered/api/data/manipulator/catalog/CatalogEntityData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
import org.spongepowered.api.data.type.OcelotType;
100100
import org.spongepowered.api.data.type.RabbitType;
101101
import org.spongepowered.api.data.type.SkeletonType;
102+
import org.spongepowered.api.effect.potion.PotionEffect;
102103
import org.spongepowered.api.entity.EnderCrystal;
103104
import org.spongepowered.api.entity.Entity;
104105
import org.spongepowered.api.entity.ExperienceOrb;
@@ -144,7 +145,6 @@
144145
import org.spongepowered.api.item.FireworkEffect;
145146
import org.spongepowered.api.item.inventory.ItemStack;
146147
import org.spongepowered.api.item.merchant.TradeOffer;
147-
import org.spongepowered.api.effect.potion.PotionEffect;
148148
import org.spongepowered.api.statistic.Statistic;
149149
import org.spongepowered.api.statistic.achievement.Achievement;
150150
import org.spongepowered.api.world.weather.Weather;

src/main/java/org/spongepowered/api/data/manipulator/catalog/CatalogItemData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@
5555
import org.spongepowered.api.data.type.DyeColor;
5656
import org.spongepowered.api.data.type.Fish;
5757
import org.spongepowered.api.data.type.GoldenApple;
58+
import org.spongepowered.api.effect.potion.PotionEffect;
5859
import org.spongepowered.api.entity.EntityType;
5960
import org.spongepowered.api.item.Enchantment;
6061
import org.spongepowered.api.item.FireworkEffect;
6162
import org.spongepowered.api.item.ItemTypes;
6263
import org.spongepowered.api.item.inventory.Inventory;
6364
import org.spongepowered.api.item.inventory.ItemStack;
64-
import org.spongepowered.api.effect.potion.PotionEffect;
6565
import org.spongepowered.api.text.Text;
6666
import org.spongepowered.api.util.Color;
6767

src/main/java/org/spongepowered/api/data/manipulator/catalog/CatalogTileEntityData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
package org.spongepowered.api.data.manipulator.catalog;
2626

27-
import org.spongepowered.api.profile.GameProfile;
2827
import org.spongepowered.api.block.tileentity.Banner;
2928
import org.spongepowered.api.block.tileentity.CommandBlock;
3029
import org.spongepowered.api.block.tileentity.Comparator;
@@ -57,6 +56,7 @@
5756
import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData;
5857
import org.spongepowered.api.data.meta.PatternLayer;
5958
import org.spongepowered.api.item.inventory.ItemStack;
59+
import org.spongepowered.api.profile.GameProfile;
6060

6161
/**
6262
* An enumeration of known vanilla {@link DataManipulator}s associated with

src/main/java/org/spongepowered/api/data/manipulator/immutable/ImmutableMobSpawnerData.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public interface ImmutableMobSpawnerData extends ImmutableDataManipulator<Immuta
102102
* {@link Player} is NOT within the provided range, no attempts to spawn an
103103
* {@link Entity} is made.
104104
*
105-
* @return The immutable value of the required player range to spawn entities
105+
* @return The immutable value of the required player range to spawn
106+
* entities
106107
*/
107108
ImmutableBoundedValue<Short> requiredPlayerRange();
108109

@@ -126,21 +127,21 @@ public interface ImmutableMobSpawnerData extends ImmutableDataManipulator<Immuta
126127
ImmutableNextEntityToSpawnValue nextEntityToSpawn();
127128

128129
/**
129-
* Gets the {@link ImmutableWeightedEntityCollectionValue} of all possible
130+
* Gets the {@link ImmutableWeightedCollectionValue} of all possible
130131
* {@link Entity} instances that can be spawned by the spawner. As they
131-
* are all {@link WeightedSerializableObject} instances, their weight is defined as
132-
* a {@link Random} to determine the next {@link Entity} that will be
133-
* spawned, unless overriden by {@link #nextEntityToSpawn()}.
132+
* are all {@link WeightedSerializableObject} instances, their weight is
133+
* defined as a {@link Random} to determine the next {@link Entity} that
134+
* will be spawned, unless overriden by {@link #nextEntityToSpawn()}.
134135
*
135136
* @return The immutable weighted entity collection value of entities
136137
*/
137138
ImmutableWeightedCollectionValue<EntitySnapshot> possibleEntitiesToSpawn();
138139

139140
/**
140141
* Represents a custom {@link Value} dealing with the next
141-
* {@link WeightedSerializableObject} such that the next {@link Entity} to spawn may
142-
* be pulled from the owning {@link #possibleEntitiesToSpawn()} with a
143-
* default {@link Random}, or it may be custom defined on a case by
142+
* {@link WeightedSerializableObject} such that the next {@link Entity} to
143+
* spawn may be pulled from the owning {@link #possibleEntitiesToSpawn()}
144+
* with a default {@link Random}, or it may be custom defined on a case by
144145
* case basis.
145146
*/
146147
interface ImmutableNextEntityToSpawnValue extends ImmutableValue<WeightedSerializableObject<EntitySnapshot>> {
@@ -161,7 +162,8 @@ interface ImmutableNextEntityToSpawnValue extends ImmutableValue<WeightedSeriali
161162
ImmutableNextEntityToSpawnValue with(WeightedSerializableObject<EntitySnapshot> value);
162163

163164
@Override
164-
ImmutableNextEntityToSpawnValue transform(Function<WeightedSerializableObject<EntitySnapshot>, WeightedSerializableObject<EntitySnapshot>> function);
165+
ImmutableNextEntityToSpawnValue transform(Function<WeightedSerializableObject<EntitySnapshot>,
166+
WeightedSerializableObject<EntitySnapshot>> function);
165167

166168
@Override
167169
MobSpawnerData.NextEntityToSpawnValue asMutable();

0 commit comments

Comments
 (0)