Fix lint warnings in the javalite branch.

This commit is contained in:
Jisi Liu 2017-03-09 15:56:29 -08:00
parent 84bc5fc41e
commit 09b707a2a1
6 changed files with 11 additions and 0 deletions

View file

@ -854,6 +854,7 @@ public abstract class GeneratedMessage extends AbstractMessage
/** Check if a singular extension is present. */
@Override
@SuppressWarnings("unchecked")
public final <Type> boolean hasExtension(final ExtensionLite<MessageType, Type> extensionLite) {
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
@ -863,6 +864,7 @@ public abstract class GeneratedMessage extends AbstractMessage
/** Get the number of elements in a repeated extension. */
@Override
@SuppressWarnings("unchecked")
public final <Type> int getExtensionCount(
final ExtensionLite<MessageType, List<Type>> extensionLite) {
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
@ -2555,6 +2557,7 @@ public abstract class GeneratedMessage extends AbstractMessage
}
@Override
@SuppressWarnings("unchecked")
public Object get(GeneratedMessage message) {
List result = new ArrayList();
for (int i = 0; i < getRepeatedCount(message); i++) {
@ -2564,6 +2567,7 @@ public abstract class GeneratedMessage extends AbstractMessage
}
@Override
@SuppressWarnings("unchecked")
public Object get(Builder builder) {
List result = new ArrayList();
for (int i = 0; i < getRepeatedCount(builder); i++) {

View file

@ -221,6 +221,7 @@ public abstract class GeneratedMessageLite<
}
@Override
@SuppressWarnings("unchecked")
public final BuilderType toBuilder() {
BuilderType builder = (BuilderType) dynamicMethod(MethodToInvoke.NEW_BUILDER);
builder.mergeFrom((MessageType) this);
@ -454,6 +455,7 @@ public abstract class GeneratedMessageLite<
*/
protected FieldSet<ExtensionDescriptor> extensions = FieldSet.newFieldSet();
@SuppressWarnings("unchecked")
protected final void mergeExtensionFields(final MessageType other) {
if (extensions.isImmutable()) {
extensions = extensions.clone();

View file

@ -89,6 +89,7 @@ public final class MapEntry<K, V> extends AbstractMessage {
}
/** Create a MapEntry with the provided key and value. */
@SuppressWarnings("unchecked")
private MapEntry(Metadata metadata, K key, V value) {
this.key = key;
this.value = value;
@ -426,6 +427,7 @@ public final class MapEntry<K, V> extends AbstractMessage {
}
@Override
@SuppressWarnings("unchecked")
public Builder<K, V> clone() {
return new Builder(metadata, key, value);
}

View file

@ -100,6 +100,7 @@ public class MapField<K, V> implements MutabilityOracle {
}
@Override
@SuppressWarnings("unchecked")
public void convertMessageToKeyAndValue(Message message, Map<K, V> map) {
MapEntry<K, V> entry = (MapEntry<K, V>) message;
map.put(entry.getKey(), entry.getValue());

View file

@ -1431,6 +1431,7 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
"\n"
"private volatile com.google.protobuf.Message cachedUnpackValue;\n"
"\n"
"@java.lang.SuppressWarnings(\"unchecked\")\n"
"public <T extends com.google.protobuf.Message> T unpack(\n"
" java.lang.Class<T> clazz)\n"
" throws com.google.protobuf.InvalidProtocolBufferException {\n"

View file

@ -339,6 +339,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
}
printer->Print(
"@java.lang.SuppressWarnings(\"unchecked\")\n"
"protected final Object dynamicMethod(\n"
" com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n"
" Object arg0, Object arg1) {\n"