mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 04:10:13 +02:00
Add and use ImmutabeleListUtils.nullToEmptyList()
This commit is contained in:
parent
a8e05220c1
commit
b0383884fa
@ -31,11 +31,11 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.Annotation;
|
||||
import org.jf.dexlib2.iface.AnnotationElement;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -59,7 +59,7 @@ public class ImmutableAnnotation implements Annotation {
|
||||
@Nullable ImmutableList<? extends ImmutableAnnotationElement> elements) {
|
||||
this.visibility = visibility;
|
||||
this.type = type;
|
||||
this.elements = Objects.firstNonNull(elements, ImmutableList.<ImmutableAnnotationElement>of());
|
||||
this.elements = ImmutableListUtils.nullToEmptyList(elements);
|
||||
}
|
||||
|
||||
public static ImmutableAnnotation of(Annotation annotation) {
|
||||
@ -77,7 +77,7 @@ public class ImmutableAnnotation implements Annotation {
|
||||
@Nonnull @Override public ImmutableList<? extends ImmutableAnnotationElement> getElements() { return elements; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableAnnotation> immutableListOf(List<? extends Annotation> list) {
|
||||
public static ImmutableList<ImmutableAnnotation> immutableListOf(@Nullable List<? extends Annotation> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ImmutableAnnotationElement implements AnnotationElement {
|
||||
@ -69,7 +70,8 @@ public class ImmutableAnnotationElement implements AnnotationElement {
|
||||
@Nonnull @Override public EncodedValue getValue() { return value; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableAnnotationElement> immutableListOf(List<? extends AnnotationElement> list) {
|
||||
public static ImmutableList<ImmutableAnnotationElement> immutableListOf(
|
||||
@Nullable List<? extends AnnotationElement> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,10 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.AnnotationElement;
|
||||
import org.jf.dexlib2.iface.BaseAnnotation;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -53,7 +53,7 @@ public class ImmutableBaseAnnotation implements BaseAnnotation {
|
||||
public ImmutableBaseAnnotation(@Nonnull String type,
|
||||
@Nullable ImmutableList<? extends ImmutableAnnotationElement> elements) {
|
||||
this.type = type;
|
||||
this.elements = Objects.firstNonNull(elements, ImmutableList.<ImmutableAnnotationElement>of());
|
||||
this.elements = ImmutableListUtils.nullToEmptyList(elements);
|
||||
}
|
||||
|
||||
public static ImmutableBaseAnnotation of(BaseAnnotation baseAnnotation) {
|
||||
|
@ -38,6 +38,7 @@ import org.jf.dexlib2.iface.ClassDef;
|
||||
import org.jf.dexlib2.iface.Field;
|
||||
import org.jf.dexlib2.iface.Method;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -82,11 +83,11 @@ public class ImmutableClassDef implements ClassDef {
|
||||
this.name = name;
|
||||
this.accessFlags = accessFlags;
|
||||
this.superclass = superclass;
|
||||
this.interfaces = Objects.firstNonNull(interfaces, ImmutableList.<String>of());
|
||||
this.interfaces = ImmutableListUtils.nullToEmptyList(interfaces);
|
||||
this.sourceFile = sourceFile;
|
||||
this.annotations = Objects.firstNonNull(annotations, ImmutableList.<ImmutableAnnotation>of());
|
||||
this.fields = Objects.firstNonNull(fields, ImmutableList.<ImmutableField>of());
|
||||
this.methods = Objects.firstNonNull(methods, ImmutableList.<ImmutableMethod>of());
|
||||
this.annotations = ImmutableListUtils.nullToEmptyList(annotations);
|
||||
this.fields = ImmutableListUtils.nullToEmptyList(fields);
|
||||
this.methods = ImmutableListUtils.nullToEmptyList(methods);
|
||||
}
|
||||
|
||||
public static ImmutableClassDef of(ClassDef classDef) {
|
||||
@ -114,7 +115,7 @@ public class ImmutableClassDef implements ClassDef {
|
||||
@Nonnull @Override public ImmutableList<? extends ImmutableMethod> getMethods() { return methods; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableClassDef> immutableListOf(List<? extends ClassDef> list) {
|
||||
public static ImmutableList<ImmutableClassDef> immutableListOf(@Nullable List<? extends ClassDef> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,9 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.*;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -47,7 +47,7 @@ public class ImmutableDexFile implements DexFile {
|
||||
}
|
||||
|
||||
public ImmutableDexFile(@Nullable ImmutableList<? extends ImmutableClassDef> classes) {
|
||||
this.classes = Objects.firstNonNull(classes, ImmutableList.<ImmutableClassDef>of());
|
||||
this.classes = ImmutableListUtils.nullToEmptyList(classes);
|
||||
}
|
||||
|
||||
public static ImmutableDexFile of(DexFile dexFile) {
|
||||
|
@ -62,7 +62,8 @@ public class ImmutableExceptionHandler implements ExceptionHandler {
|
||||
@Override public int getHandlerCodeOffset() { return handlerCodeOffset; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableExceptionHandler> immutableListOf(List<? extends ExceptionHandler> list) {
|
||||
public static ImmutableList<ImmutableExceptionHandler> immutableListOf(
|
||||
@Nullable List<? extends ExceptionHandler> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -31,13 +31,13 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.immutable.value.ImmutableEncodedValue;
|
||||
import org.jf.dexlib2.iface.Annotation;
|
||||
import org.jf.dexlib2.iface.Field;
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -76,7 +76,7 @@ public class ImmutableField implements Field {
|
||||
this.type = type;
|
||||
this.accessFlags = accessFlags;
|
||||
this.initialValue = initialValue;
|
||||
this.annotations = Objects.firstNonNull(annotations, ImmutableList.<ImmutableAnnotation>of());
|
||||
this.annotations = ImmutableListUtils.nullToEmptyList(annotations);
|
||||
}
|
||||
|
||||
public static ImmutableField of(Field field) {
|
||||
@ -100,7 +100,7 @@ public class ImmutableField implements Field {
|
||||
@Nonnull @Override public ImmutableList<? extends ImmutableAnnotation> getAnnotations() { return annotations; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableField> immutableListOf(List<? extends Field> list) {
|
||||
public static ImmutableList<ImmutableField> immutableListOf(@Nullable List<? extends Field> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,10 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.*;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -74,10 +74,10 @@ public class ImmutableMethod implements Method {
|
||||
@Nullable ImmutableMethodImplementation methodImplementation) {
|
||||
this.containingClass = containingClass;
|
||||
this.name = name;
|
||||
this.parameters = Objects.firstNonNull(parameters, ImmutableList.<ImmutableMethodParameter>of());
|
||||
this.parameters = ImmutableListUtils.nullToEmptyList(parameters);
|
||||
this.returnType = returnType;
|
||||
this.accessFlags = accessFlags;
|
||||
this.annotations = Objects.firstNonNull(annotations, ImmutableList.<ImmutableAnnotation>of());
|
||||
this.annotations = ImmutableListUtils.nullToEmptyList(annotations);
|
||||
this.methodImplementation = methodImplementation;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public class ImmutableMethod implements Method {
|
||||
@Nullable public ImmutableMethodImplementation getImplementation() { return methodImplementation; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableMethod> immutableListOf(List<? extends Method> list) {
|
||||
public static ImmutableList<ImmutableMethod> immutableListOf(@Nullable List<? extends Method> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.MethodImplementation;
|
||||
import org.jf.dexlib2.iface.TryBlock;
|
||||
@ -39,6 +38,7 @@ import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||
import org.jf.dexlib2.immutable.debug.ImmutableDebugItem;
|
||||
import org.jf.dexlib2.immutable.instruction.ImmutableInstruction;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -65,9 +65,9 @@ public class ImmutableMethodImplementation implements MethodImplementation {
|
||||
@Nullable ImmutableList<? extends ImmutableTryBlock> tryBlocks,
|
||||
@Nullable ImmutableList<? extends ImmutableDebugItem> debugItems) {
|
||||
this.registerCount = registerCount;
|
||||
this.instructions = Objects.firstNonNull(instructions, ImmutableList.<ImmutableInstruction>of());
|
||||
this.tryBlocks = Objects.firstNonNull(tryBlocks, ImmutableList.<ImmutableTryBlock>of());
|
||||
this.debugItems = Objects.firstNonNull(debugItems, ImmutableList.<ImmutableDebugItem>of());
|
||||
this.instructions = ImmutableListUtils.nullToEmptyList(instructions);
|
||||
this.tryBlocks = ImmutableListUtils.nullToEmptyList(tryBlocks);
|
||||
this.debugItems = ImmutableListUtils.nullToEmptyList(debugItems);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -31,11 +31,11 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.Annotation;
|
||||
import org.jf.dexlib2.iface.MethodParameter;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -58,7 +58,7 @@ public class ImmutableMethodParameter implements MethodParameter {
|
||||
@Nullable ImmutableList<? extends ImmutableAnnotation> annotations,
|
||||
@Nullable String name) {
|
||||
this.type = type;
|
||||
this.annotations = Objects.firstNonNull(annotations, ImmutableList.<ImmutableAnnotation>of());
|
||||
this.annotations = ImmutableListUtils.nullToEmptyList(annotations);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ -80,7 +80,8 @@ public class ImmutableMethodParameter implements MethodParameter {
|
||||
@Nullable @Override public String getSignature() { return null; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableMethodParameter> immutableListOf(List<? extends MethodParameter> list) {
|
||||
public static ImmutableList<ImmutableMethodParameter> immutableListOf(
|
||||
@Nullable List<? extends MethodParameter> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,11 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.ExceptionHandler;
|
||||
import org.jf.dexlib2.iface.TryBlock;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -59,7 +59,7 @@ public class ImmutableTryBlock implements TryBlock {
|
||||
@Nullable ImmutableList<? extends ImmutableExceptionHandler> exceptionHandlers) {
|
||||
this.startCodeOffset = startCodeOffset;
|
||||
this.codeUnitCount = codeUnitCount;
|
||||
this.exceptionHandlers = Objects.firstNonNull(exceptionHandlers, ImmutableList.<ImmutableExceptionHandler>of());
|
||||
this.exceptionHandlers = ImmutableListUtils.nullToEmptyList(exceptionHandlers);
|
||||
}
|
||||
|
||||
public static ImmutableTryBlock of(TryBlock tryBlock) {
|
||||
@ -80,7 +80,7 @@ public class ImmutableTryBlock implements TryBlock {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableTryBlock> immutableListOf(List<? extends TryBlock> list) {
|
||||
public static ImmutableList<ImmutableTryBlock> immutableListOf(@Nullable List<? extends TryBlock> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,11 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.instruction;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.Format;
|
||||
import org.jf.dexlib2.Opcode;
|
||||
import org.jf.dexlib2.iface.instruction.formats.ArrayPayload;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -60,7 +60,7 @@ public class ImmutableArrayPayload extends ImmutableInstruction implements Array
|
||||
//TODO: need to ensure this is a valid width (1, 2, 4, 8)
|
||||
this.elementWidth = elementWidth;
|
||||
//TODO: need to validate the elements fit within the width
|
||||
this.arrayElements = Objects.firstNonNull(arrayElements, ImmutableList.<Number>of());
|
||||
this.arrayElements = ImmutableListUtils.nullToEmptyList(arrayElements);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -31,12 +31,12 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.instruction;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.Format;
|
||||
import org.jf.dexlib2.Opcode;
|
||||
import org.jf.dexlib2.iface.instruction.SwitchElement;
|
||||
import org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -56,7 +56,7 @@ public class ImmutablePackedSwitchPayload extends ImmutableInstruction implement
|
||||
public ImmutablePackedSwitchPayload(
|
||||
@Nullable ImmutableList<? extends ImmutableSwitchElement> switchElements) {
|
||||
super(OPCODE);
|
||||
this.switchElements = Objects.firstNonNull(switchElements, ImmutableList.<ImmutableSwitchElement>of());
|
||||
this.switchElements = ImmutableListUtils.nullToEmptyList(switchElements);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -31,13 +31,12 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.instruction;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.Format;
|
||||
import org.jf.dexlib2.Opcode;
|
||||
import org.jf.dexlib2.iface.instruction.SwitchElement;
|
||||
import org.jf.dexlib2.iface.instruction.formats.SparseSwitchPayload;
|
||||
import org.jf.dexlib2.iface.instruction.formats.SparseSwitchPayload;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -56,7 +55,7 @@ public class ImmutableSparseSwitchPayload extends ImmutableInstruction implement
|
||||
public ImmutableSparseSwitchPayload(
|
||||
@Nullable ImmutableList<? extends ImmutableSwitchElement> switchElements) {
|
||||
super(OPCODE);
|
||||
this.switchElements = Objects.firstNonNull(switchElements, ImmutableList.<ImmutableSwitchElement>of());
|
||||
this.switchElements = ImmutableListUtils.nullToEmptyList(switchElements);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -36,6 +36,7 @@ import org.jf.dexlib2.iface.instruction.SwitchElement;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ImmutableSwitchElement implements SwitchElement {
|
||||
@ -62,7 +63,7 @@ public class ImmutableSwitchElement implements SwitchElement {
|
||||
@Override public int getOffset() { return offset; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableSwitchElement> immutableListOf(List<? extends SwitchElement> list) {
|
||||
public static ImmutableList<ImmutableSwitchElement> immutableListOf(@Nullable List<? extends SwitchElement> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,10 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.reference;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.reference.BasicMethodParameter;
|
||||
import org.jf.dexlib2.iface.reference.MethodReference;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -62,7 +62,7 @@ public class ImmutableMethodReference extends ImmutableReference implements Meth
|
||||
@Nonnull String returnType) {
|
||||
this.containingClass = containingClass;
|
||||
this.name = name;
|
||||
this.parameters = Objects.firstNonNull(parameters, ImmutableList.<ImmutableBasicMethodParameter>of());
|
||||
this.parameters = ImmutableListUtils.nullToEmptyList(parameters);
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
|
@ -31,12 +31,12 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.AnnotationElement;
|
||||
import org.jf.dexlib2.immutable.ImmutableAnnotationElement;
|
||||
import org.jf.dexlib2.iface.value.AnnotationEncodedValue;
|
||||
import org.jf.util.ImmutableListUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -57,7 +57,7 @@ public class ImmutableAnnotationEncodedValue extends ImmutableEncodedValue imple
|
||||
@Nullable ImmutableList<? extends ImmutableAnnotationElement> elements) {
|
||||
super(ValueType.ANNOTATION);
|
||||
this.type = type;
|
||||
this.elements = Objects.firstNonNull(elements, ImmutableList.<ImmutableAnnotationElement>of());
|
||||
this.elements = ImmutableListUtils.nullToEmptyList(elements);
|
||||
}
|
||||
|
||||
public static ImmutableAnnotationEncodedValue of(AnnotationEncodedValue annotationEncodedValue) {
|
||||
|
@ -95,7 +95,7 @@ public class ImmutableEncodedValue implements EncodedValue {
|
||||
public int getValueType() { return type; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableEncodedValue> immutableListOf(List<? extends EncodedValue> list) {
|
||||
public static ImmutableList<ImmutableEncodedValue> immutableListOf(@Nullable List<? extends EncodedValue> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
|
46
util/src/main/java/org/jf/util/ImmutableListUtils.java
Normal file
46
util/src/main/java/org/jf/util/ImmutableListUtils.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER 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 org.jf.util;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ImmutableListUtils {
|
||||
@Nonnull public static <T> ImmutableList<T> nullToEmptyList(@Nullable ImmutableList<T> list) {
|
||||
if (list == null) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user