Skip to content

Commit

Permalink
1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzue committed Jan 22, 2024
1 parent 82e4e16 commit 17d7bcf
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
48 changes: 48 additions & 0 deletions basejson/src/main/java/com/kongzue/baseokhttp/util/JsonList.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ public Object get(int index) {
}

public JsonMap findJsonMap(String key, Object value) {
if (isNull(key)){
return new JsonMap().preBuild(-1, this);
}
for (int i = 0; i < size(); i++) {
Object child = get(i);
if (child instanceof JsonMap) {
Expand All @@ -322,6 +325,51 @@ public JsonMap findJsonMap(String key, Object value) {
return new JsonMap().preBuild(-1, this);
}

public int findJsonMapIndex(String key, Object value) {
if (isNull(key)){
return -1;
}
for (int i = 0; i < size(); i++) {
Object child = get(i);
if (child instanceof JsonMap) {
if (((JsonMap) child).getString(key).equals(String.valueOf(value))) {
return i;
}
}
}
return -1;
}

public JsonList findRemove(String key, Object value) {
if (isNull(key)){
return this;
}
for (int i = 0; i < size(); i++) {
Object child = get(i);
if (child instanceof JsonMap) {
if (((JsonMap) child).getString(key).equals(String.valueOf(value))) {
remove(i);
return this;
}
}
}
return this;
}

public JsonList remove(JsonMap data) {
if (data == null || data.isEmpty()) {
return this;
}
for (int i = 0; i < size(); i++) {
Object child = get(i);
if (data.toString().equals(child.toString())) {
remove(i);
return this;
}
}
return this;
}

public JsonListAdapter createAdapter(Context context, int layoutResId) {
return new JsonListAdapter(context, layoutResId, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ public boolean equals(Object o) {
return toString().equals(o.toString());
}

public boolean equals(String key, Object value) {
return get(key) == value;
}

private void callParentRelease() {
if (parentJsonMap != null) {
parentJsonMap.set(preBuildKey, this);
Expand Down

0 comments on commit 17d7bcf

Please sign in to comment.