Skip to content

Commit

Permalink
Organized imports and formatted source.
Browse files Browse the repository at this point in the history
Sorry for the large diff, but let's keep things tidy! This may result in poor formatting for a small amount of code. Such code can use `//` to create a newline that the formatter respects. Also @off and @on can be used to exclude code from being formatted (though rarely needed).

Eclipse formatter settings are (have always been) in Git.
  • Loading branch information
NathanSweet committed Nov 11, 2016
1 parent f0cb0ac commit f3700c4
Show file tree
Hide file tree
Showing 114 changed files with 3,220 additions and 3,356 deletions.
6 changes: 3 additions & 3 deletions src/com/esotericsoftware/kryo/ClassResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

import com.esotericsoftware.kryo.io.Input;
Expand Down Expand Up @@ -52,4 +52,4 @@ public interface ClassResolver {

/** Called by {@link Kryo#reset()}. */
public void reset ();
}
}
6 changes: 3 additions & 3 deletions src/com/esotericsoftware/kryo/DefaultSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

import java.lang.annotation.ElementType;
Expand All @@ -32,4 +32,4 @@
@Target(ElementType.TYPE)
public @interface DefaultSerializer {
Class<? extends Serializer> value();
}
}
66 changes: 33 additions & 33 deletions src/com/esotericsoftware/kryo/Kryo.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@
import java.util.TreeMap;
import java.util.TreeSet;

import com.esotericsoftware.kryo.serializers.ClosureSerializer;
import com.esotericsoftware.kryo.serializers.DefaultSerializers.URLSerializer;
import com.esotericsoftware.kryo.serializers.FieldSerializerConfig;
import com.esotericsoftware.kryo.serializers.OptionalSerializers;
import com.esotericsoftware.kryo.serializers.GenericsResolver;
import com.esotericsoftware.kryo.serializers.TaggedFieldSerializerConfig;
import com.esotericsoftware.kryo.serializers.TimeSerializers;
import org.objenesis.instantiator.ObjectInstantiator;
import org.objenesis.strategy.InstantiatorStrategy;
import org.objenesis.strategy.SerializingInstantiatorStrategy;
Expand All @@ -61,6 +54,7 @@
import com.esotericsoftware.kryo.factories.SerializerFactory;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.serializers.ClosureSerializer;
import com.esotericsoftware.kryo.serializers.CollectionSerializer;
import com.esotericsoftware.kryo.serializers.DefaultArraySerializers.BooleanArraySerializer;
import com.esotericsoftware.kryo.serializers.DefaultArraySerializers.ByteArraySerializer;
Expand Down Expand Up @@ -103,9 +97,15 @@
import com.esotericsoftware.kryo.serializers.DefaultSerializers.TimeZoneSerializer;
import com.esotericsoftware.kryo.serializers.DefaultSerializers.TreeMapSerializer;
import com.esotericsoftware.kryo.serializers.DefaultSerializers.TreeSetSerializer;
import com.esotericsoftware.kryo.serializers.DefaultSerializers.URLSerializer;
import com.esotericsoftware.kryo.serializers.DefaultSerializers.VoidSerializer;
import com.esotericsoftware.kryo.serializers.FieldSerializer;
import com.esotericsoftware.kryo.serializers.FieldSerializerConfig;
import com.esotericsoftware.kryo.serializers.GenericsResolver;
import com.esotericsoftware.kryo.serializers.MapSerializer;
import com.esotericsoftware.kryo.serializers.OptionalSerializers;
import com.esotericsoftware.kryo.serializers.TaggedFieldSerializerConfig;
import com.esotericsoftware.kryo.serializers.TimeSerializers;
import com.esotericsoftware.kryo.util.DefaultClassResolver;
import com.esotericsoftware.kryo.util.DefaultStreamFactory;
import com.esotericsoftware.kryo.util.IdentityMap;
Expand Down Expand Up @@ -241,8 +241,8 @@ public Kryo (ClassResolver classResolver, ReferenceResolver referenceResolver, S
}

