io.everitoken.sdk.java.dto.Permission Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chain-sdk Show documentation
Show all versions of chain-sdk Show documentation
Official Java SDK for everiToken public chain. https://www.everitoken.io
package io.everitoken.sdk.java.dto;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import org.jetbrains.annotations.NotNull;
public class Permission implements Namable {
private final String name;
private final int threshold;
private List authorizers = new ArrayList<>();
private Permission(String name, int threshold, List authorizers) {
this.name = name;
this.threshold = threshold;
this.authorizers = authorizers;
}
@NotNull
public static Permission ofRaw(@NotNull JSONObject raw) {
Objects.requireNonNull(raw);
String name = raw.getString("name");
int threshold = raw.getInteger("threshold");
List authorizers = new ArrayList<>();
JSONArray authorizersArray = raw.getJSONArray("authorizers");
for (int i = 0; i < authorizersArray.size(); i++) {
authorizers.add(AuthorizerWeight.ofRaw((JSONObject) authorizersArray.get(i)));
}
return new Permission(name, threshold, authorizers);
}
@JSONField(ordinal = 1)
public int getThreshold() {
return threshold;
}
@JSONField(ordinal = 2)
public List getAuthorizers() {
return authorizers;
}
@Override
public String getName() {
return name;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy