
com.liferay.headless.delivery.dto.v1_0.PageWidgetInstanceDefinition Maven / Gradle / Ivy
The newest version!
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.headless.delivery.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 jakarta.annotation.Generated;
import jakarta.validation.Valid;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Supplier;
/**
* @author Javier Gamarra
* @generated
*/
@Generated("")
@GraphQLName(
description = "Represents a definition of a Page Widget instance.",
value = "PageWidgetInstanceDefinition"
)
@JsonFilter("Liferay.Vulcan")
@XmlRootElement(name = "PageWidgetInstanceDefinition")
public class PageWidgetInstanceDefinition implements Serializable {
public static PageWidgetInstanceDefinition toDTO(String json) {
return ObjectMapperUtil.readValue(
PageWidgetInstanceDefinition.class, json);
}
public static PageWidgetInstanceDefinition unsafeToDTO(String json) {
return ObjectMapperUtil.unsafeReadValue(
PageWidgetInstanceDefinition.class, json);
}
@io.swagger.v3.oas.annotations.media.Schema(
description = "A list of CSS Classes that are applied to the element."
)
public String[] getCssClasses() {
if (_cssClassesSupplier != null) {
cssClasses = _cssClassesSupplier.get();
_cssClassesSupplier = null;
}
return cssClasses;
}
public void setCssClasses(String[] cssClasses) {
this.cssClasses = cssClasses;
_cssClassesSupplier = null;
}
@JsonIgnore
public void setCssClasses(
UnsafeSupplier cssClassesUnsafeSupplier) {
_cssClassesSupplier = () -> {
try {
return cssClassesUnsafeSupplier.get();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new RuntimeException(exception);
}
};
}
@GraphQLField(
description = "A list of CSS Classes that are applied to the element."
)
@JsonProperty(access = JsonProperty.Access.READ_WRITE)
protected String[] cssClasses;
@JsonIgnore
private Supplier _cssClassesSupplier;
@io.swagger.v3.oas.annotations.media.Schema(
description = "Custom CSS that is applied on the fragment."
)
public String getCustomCSS() {
if (_customCSSSupplier != null) {
customCSS = _customCSSSupplier.get();
_customCSSSupplier = null;
}
return customCSS;
}
public void setCustomCSS(String customCSS) {
this.customCSS = customCSS;
_customCSSSupplier = null;
}
@JsonIgnore
public void setCustomCSS(
UnsafeSupplier customCSSUnsafeSupplier) {
_customCSSSupplier = () -> {
try {
return customCSSUnsafeSupplier.get();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new RuntimeException(exception);
}
};
}
@GraphQLField(description = "Custom CSS that is applied on the fragment.")
@JsonProperty(access = JsonProperty.Access.READ_WRITE)
protected String customCSS;
@JsonIgnore
private Supplier _customCSSSupplier;
@io.swagger.v3.oas.annotations.media.Schema(
description = "The custom CSS viewports of the page collection."
)
@Valid
public CustomCSSViewport[] getCustomCSSViewports() {
if (_customCSSViewportsSupplier != null) {
customCSSViewports = _customCSSViewportsSupplier.get();
_customCSSViewportsSupplier = null;
}
return customCSSViewports;
}
public void setCustomCSSViewports(CustomCSSViewport[] customCSSViewports) {
this.customCSSViewports = customCSSViewports;
_customCSSViewportsSupplier = null;
}
@JsonIgnore
public void setCustomCSSViewports(
UnsafeSupplier
customCSSViewportsUnsafeSupplier) {
_customCSSViewportsSupplier = () -> {
try {
return customCSSViewportsUnsafeSupplier.get();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new RuntimeException(exception);
}
};
}
@GraphQLField(
description = "The custom CSS viewports of the page collection."
)
@JsonProperty(access = JsonProperty.Access.READ_WRITE)
protected CustomCSSViewport[] customCSSViewports;
@JsonIgnore
private Supplier _customCSSViewportsSupplier;
@io.swagger.v3.oas.annotations.media.Schema(
description = "The fragment style of the page widget instance."
)
@Valid
public FragmentStyle getFragmentStyle() {
if (_fragmentStyleSupplier != null) {
fragmentStyle = _fragmentStyleSupplier.get();
_fragmentStyleSupplier = null;
}
return fragmentStyle;
}
public void setFragmentStyle(FragmentStyle fragmentStyle) {
this.fragmentStyle = fragmentStyle;
_fragmentStyleSupplier = null;
}
@JsonIgnore
public void setFragmentStyle(
UnsafeSupplier fragmentStyleUnsafeSupplier) {
_fragmentStyleSupplier = () -> {
try {
return fragmentStyleUnsafeSupplier.get();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new RuntimeException(exception);
}
};
}
@GraphQLField(
description = "The fragment style of the page widget instance."
)
@JsonProperty(access = JsonProperty.Access.READ_WRITE)
protected FragmentStyle fragmentStyle;
@JsonIgnore
private Supplier _fragmentStyleSupplier;
@io.swagger.v3.oas.annotations.media.Schema(
description = "A list of fragment viewports of the page widget instance."
)
@Valid
public FragmentViewport[] getFragmentViewports() {
if (_fragmentViewportsSupplier != null) {
fragmentViewports = _fragmentViewportsSupplier.get();
_fragmentViewportsSupplier = null;
}
return fragmentViewports;
}
public void setFragmentViewports(FragmentViewport[] fragmentViewports) {
this.fragmentViewports = fragmentViewports;
_fragmentViewportsSupplier = null;
}
@JsonIgnore
public void setFragmentViewports(
UnsafeSupplier
fragmentViewportsUnsafeSupplier) {
_fragmentViewportsSupplier = () -> {
try {
return fragmentViewportsUnsafeSupplier.get();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new RuntimeException(exception);
}
};
}
@GraphQLField(
description = "A list of fragment viewports of the page widget instance."
)
@JsonProperty(access = JsonProperty.Access.READ_WRITE)
protected FragmentViewport[] fragmentViewports;
@JsonIgnore
private Supplier _fragmentViewportsSupplier;
@io.swagger.v3.oas.annotations.media.Schema(
description = "The custom name of a Page Widget instance."
)
public String getName() {
if (_nameSupplier != null) {
name = _nameSupplier.get();
_nameSupplier = null;
}
return name;
}
public void setName(String name) {
this.name = name;
_nameSupplier = null;
}
@JsonIgnore
public void setName(UnsafeSupplier nameUnsafeSupplier) {
_nameSupplier = () -> {
try {
return nameUnsafeSupplier.get();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new RuntimeException(exception);
}
};
}
@GraphQLField(description = "The custom name of a Page Widget instance.")
@JsonProperty(access = JsonProperty.Access.READ_WRITE)
protected String name;
@JsonIgnore
private Supplier _nameSupplier;
@io.swagger.v3.oas.annotations.media.Schema(
description = "The widget instance of the page widget instance."
)
@Valid
public WidgetInstance getWidgetInstance() {
if (_widgetInstanceSupplier != null) {
widgetInstance = _widgetInstanceSupplier.get();
_widgetInstanceSupplier = null;
}
return widgetInstance;
}
public void setWidgetInstance(WidgetInstance widgetInstance) {
this.widgetInstance = widgetInstance;
_widgetInstanceSupplier = null;
}
@JsonIgnore
public void setWidgetInstance(
UnsafeSupplier
widgetInstanceUnsafeSupplier) {
_widgetInstanceSupplier = () -> {
try {
return widgetInstanceUnsafeSupplier.get();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new RuntimeException(exception);
}
};
}
@GraphQLField(
description = "The widget instance of the page widget instance."
)
@JsonProperty(access = JsonProperty.Access.READ_WRITE)
protected WidgetInstance widgetInstance;
@JsonIgnore
private Supplier _widgetInstanceSupplier;
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof PageWidgetInstanceDefinition)) {
return false;
}
PageWidgetInstanceDefinition pageWidgetInstanceDefinition =
(PageWidgetInstanceDefinition)object;
return Objects.equals(
toString(), pageWidgetInstanceDefinition.toString());
}
@Override
public int hashCode() {
String string = toString();
return string.hashCode();
}
public String toString() {
StringBundler sb = new StringBundler();
sb.append("{");
String[] cssClasses = getCssClasses();
if (cssClasses != null) {
if (sb.length() > 1) {
sb.append(", ");
}
sb.append("\"cssClasses\": ");
sb.append("[");
for (int i = 0; i < cssClasses.length; i++) {
sb.append("\"");
sb.append(_escape(cssClasses[i]));
sb.append("\"");
if ((i + 1) < cssClasses.length) {
sb.append(", ");
}
}
sb.append("]");
}
String customCSS = getCustomCSS();
if (customCSS != null) {
if (sb.length() > 1) {
sb.append(", ");
}
sb.append("\"customCSS\": ");
sb.append("\"");
sb.append(_escape(customCSS));
sb.append("\"");
}
CustomCSSViewport[] customCSSViewports = getCustomCSSViewports();
if (customCSSViewports != null) {
if (sb.length() > 1) {
sb.append(", ");
}
sb.append("\"customCSSViewports\": ");
sb.append("[");
for (int i = 0; i < customCSSViewports.length; i++) {
sb.append(String.valueOf(customCSSViewports[i]));
if ((i + 1) < customCSSViewports.length) {
sb.append(", ");
}
}
sb.append("]");
}
FragmentStyle fragmentStyle = getFragmentStyle();
if (fragmentStyle != null) {
if (sb.length() > 1) {
sb.append(", ");
}
sb.append("\"fragmentStyle\": ");
sb.append(String.valueOf(fragmentStyle));
}
FragmentViewport[] fragmentViewports = getFragmentViewports();
if (fragmentViewports != null) {
if (sb.length() > 1) {
sb.append(", ");
}
sb.append("\"fragmentViewports\": ");
sb.append("[");
for (int i = 0; i < fragmentViewports.length; i++) {
sb.append(String.valueOf(fragmentViewports[i]));
if ((i + 1) < fragmentViewports.length) {
sb.append(", ");
}
}
sb.append("]");
}
String name = getName();
if (name != null) {
if (sb.length() > 1) {
sb.append(", ");
}
sb.append("\"name\": ");
sb.append("\"");
sb.append(_escape(name));
sb.append("\"");
}
WidgetInstance widgetInstance = getWidgetInstance();
if (widgetInstance != null) {
if (sb.length() > 1) {
sb.append(", ");
}
sb.append("\"widgetInstance\": ");
sb.append(String.valueOf(widgetInstance));
}
sb.append("}");
return sb.toString();
}
@io.swagger.v3.oas.annotations.media.Schema(
accessMode = io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY,
defaultValue = "com.liferay.headless.delivery.dto.v1_0.PageWidgetInstanceDefinition",
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 map) {
StringBuilder sb = new StringBuilder("{");
@SuppressWarnings("unchecked")
Set set = map.entrySet();
@SuppressWarnings("unchecked")
Iterator> iterator = set.iterator();
while (iterator.hasNext()) {
Map.Entry 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 Map) {
sb.append(_toJSON((Map)valueArray[i]));
}
else 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)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"}
};
private Map _extendedProperties;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy