Code cleanup

This commit is contained in:
David Noble
2019-09-13 12:04:49 -07:00
parent 7012ec8a80
commit 99e2d462cd
6 changed files with 75 additions and 73 deletions

View File

@@ -83,14 +83,14 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* {@code true} if the length of this instance is zero
* {@code true} if the length of this instance is zero.
*/
public final boolean isEmpty() {
return this.buffer != null && this.buffer.writerIndex() == 0;
}
/**
* {@code true} if this instance is null
* {@code true} if this instance is null.
*/
public final boolean isNull() {
return this.buffer == null;
@@ -102,7 +102,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Non-allocating enumeration of each character in the UTF-8 stream
* Non-allocating enumeration of each character in the UTF-8 stream.
*/
@Override
public IntStream chars() {
@@ -110,7 +110,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Non-allocating enumeration of each code point in the UTF-8 stream
* Non-allocating enumeration of each code point in the UTF-8 stream.
*/
public final IntStream codePoints() {
@@ -162,7 +162,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Returns a reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}
* Returns a reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}.
* <p>
* A value of {@code null} is returns, if this {@link Utf8String} is null.
* @return reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}.
@@ -173,7 +173,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Creates a deep copy of this {@link Utf8String}
* Creates a deep copy of this {@link Utf8String}.
*/
@Override
public Utf8String copy() {
@@ -181,7 +181,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Duplicates this {@link Utf8String}
* Duplicates this {@link Utf8String}.
* <p>
* Be aware that this will not automatically call {@link #retain()}.
*/
@@ -191,9 +191,10 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Encoded length of this {@link Utf8String}
* Encoded length of this {@link Utf8String}.
* <p>
* This is the same value as would be returned by {@link String#getBytes()#utf16CodeUnitCount} with no time or space overhead.
* This is the same value as would be returned by {@link String#getBytes()#utf16CodeUnitCount} with no time or space
* overhead.
*
* @return encoded length of {@link Utf8String}
*/
@@ -235,9 +236,9 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Creates a new {@link Utf8String} from a {@link ByteBuf} with UTF-8 character validation
* Creates a new {@link Utf8String} from a {@link ByteBuf} with UTF-8 character validation.
* <p>
* The {@link Utf8String} created retains the {@link ByteBuf}. (No data is transferred.)
* The {@link Utf8String} created retains the {@link ByteBuf}. No data is transferred.
*
* @param buffer The {@link ByteBuf} to validate and assign to the {@link Utf8String} created.
* @return A {@link Utf8String} instance, if the @{code buffer} validates or a value of @{link Optional#empty}
@@ -280,7 +281,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Returns the reference count of this {@link Utf8String}
* Returns the reference count of this {@link Utf8String}.
* <p>
* If {@code 0}, it means this object has been deallocated.
*/
@@ -302,7 +303,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Decreases the reference count by the specified {@code decrement}
* Decreases the reference count by the specified {@code decrement}.
*
* The underlying storage for this instance is deallocated, if the reference count reaches {@code 0}.
*
@@ -376,7 +377,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
/**
* Creates a {@link Utf8String} from a UTF16 encoding string
* Creates a {@link Utf8String} from a UTF16 encoding string.
* <p>
* This method must transcode the UTF-16 into UTF-8 which both requires allocation and is a size of data operation.
*
@@ -422,8 +423,8 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
/**
* Returns the next {@code int} element in the iteration.
*
* @return the next {@code int} element in the iteration
* @throws NoSuchElementException if the iteration has no more elements
* @return the next {@code int} element in the iteration.
* @throws NoSuchElementException if the iteration has no more elements.
*/
@Override
public int nextInt() {
@@ -581,7 +582,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
* single-byte UTF-8 code units in the code point.
* <p>
* Code points are validated. The {@link #process(byte)} method returns the Unicode
* <a href="https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character">Replacement character</a>
* <a href="https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character">Replacement Character</a>
* when an undefined code point is encountered.
*
* @see <a href="https://tools.ietf.org/html/rfc3629">RFC 3629: UTF-8, a transformation format of ISO 10646</a>

View File

@@ -9,7 +9,7 @@ import static com.azure.data.cosmos.core.Utf8String.transcodeUtf16;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* A string whose memory representation may be either UTF-8 or UTF-16
* A string whose memory representation may be either UTF-8 or UTF-16.
* <p>
* This type supports polymorphic use of {@link String} and {@link Utf8String} when equality, hashing, and comparison
* are needed against either encoding. An API leveraging {@link UtfAnyString} can avoid separate method overloads
@@ -40,14 +40,14 @@ public final class UtfAnyString implements CharSequence, Comparable<UtfAnyString
}
/**
* {@code true} if the {@link UtfAnyString} is empty
* {@code true} if the {@link UtfAnyString} is empty.
*/
public boolean isEmpty() {
return this.buffer != null && this.buffer.length() == 0;
}
/**
* {@code true} if the {@link UtfAnyString} is {@code null}
* {@code true} if the {@link UtfAnyString} is {@code null}.
*/
public boolean isNull() {
return null == this.buffer;
@@ -62,7 +62,7 @@ public final class UtfAnyString implements CharSequence, Comparable<UtfAnyString
}
/**
* Returns the {@code char} value at the specified {@code index}
* Returns the {@code char} value at the specified {@code index}.
* <p>
* An index ranges from zero to {@link UtfAnyString#length()} minus one. The first {@code char} value of the
* sequence is at index zero, the next at index one, and so on, as for array indexing. If the {@code char}
@@ -230,11 +230,12 @@ public final class UtfAnyString implements CharSequence, Comparable<UtfAnyString
}
/**
* Returns the length of this character sequence. The length is the number
* of 16-bit {@code char}s in the sequence.
* Returns the length of this character sequence.
* <p>
* The length is the number of 16-bit {@code char}s in the sequence.
*
* @return the number of {@code char}s in this sequence
* @throws UnsupportedOperationException if this {@link UtfAnyString} is {@code null}
* @return the number of {@code char}s in this sequence.
* @throws UnsupportedOperationException if this {@link UtfAnyString} is {@code null}.
*/
@Override
public int length() {
@@ -245,7 +246,7 @@ public final class UtfAnyString implements CharSequence, Comparable<UtfAnyString
}
/**
* Returns a {@code CharSequence} that is a subsequence of this sequence
* Returns a {@code CharSequence} that is a subsequence of this sequence.
* <p>
* The subsequence starts with the {@code char} value at the specified index and ends with the{@code char} value at
* index {@code end - 1}. The length (in {@code char}s) of the returned sequence is {@code end - start}, so if

View File

@@ -32,10 +32,10 @@ public final class DateTimeCodec {
}
/**
* Decode an {@link OffsetDateTime} from a {@code System.DateTimeCodec} as serialized by {@code MemoryMarshal.Write}
* Decode an {@link OffsetDateTime} serialized like a {@code System.DateTime} by {@code MemoryMarshal.Write}.
*
* @param bytes a {@link byte} array containing the serialized value to be decoded
* @return a new {@link OffsetDateTime}
* @param bytes a {@link byte} array containing the serialized value to be decoded.
* @return a new {@link OffsetDateTime}.
* @see <a href="https://referencesource.microsoft.com/mscorlib/a.html#df6b1eba7461813b">
* struct DateTimeCodec source</a>
*/
@@ -45,10 +45,10 @@ public final class DateTimeCodec {
}
/**
* Decode an {@link OffsetDateTime} from a {@code System.DateTimeCodec} as serialized by {@code MemoryMarshal.Write}
* Decode an {@link OffsetDateTime} serialized like a {@code System.DateTime} by {@code MemoryMarshal.Write}.
*
* @param in a {@link ByteBuf} containing the serialized value to be decoded
* @return a new {@link OffsetDateTime}
* @param in a {@link ByteBuf} containing the serialized value to be decoded.
* @return a new {@link OffsetDateTime}.
* @see <a href="https://referencesource.microsoft.com/mscorlib/a.html#df6b1eba7461813b">
* struct DateTimeCodec source</a>
*/
@@ -68,10 +68,10 @@ public final class DateTimeCodec {
}
/**
* Encode an {@link OffsetDateTime} as a {@code System.DateTimeCodec} serialized by {@code MemoryMarshal.Write}
* Encode an {@link OffsetDateTime} like a {@code System.DateTime} serialized by {@code MemoryMarshal.Write}.
*
* @param offsetDateTime an {@link OffsetDateTime} to be encoded
* @return a new byte array containing the encoded {@code offsetDateTime}
* @param offsetDateTime an {@link OffsetDateTime} to be encoded.
* @return a new byte array containing the encoded {@code offsetDateTime}.
* @see <a href="https://referencesource.microsoft.com/mscorlib/a.html#df6b1eba7461813b">
* struct DateTimeCodec source</a>
*/
@@ -82,10 +82,10 @@ public final class DateTimeCodec {
}
/**
* Encode an {@link OffsetDateTime} as a {@code System.DateTimeCodec} serialized by {@code MemoryMarshal.Write}
* Encode an {@link OffsetDateTime} like a {@code System.DateTime} produced by {@code MemoryMarshal.Write}.
*
* @param offsetDateTime an {@link OffsetDateTime} to be encoded
* @param out an output {@link ByteBuf}
* @param offsetDateTime an {@link OffsetDateTime} to be encoded.
* @param out an output {@link ByteBuf}.
* @see <a href="https://referencesource.microsoft.com/mscorlib/a.html#df6b1eba7461813b">
* struct DateTimeCodec source</a>
*/

View File

@@ -46,10 +46,10 @@ public final class DecimalCodec {
}
/**
* Decode a {@link BigDecimal} from a {@code System.DecimalCodec} as serialized by {@code MemoryMarshal.Write}
* Decode an {@link BigDecimal} serialized like a {@code System.Decimal} by {@code MemoryMarshal.Write}.
*
* @param bytes a {@link byte} array containing the serialized {@code System.DecimalCodec} to be decoded
* @return a new {@link BigDecimal}
* @param bytes a {@link byte} array containing the serialized {@code System.Decimal} to be decoded.
* @return a new {@link BigDecimal}.
* @see <a href="https://referencesource.microsoft.com/mscorlib/system/decimal.cs.html">
* struct DecimalCodec source</a>
*/
@@ -59,10 +59,10 @@ public final class DecimalCodec {
}
/**
* Decode a {@link BigDecimal} from a {@code System.DecimalCodec} value serialized by {@code MemoryMarshal.Write}
* Decode an {@link BigDecimal} serialized like a {@code System.Decimal} by {@code MemoryMarshal.Write}.
*
* @param in a {@link ByteBuf} containing the serialized {@code System.DecimalCodec} to be decoded
* @return a new {@link BigDecimal}
* @param in a {@link ByteBuf} containing the serialized {@code System.Decimal} to be decoded.
* @return a new {@link BigDecimal}.
* @see <a href="https://referencesource.microsoft.com/mscorlib/system/decimal.cs.html">
* struct DecimalCodec source</a>
*/
@@ -106,10 +106,10 @@ public final class DecimalCodec {
}
/**
* Encode a {@link BigDecimal} as a {@code System.DecimalCodec} serialized by {@code MemoryMarshal.Write}
* Encode a {@link BigDecimal} like a {@code System.Decimal} serialized by {@code MemoryMarshal.Write}.
*
* @param bigDecimal a {@link BigDecimal} to be encoded
* @return a new byte array containing the encoded {@code bigDecimal}
* @param bigDecimal a {@link BigDecimal} to be encoded.
* @return a new byte array containing the encoded {@code bigDecimal}.
* @see <a href="https://referencesource.microsoft.com/mscorlib/system/decimal.cs.html">
* struct DecimalCodec source</a>
*/
@@ -120,10 +120,10 @@ public final class DecimalCodec {
}
/**
* Encode a {@link BigDecimal} as a {@code System.DecimalCodec} serialized by {@code MemoryMarshal.Write}
* Encode a {@link BigDecimal} like a {@code System.Decimal} serialized by {@code MemoryMarshal.Write}.
*
* @param value a {@link BigDecimal} to be encoded
* @param out an output {@link ByteBuf}
* @param value a {@link BigDecimal} to be encoded.
* @param out an output {@link ByteBuf}.
* @see <a href="https://referencesource.microsoft.com/mscorlib/system/decimal.cs.html">
* struct DecimalCodec source</a>
*/

View File

@@ -20,10 +20,10 @@ public final class Float128Codec {
}
/**
* Decode a {@link Float128} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
* Decode a {@link Float128} from a sequence of two {@code long}s in little endian format.
*
* @param bytes a {@link byte} array containing the serialized {@link Float128} to be decoded
* @return a new {@link Float128}
* @param bytes a {@link byte} array containing the serialized {@link Float128} to be decoded.
* @return a new {@link Float128}.
*/
public static Float128 decode(@Nonnull final byte[] bytes) {
checkNotNull(bytes);
@@ -31,10 +31,10 @@ public final class Float128Codec {
}
/**
* Decode a {@link Float128} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
* Decode a {@link Float128} from a sequence of two {@code long}s in little endian format.
*
* @param in a {@link ByteBuf} containing the serialized {@link Float128} to be decoded
* @return a new {@link Float128}
* @param in a {@link ByteBuf} containing the serialized {@link Float128} to be decoded.
* @return a new {@link Float128}.
*/
public static Float128 decode(@Nonnull final ByteBuf in) {
@@ -48,10 +48,10 @@ public final class Float128Codec {
}
/**
* Encodes a {@link Float128} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
* Encodes a {@link Float128} as a sequence of two {@code long}s in little endian format.
*
* @param value a {@link Float128} to be encoded
* @return a new byte array containing the encoded
* @param value a {@link Float128} to be encoded.
* @return a new byte array containing the encoded.
*/
public static byte[] encode(final Float128 value) {
final byte[] bytes = new byte[BYTES];
@@ -60,10 +60,10 @@ public final class Float128Codec {
}
/**
* Encodes a {@link Float128} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
* Encodes a {@link Float128} as a sequence of two {@code long}s in little endian format.
*
* @param value a {@link Float128} to be encoded
* @param out an output {@link ByteBuf}
* @param value a {@link Float128} to be encoded.
* @param out an output {@link ByteBuf}.
*/
public static void encode(final Float128 value, final ByteBuf out) {
out.writeLongLE(value.high());

View File

@@ -21,10 +21,10 @@ public final class GuidCodec {
}
/**
* Decode a {@link UUID} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
* Decode a {@link UUID} serialized like a {@code System.Guid} by {@code MemoryMarshal.Write}.
*
* @param bytes a {@link byte} array containing the serialized {@link UUID} to be decoded
* @return a new {@link UUID}
* @param bytes a {@link byte} array containing the serialized {@link UUID} to be decoded.
* @return a new {@link UUID}.
*/
public static UUID decode(@Nonnull final byte[] bytes) {
checkNotNull(bytes);
@@ -32,9 +32,9 @@ public final class GuidCodec {
}
/**
* Decode a {@link UUID} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
* Decode a {@link UUID} serialized like a {@code System.Guid} by {@code MemoryMarshal.Write}.
*
* @param in a {@link ByteBuf} containing the serialized {@link UUID} to be decoded
* @param in a {@link ByteBuf} containing the serialized {@link UUID} to be decoded;
* @return a new {@link UUID}
*/
public static UUID decode(@Nonnull final ByteBuf in) {
@@ -60,10 +60,10 @@ public final class GuidCodec {
}
/**
* Encodes a {@link UUID} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
* Encodes a {@link UUID} like a {@code System.Guid} serialized by {@code MemoryMarshal.Write}.
*
* @param uuid a {@link UUID} to be encoded
* @return a new byte array containing the encoded
* @param uuid a {@link UUID} to be encoded.
* @return a new byte array containing the encoded.
*/
public static byte[] encode(final UUID uuid) {
final byte[] bytes = new byte[BYTES];
@@ -72,10 +72,10 @@ public final class GuidCodec {
}
/**
* Encodes a {@link UUID} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
* Encodes a {@link UUID} like a {@code System.Guid} serialized by {@code MemoryMarshal.Write}.
*
* @param uuid a {@link UUID} to be encoded
* @param out an output {@link ByteBuf}
* @param uuid a {@link UUID} to be encoded.
* @param out an output {@link ByteBuf}.
*/
public static void encode(final UUID uuid, final ByteBuf out) {