mirror of
https://github.com/revanced/smali.git
synced 2025-05-04 16:44:25 +02:00
Refactor LocatedItems to use the function addItem() instead of
initItemsIfNull().
This commit is contained in:
parent
af8bc1d9cd
commit
1bf8f2544b
@ -13,12 +13,6 @@ public abstract class LocatedItems<T extends ItemWithLocation> {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private List<T> items = null;
|
private List<T> items = null;
|
||||||
|
|
||||||
private void initItemsIfNull() {
|
|
||||||
if (items == null) {
|
|
||||||
items = new ArrayList<>(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private List<T> getItems() {
|
private List<T> getItems() {
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
@ -70,13 +64,19 @@ public abstract class LocatedItems<T extends ItemWithLocation> {
|
|||||||
throw new IllegalArgumentException(getAddLocatedItemError());
|
throw new IllegalArgumentException(getAddLocatedItemError());
|
||||||
}
|
}
|
||||||
item.setLocation(newItemsLocation);
|
item.setLocation(newItemsLocation);
|
||||||
initItemsIfNull();
|
addItem(item);
|
||||||
items.add(item);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addItem(@Nonnull T item) {
|
||||||
|
if (items == null) {
|
||||||
|
items = new ArrayList<>(1);
|
||||||
|
}
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract String getAddLocatedItemError();
|
protected abstract String getAddLocatedItemError();
|
||||||
|
|
||||||
public void mergeItemsIntoNext(@Nonnull MethodLocation nextLocation, LocatedItems<T> otherLocatedItems) {
|
public void mergeItemsIntoNext(@Nonnull MethodLocation nextLocation, LocatedItems<T> otherLocatedItems) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user