Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public int hashCode() {
}

@Override
@CanIgnoreReturnValue
public boolean add(E e) {
ensureIsMutable();
return super.add(e);
Expand All @@ -89,12 +90,14 @@ public void add(int index, E element) {
}

@Override
@CanIgnoreReturnValue
public boolean addAll(Collection<? extends E> c) {
ensureIsMutable();
return super.addAll(c);
}

@Override
@CanIgnoreReturnValue
public boolean addAll(int index, Collection<? extends E> c) {
ensureIsMutable();
return super.addAll(index, c);
Expand All @@ -119,12 +122,14 @@ public final void makeImmutable() {
}

@Override
@CanIgnoreReturnValue
public E remove(int index) {
ensureIsMutable();
return super.remove(index);
}

@Override
@CanIgnoreReturnValue
public boolean remove(Object o) {
ensureIsMutable();
int index = indexOf(o);
Expand All @@ -136,18 +141,21 @@ public boolean remove(Object o) {
}

@Override
@CanIgnoreReturnValue
public boolean removeAll(Collection<?> c) {
ensureIsMutable();
return super.removeAll(c);
}

@Override
@CanIgnoreReturnValue
public boolean retainAll(Collection<?> c) {
ensureIsMutable();
return super.retainAll(c);
}

@Override
@CanIgnoreReturnValue
public E set(int index, E element) {
ensureIsMutable();
return super.set(index, element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ public int size() {
}

@Override
@CanIgnoreReturnValue
public Boolean set(int index, Boolean element) {
return setBoolean(index, element);
}

@Override
@CanIgnoreReturnValue
public boolean setBoolean(int index, boolean element) {
ensureIsMutable();
ensureIndexInRange(index);
Expand All @@ -171,6 +173,7 @@ public boolean setBoolean(int index, boolean element) {
}

@Override
@CanIgnoreReturnValue
public boolean add(Boolean element) {
addBoolean(element);
return true;
Expand Down Expand Up @@ -224,6 +227,7 @@ private void addBoolean(int index, boolean element) {
}

@Override
@CanIgnoreReturnValue
public boolean addAll(Collection<? extends Boolean> collection) {
ensureIsMutable();

Expand Down Expand Up @@ -257,6 +261,7 @@ public boolean addAll(Collection<? extends Boolean> collection) {
}

@Override
@CanIgnoreReturnValue
public Boolean remove(int index) {
ensureIsMutable();
ensureIndexInRange(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ public abstract <T extends MessageLite> T readMessage(
*
* @return the old limit.
*/
@CanIgnoreReturnValue
public final int setRecursionLimit(final int limit) {
if (limit < 0) {
throw new IllegalArgumentException("Recursion limit cannot be negative: " + limit);
Expand All @@ -464,6 +465,7 @@ public final int setRecursionLimit(final int limit) {
*
* @return the old limit.
*/
@CanIgnoreReturnValue
public final int setSizeLimit(final int limit) {
if (limit < 0) {
throw new IllegalArgumentException("Size limit cannot be negative: " + limit);
Expand Down Expand Up @@ -522,6 +524,7 @@ final boolean shouldDiscardUnknownFields() {
*
* @return the old limit.
*/
@CanIgnoreReturnValue
public abstract int pushLimit(int byteLimit) throws InvalidProtocolBufferException;

/**
Expand Down Expand Up @@ -1224,6 +1227,7 @@ public void resetSizeCounter() {
}

@Override
@CanIgnoreReturnValue
public int pushLimit(int byteLimit) throws InvalidProtocolBufferException {
if (byteLimit < 0) {
throw InvalidProtocolBufferException.negativeSize();
Expand Down Expand Up @@ -2000,6 +2004,7 @@ public void resetSizeCounter() {
}

@Override
@CanIgnoreReturnValue
public int pushLimit(int byteLimit) throws InvalidProtocolBufferException {
if (byteLimit < 0) {
throw InvalidProtocolBufferException.negativeSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ public int size() {
}

@Override
@CanIgnoreReturnValue
public Double set(int index, Double element) {
return setDouble(index, element);
}

@Override
@CanIgnoreReturnValue
public double setDouble(int index, double element) {
ensureIsMutable();
ensureIndexInRange(index);
Expand All @@ -170,6 +172,7 @@ public double setDouble(int index, double element) {
}

@Override
@CanIgnoreReturnValue
public boolean add(Double element) {
addDouble(element);
return true;
Expand Down Expand Up @@ -223,6 +226,7 @@ private void addDouble(int index, double element) {
}

@Override
@CanIgnoreReturnValue
public boolean addAll(Collection<? extends Double> collection) {
ensureIsMutable();

Expand Down Expand Up @@ -256,6 +260,7 @@ public boolean addAll(Collection<? extends Double> collection) {
}

@Override
@CanIgnoreReturnValue
public Double remove(int index) {
ensureIsMutable();
ensureIndexInRange(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ public int size() {
}

@Override
@CanIgnoreReturnValue
public Float set(int index, Float element) {
return setFloat(index, element);
}

@Override
@CanIgnoreReturnValue
public float setFloat(int index, float element) {
ensureIsMutable();
ensureIndexInRange(index);
Expand All @@ -169,6 +171,7 @@ public float setFloat(int index, float element) {
}

@Override
@CanIgnoreReturnValue
public boolean add(Float element) {
addFloat(element);
return true;
Expand Down Expand Up @@ -222,6 +225,7 @@ private void addFloat(int index, float element) {
}

@Override
@CanIgnoreReturnValue
public boolean addAll(Collection<? extends Float> collection) {
ensureIsMutable();

Expand Down Expand Up @@ -255,6 +259,7 @@ public boolean addAll(Collection<? extends Float> collection) {
}

@Override
@CanIgnoreReturnValue
public Float remove(int index) {
ensureIsMutable();
ensureIndexInRange(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ public int size() {
}

@Override
@CanIgnoreReturnValue
public Integer set(int index, Integer element) {
return setInt(index, element);
}

@Override
@CanIgnoreReturnValue
public int setInt(int index, int element) {
ensureIsMutable();
ensureIndexInRange(index);
Expand All @@ -169,6 +171,7 @@ public int setInt(int index, int element) {
}

@Override
@CanIgnoreReturnValue
public boolean add(Integer element) {
addInt(element);
return true;
Expand Down Expand Up @@ -222,6 +225,7 @@ private void addInt(int index, int element) {
}

@Override
@CanIgnoreReturnValue
public boolean addAll(Collection<? extends Integer> collection) {
ensureIsMutable();

Expand Down Expand Up @@ -255,6 +259,7 @@ public boolean addAll(Collection<? extends Integer> collection) {
}

@Override
@CanIgnoreReturnValue
public Integer remove(int index) {
ensureIsMutable();
ensureIndexInRange(index);
Expand Down
2 changes: 2 additions & 0 deletions java/core/src/main/java/com/google/protobuf/Internal.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private Internal() {}
static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");

/** Throws an appropriate {@link NullPointerException} if the given objects is {@code null}. */
@CanIgnoreReturnValue
static <T> T checkNotNull(T obj) {
if (obj == null) {
throw new NullPointerException();
Expand All @@ -44,6 +45,7 @@ static <T> T checkNotNull(T obj) {
}

/** Throws an appropriate {@link NullPointerException} if the given objects is {@code null}. */
@CanIgnoreReturnValue
static <T> T checkNotNull(T obj, String message) {
if (obj == null) {
throw new NullPointerException(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public InvalidProtocolBufferException(String description, IOException e) {
*
* @return this
*/
@CanIgnoreReturnValue
public InvalidProtocolBufferException setUnfinishedMessage(MessageLite unfinishedMessage) {
this.unfinishedMessage = unfinishedMessage;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public MessageLite getValue() {
* <p>LazyField is not thread-safe for write access. Synchronizations are needed under read/write
* situations.
*/
@CanIgnoreReturnValue
public MessageLite setValue(MessageLite value) {
MessageLite originalValue = this.value;
this.delayedBytes = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public void add(byte[] element) {
}

@Override
@CanIgnoreReturnValue
public boolean addAll(Collection<? extends String> c) {
// The default implementation of AbstractCollection.addAll(Collection)
// delegates to add(Object). This implementation instead delegates to
Expand All @@ -170,6 +171,7 @@ public boolean addAll(Collection<? extends String> c) {
}

@Override
@CanIgnoreReturnValue
public boolean addAll(int index, Collection<? extends String> c) {
ensureIsMutable();
// When copying from another LazyStringList, directly copy the underlying
Expand All @@ -182,6 +184,7 @@ public boolean addAll(int index, Collection<? extends String> c) {
}

@Override
@CanIgnoreReturnValue
public boolean addAllByteString(Collection<? extends ByteString> values) {
ensureIsMutable();
boolean ret = list.addAll(values);
Expand All @@ -190,6 +193,7 @@ public boolean addAllByteString(Collection<? extends ByteString> values) {
}

@Override
@CanIgnoreReturnValue
public boolean addAllByteArray(Collection<byte[]> c) {
ensureIsMutable();
boolean ret = list.addAll(c);
Expand All @@ -198,6 +202,7 @@ public boolean addAllByteArray(Collection<byte[]> c) {
}

@Override
@CanIgnoreReturnValue
public String remove(int index) {
ensureIsMutable();
Object o = list.remove(index);
Expand Down Expand Up @@ -238,6 +243,7 @@ public byte[] getByteArray(int index) {
}

@Override
@CanIgnoreReturnValue
public String set(int index, String s) {
ensureIsMutable();
Object o = list.set(index, s);
Expand All @@ -254,11 +260,13 @@ public void set(int index, byte[] s) {
setAndReturn(index, s);
}

@CanIgnoreReturnValue
private Object setAndReturn(int index, ByteString s) {
ensureIsMutable();
return list.set(index, s);
}

@CanIgnoreReturnValue
private Object setAndReturn(int index, byte[] s) {
ensureIsMutable();
return list.set(index, s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ public int size() {
}

@Override
@CanIgnoreReturnValue
public Long set(int index, Long element) {
return setLong(index, element);
}

@Override
@CanIgnoreReturnValue
public long setLong(int index, long element) {
ensureIsMutable();
ensureIndexInRange(index);
Expand All @@ -169,6 +171,7 @@ public long setLong(int index, long element) {
}

@Override
@CanIgnoreReturnValue
public boolean add(Long element) {
addLong(element);
return true;
Expand Down Expand Up @@ -222,6 +225,7 @@ private void addLong(int index, long element) {
}

@Override
@CanIgnoreReturnValue
public boolean addAll(Collection<? extends Long> collection) {
ensureIsMutable();

Expand Down Expand Up @@ -255,6 +259,7 @@ public boolean addAll(Collection<? extends Long> collection) {
}

@Override
@CanIgnoreReturnValue
public Long remove(int index) {
ensureIsMutable();
ensureIndexInRange(index);
Expand Down
Loading
Loading