// --- Default serializers ---
/** Sets the serializer factory to use when no {@link #addDefaultSerializer(Class, Class) default serializers} match an object's
* type. Default is {@link ReflectionSerializerFactory} with {@link FieldSerializer}.
/** Sets the serializer factory to use when no {@link #addDefaultSerializer(Class, Class) default serializers} match an
* object's type. Default is {@link ReflectionSerializerFactory} with {@link FieldSerializer}.
* @see #newDefaultSerializer(Class) */
public void setDefaultSerializer (SerializerFactory serializer) {
if (serializer == null) throw new IllegalArgumentException("serializer cannot be null.");
Expand Down Expand Up @@ -399,8 +399,8 @@ protected Serializer newDefaultSerializer (Class type) {
// --- Registration ---

/** Registers the class using the lowest, next available integer ID and the {@link Kryo#getDefaultSerializer(Class) default
* serializer}. If the class is already registered, no change will be made and the existing registration will be
* returned. Registering a primitive also affects the corresponding primitive wrapper.
* serializer}. If the class is already registered, no change will be made and the existing registration will be returned.
* Registering a primitive also affects the corresponding primitive wrapper.
* <p>
* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when
* using this method. The order must be the same at deserialization as it was for serialization. */
Expand All @@ -410,9 +410,9 @@ public Registration register (Class type) {
return register(type, getDefaultSerializer(type));
}

/** Registers the class using the specified ID and the {@link Kryo#getDefaultSerializer(Class) default serializer}.
* If the class is already registered this has no effect and the existing registration is returned. Registering a
* primitive also affects the corresponding primitive wrapper.
/** Registers the class using the specified ID and the {@link Kryo#getDefaultSerializer(Class) default serializer}. If the
* class is already registered this has no effect and the existing registration is returned. Registering a primitive also
* affects the corresponding primitive wrapper.
* <p>
* IDs must be the same at deserialization as they were for serialization.
* @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and
Expand All @@ -438,8 +438,8 @@ public Registration register (Class type, Serializer serializer) {
return classResolver.register(new Registration(type, serializer, getNextRegistrationId()));
}

/** Registers the class using the specified ID and serializer. Providing an ID that is already in use by the same type
* will cause the old entry to be overwritten. Registering a primitive also affects the corresponding primitive wrapper.
/** Registers the class using the specified ID and serializer. Providing an ID that is already in use by the same type will
* cause the old entry to be overwritten. Registering a primitive also affects the corresponding primitive wrapper.
* <p>
* IDs must be the same at deserialization as they were for serialization.
* @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and
Expand All @@ -449,8 +449,8 @@ public Registration register (Class type, Serializer serializer, int id) {
return register(new Registration(type, serializer, id));
}

/** Stores the specified registration. If the ID is already in use by the same type, the old entry is overwritten.
* Registering a primitive also affects the corresponding primitive wrapper.
/** Stores the specified registration. If the ID is already in use by the same type, the old entry is overwritten. Registering
* a primitive also affects the corresponding primitive wrapper.
* <p>
* IDs must be the same at deserialization as they were for serialization.
* <p>
Expand Down Expand Up @@ -502,7 +502,7 @@ public Registration getRegistration (Class type) {
if (registrationRequired) {
throw new IllegalArgumentException(unregisteredClassMessage(type));
}
if(warnUnregisteredClasses) {
if (warnUnregisteredClasses) {
warn(unregisteredClassMessage(type));
}
registration = classResolver.registerImplicit(type);
Expand All @@ -512,8 +512,8 @@ public Registration getRegistration (Class type) {
}

protected String unregisteredClassMessage (Class type) {
return "Class is not registered: " + className(type)
+ "\nNote: To register this class use: kryo.register(" + className(type) + ".class);";
return "Class is not registered: " + className(type) + "\nNote: To register this class use: kryo.register("
+ className(type) + ".class);";
}

/** @see ClassResolver#getRegistration(int) */
Expand Down Expand Up @@ -1022,7 +1022,8 @@ public ReferenceResolver getReferenceResolver () {
return referenceResolver;
}

/** Sets the classloader to resolve unregistered class names to classes. The default is the loader that loaded the Kryo class. */
/** Sets the classloader to resolve unregistered class names to classes. The default is the loader that loaded the Kryo
* class. */
public void setClassLoader (ClassLoader classLoader) {
if (classLoader == null) throw new IllegalArgumentException("classLoader cannot be null.");
this.classLoader = classLoader;
Expand All @@ -1048,18 +1049,17 @@ public void setRegistrationRequired (boolean registrationRequired) {
public boolean isRegistrationRequired () {
return registrationRequired;
}

/**
* If true, kryo writes a warn log telling about the classes unregistered. Default is false.

/** If true, kryo writes a warn log telling about the classes unregistered. Default is false.
* <p>
* If false, no log are written when unregistered classes are encountered.
* </p>
*/
*/
public void setWarnUnregisteredClasses (boolean warnUnregisteredClasses) {
this.warnUnregisteredClasses = warnUnregisteredClasses;
if (TRACE) trace("kryo", "Warn unregistered classes: " + warnUnregisteredClasses);
}

public boolean isWarnUnregisteredClasses () {
return warnUnregisteredClasses;
}
Expand All @@ -1084,14 +1084,14 @@ public void setCopyReferences (boolean copyReferences) {
this.copyReferences = copyReferences;
}

/** The default configuration for {@link FieldSerializer} instances. Already existing serializer instances (e.g.
* implicitely created for already registered classes) are not affected by this configuration. You can override
* the configuration for a single {@link FieldSerializer}. */
public FieldSerializerConfig getFieldSerializerConfig() {
/** The default configuration for {@link FieldSerializer} instances. Already existing serializer instances (e.g. implicitely
* created for already registered classes) are not affected by this configuration. You can override the configuration for a
* single {@link FieldSerializer}. */
public FieldSerializerConfig getFieldSerializerConfig () {
return fieldSerializerConfig;
}

public TaggedFieldSerializerConfig getTaggedFieldSerializerConfig() {
public TaggedFieldSerializerConfig getTaggedFieldSerializerConfig () {
return taggedFieldSerializerConfig;
}

Expand Down Expand Up @@ -1193,7 +1193,7 @@ public boolean isFinal (Class type) {
/** Returns true if the specified type is a closure.
* <p>
* This can be overridden to support alternative implementations of clousres. Current version supports Oracle's Java8 only */
protected boolean isClosure(Class type) {
protected boolean isClosure (Class type) {
if (type == null) throw new IllegalArgumentException("type cannot be null.");
return type.getName().indexOf('/') >= 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/com/esotericsoftware/kryo/KryoCopyable.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

/** Allows implementing classes to perform their own copying. Hand written copying can be more efficient in some cases.
Expand All @@ -28,4 +28,4 @@ public interface KryoCopyable<T> {
* {@link Kryo#reference(Object)} must be called with the copy to ensure it can be referenced by the child objects.
* @see Serializer#copy(Kryo, Object) */
public T copy (Kryo kryo);
}
}
6 changes: 3 additions & 3 deletions src/com/esotericsoftware/kryo/KryoException.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

/** General Kryo RuntimeException.
Expand Down Expand Up @@ -58,4 +58,4 @@ public void addTrace (String info) {
trace.append('\n');
trace.append(info);
}
}
}
9 changes: 5 additions & 4 deletions src/com/esotericsoftware/kryo/KryoSerializable.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.serializers.DefaultSerializers.KryoSerializableSerializer;

/** Allows implementing classes to perform their own serialization. Hand written serialization can be more efficient in some cases.
/** Allows implementing classes to perform their own serialization. Hand written serialization can be more efficient in some
* cases.
* <p>
* The default serializer for KryoSerializable is {@link KryoSerializableSerializer}, which uses {@link Kryo#newInstance(Class)}
* to construct the class.
Expand All @@ -32,4 +33,4 @@ public interface KryoSerializable {
public void write (Kryo kryo, Output output);

public void read (Kryo kryo, Input input);
}
}
6 changes: 3 additions & 3 deletions src/com/esotericsoftware/kryo/NotNull.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

import java.lang.annotation.ElementType;
Expand All @@ -32,4 +32,4 @@
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface NotNull {
}
}
6 changes: 3 additions & 3 deletions src/com/esotericsoftware/kryo/ReferenceResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

/** When references are enabled, this tracks objects that have already been read or written, provides an ID for objects that are
Expand Down Expand Up @@ -52,4 +52,4 @@ public interface ReferenceResolver {
/** Returns true if references will be written for the specified type.
* @param type Will never be a primitive type, but may be a primitive type wrapper. */
public boolean useReferences (Class type);
}
}
10 changes: 5 additions & 5 deletions src/com/esotericsoftware/kryo/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

import org.objenesis.instantiator.ObjectInstantiator;
package com.esotericsoftware.kryo;

import static com.esotericsoftware.kryo.util.Util.*;
import static com.esotericsoftware.minlog.Log.*;

import org.objenesis.instantiator.ObjectInstantiator;

/** Describes the {@link Serializer} and class ID to use for a class.
* @author Nathan Sweet <[email protected]> */
public class Registration {
Expand Down Expand Up @@ -74,4 +74,4 @@ public void setInstantiator (ObjectInstantiator instantiator) {
public String toString () {
return "[" + id + ", " + className(type) + "]";
}
}
}
Loading

0 comments on commit f3700c4

Please sign in to comment.