/modules/apps/headless/headless-admin-user/headless-admin-user-api/src/main/java/com/liferay/headless/admin/user/dto/v1_0/AccountRole.java
Java | 423 lines | 312 code | 94 blank | 17 comment | 35 complexity | d640e9525a56eb1b755d553423d6df72 MD5 | raw file
- /**
- * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- */
- package com.liferay.headless.admin.user.dto.v1_0;
- import com.fasterxml.jackson.annotation.JsonFilter;
- import com.fasterxml.jackson.annotation.JsonIgnore;
- import com.fasterxml.jackson.annotation.JsonProperty;
- import com.liferay.petra.function.UnsafeSupplier;
- import com.liferay.petra.string.StringBundler;
- import com.liferay.portal.kernel.util.StringUtil;
- import com.liferay.portal.vulcan.graphql.annotation.GraphQLField;
- import com.liferay.portal.vulcan.graphql.annotation.GraphQLName;
- import com.liferay.portal.vulcan.util.ObjectMapperUtil;
- import io.swagger.v3.oas.annotations.media.Schema;
- import java.io.Serializable;
- import java.util.Iterator;
- import java.util.Map;
- import java.util.Objects;
- import java.util.Set;
- import javax.annotation.Generated;
- import javax.xml.bind.annotation.XmlRootElement;
- /**
- * @author Javier Gamarra
- * @generated
- */
- @Generated("")
- @GraphQLName(
- description = "A role that belongs to an account", value = "AccountRole"
- )
- @JsonFilter("Liferay.Vulcan")
- @XmlRootElement(name = "AccountRole")
- public class AccountRole implements Serializable {
- public static AccountRole toDTO(String json) {
- return ObjectMapperUtil.readValue(AccountRole.class, json);
- }
- public static AccountRole unsafeToDTO(String json) {
- return ObjectMapperUtil.unsafeReadValue(AccountRole.class, json);
- }
- @Schema(description = "The primary key of the account that owns this role.")
- public Long getAccountId() {
- return accountId;
- }
- public void setAccountId(Long accountId) {
- this.accountId = accountId;
- }
- @JsonIgnore
- public void setAccountId(
- UnsafeSupplier<Long, Exception> accountIdUnsafeSupplier) {
- try {
- accountId = accountIdUnsafeSupplier.get();
- }
- catch (RuntimeException re) {
- throw re;
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- @GraphQLField(
- description = "The primary key of the account that owns this role."
- )
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
- protected Long accountId;
- @Schema
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- @JsonIgnore
- public void setDescription(
- UnsafeSupplier<String, Exception> descriptionUnsafeSupplier) {
- try {
- description = descriptionUnsafeSupplier.get();
- }
- catch (RuntimeException re) {
- throw re;
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- @GraphQLField
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
- protected String description;
- @Schema
- public String getDisplayName() {
- return displayName;
- }
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
- @JsonIgnore
- public void setDisplayName(
- UnsafeSupplier<String, Exception> displayNameUnsafeSupplier) {
- try {
- displayName = displayNameUnsafeSupplier.get();
- }
- catch (RuntimeException re) {
- throw re;
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- @GraphQLField
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
- protected String displayName;
- @Schema
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- @JsonIgnore
- public void setId(UnsafeSupplier<Long, Exception> idUnsafeSupplier) {
- try {
- id = idUnsafeSupplier.get();
- }
- catch (RuntimeException re) {
- throw re;
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- @GraphQLField
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
- protected Long id;
- @Schema
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- @JsonIgnore
- public void setName(UnsafeSupplier<String, Exception> nameUnsafeSupplier) {
- try {
- name = nameUnsafeSupplier.get();
- }
- catch (RuntimeException re) {
- throw re;
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- @GraphQLField
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
- protected String name;
- @Schema(description = "The primary key of the underlying system role.")
- public Long getRoleId() {
- return roleId;
- }
- public void setRoleId(Long roleId) {
- this.roleId = roleId;
- }
- @JsonIgnore
- public void setRoleId(
- UnsafeSupplier<Long, Exception> roleIdUnsafeSupplier) {
- try {
- roleId = roleIdUnsafeSupplier.get();
- }
- catch (RuntimeException re) {
- throw re;
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- @GraphQLField(
- description = "The primary key of the underlying system role."
- )
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
- protected Long roleId;
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (!(object instanceof AccountRole)) {
- return false;
- }
- AccountRole accountRole = (AccountRole)object;
- return Objects.equals(toString(), accountRole.toString());
- }
- @Override
- public int hashCode() {
- String string = toString();
- return string.hashCode();
- }
- public String toString() {
- StringBundler sb = new StringBundler();
- sb.append("{");
- if (accountId != null) {
- if (sb.length() > 1) {
- sb.append(", ");
- }
- sb.append("\"accountId\": ");
- sb.append(accountId);
- }
- if (description != null) {
- if (sb.length() > 1) {
- sb.append(", ");
- }
- sb.append("\"description\": ");
- sb.append("\"");
- sb.append(_escape(description));
- sb.append("\"");
- }
- if (displayName != null) {
- if (sb.length() > 1) {
- sb.append(", ");
- }
- sb.append("\"displayName\": ");
- sb.append("\"");
- sb.append(_escape(displayName));
- sb.append("\"");
- }
- if (id != null) {
- if (sb.length() > 1) {
- sb.append(", ");
- }
- sb.append("\"id\": ");
- sb.append(id);
- }
- if (name != null) {
- if (sb.length() > 1) {
- sb.append(", ");
- }
- sb.append("\"name\": ");
- sb.append("\"");
- sb.append(_escape(name));
- sb.append("\"");
- }
- if (roleId != null) {
- if (sb.length() > 1) {
- sb.append(", ");
- }
- sb.append("\"roleId\": ");
- sb.append(roleId);
- }
- sb.append("}");
- return sb.toString();
- }
- @Schema(
- accessMode = Schema.AccessMode.READ_ONLY,
- defaultValue = "com.liferay.headless.admin.user.dto.v1_0.AccountRole",
- name = "x-class-name"
- )
- public String xClassName;
- private static String _escape(Object object) {
- return StringUtil.replace(
- String.valueOf(object), _JSON_ESCAPE_STRINGS[0],
- _JSON_ESCAPE_STRINGS[1]);
- }
- private static boolean _isArray(Object value) {
- if (value == null) {
- return false;
- }
- Class<?> clazz = value.getClass();
- return clazz.isArray();
- }
- private static String _toJSON(Map<String, ?> map) {
- StringBuilder sb = new StringBuilder("{");
- @SuppressWarnings("unchecked")
- Set set = map.entrySet();
- @SuppressWarnings("unchecked")
- Iterator<Map.Entry<String, ?>> iterator = set.iterator();
- while (iterator.hasNext()) {
- Map.Entry<String, ?> entry = iterator.next();
- sb.append("\"");
- sb.append(_escape(entry.getKey()));
- sb.append("\": ");
- Object value = entry.getValue();
- if (_isArray(value)) {
- sb.append("[");
- Object[] valueArray = (Object[])value;
- for (int i = 0; i < valueArray.length; i++) {
- if (valueArray[i] instanceof String) {
- sb.append("\"");
- sb.append(valueArray[i]);
- sb.append("\"");
- }
- else {
- sb.append(valueArray[i]);
- }
- if ((i + 1) < valueArray.length) {
- sb.append(", ");
- }
- }
- sb.append("]");
- }
- else if (value instanceof Map) {
- sb.append(_toJSON((Map<String, ?>)value));
- }
- else if (value instanceof String) {
- sb.append("\"");
- sb.append(_escape(value));
- sb.append("\"");
- }
- else {
- sb.append(value);
- }
- if (iterator.hasNext()) {
- sb.append(", ");
- }
- }
- sb.append("}");
- return sb.toString();
- }
- private static final String[][] _JSON_ESCAPE_STRINGS = {
- {"\\", "\"", "\b", "\f", "\n", "\r", "\t"},
- {"\\\\", "\\\"", "\\b", "\\f", "\\n", "\\r", "\\t"}
- };
- }