|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). |
| 3 | + * |
| 4 | + * WSO2 LLC. licenses this file to you under the Apache License, |
| 5 | + * Version 2.0 (the "License"); you may not use this file except |
| 6 | + * in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, |
| 12 | + * software distributed under the License is distributed on an |
| 13 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | + * KIND, either express or implied. See the License for the |
| 15 | + * specific language governing permissions and limitations |
| 16 | + * under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +package org.wso2.carbon.identity.authz.spicedb.handler.model; |
| 20 | + |
| 21 | +import com.google.gson.annotations.Expose; |
| 22 | +import com.google.gson.annotations.SerializedName; |
| 23 | +import org.wso2.carbon.identity.authz.spicedb.constants.SpiceDbModelConstants; |
| 24 | + |
| 25 | +import java.util.ArrayList; |
| 26 | + |
| 27 | +/** |
| 28 | + * The {@code Definition} class represents a definition object returned in a reflection response. This definition |
| 29 | + * refers to a specific definition that is used to define the structure of an entity in SpiceDB. |
| 30 | + */ |
| 31 | +public class Definition { |
| 32 | + |
| 33 | + @SerializedName(SpiceDbModelConstants.DEFINITION_NAME) |
| 34 | + @Expose |
| 35 | + private String definitionName; |
| 36 | + @SerializedName(SpiceDbModelConstants.DEFINITION_COMMENT) |
| 37 | + @Expose |
| 38 | + private String definitionComment; |
| 39 | + @SerializedName(SpiceDbModelConstants.DEFINITION_RELATIONS) |
| 40 | + @Expose |
| 41 | + private ArrayList<Object> relations; |
| 42 | + @SerializedName(SpiceDbModelConstants.DEFINITION_PERMISSIONS) |
| 43 | + @Expose |
| 44 | + private ArrayList<Permission> permissions; |
| 45 | + private ArrayList<String> permissionNames; |
| 46 | + |
| 47 | + public String getDefinitionName() { |
| 48 | + |
| 49 | + return definitionName; |
| 50 | + } |
| 51 | + |
| 52 | + public String getDefinitionComment() { |
| 53 | + |
| 54 | + return definitionComment; |
| 55 | + } |
| 56 | + |
| 57 | + public ArrayList<Object> getRelations() { |
| 58 | + |
| 59 | + return relations; |
| 60 | + } |
| 61 | + |
| 62 | + public ArrayList<Permission> getPermissions() { |
| 63 | + |
| 64 | + return permissions; |
| 65 | + } |
| 66 | + |
| 67 | + public ArrayList<String> getPermissionNames() { |
| 68 | + |
| 69 | + permissionNames = new ArrayList<>(); |
| 70 | + if (this.permissions != null) { |
| 71 | + for (Permission permission : this.permissions) { |
| 72 | + permissionNames.add(permission.getPermissionName()); |
| 73 | + } |
| 74 | + } |
| 75 | + return permissionNames; |
| 76 | + } |
| 77 | +} |
0 commit comments