public class ContentItem
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ContentItem.ContentItemBuilder |
| Constructor and Description |
|---|
ContentItem() |
ContentItem(System system,
java.util.Map<java.lang.String,Element> elements,
kontent.ai.delivery.LinkedItemProvider linkedItemProvider,
StronglyTypedContentItemConverter stronglyTypedContentItemConverter) |
| Modifier and Type | Method and Description |
|---|---|
static ContentItem.ContentItemBuilder |
builder() |
protected boolean |
canEqual(java.lang.Object other) |
<T> T |
castTo(java.lang.Class<T> tClass)
Returns a new instance of T by mapping fields to elements in this content item.
|
java.lang.Object |
castTo(java.lang.String contentItemSystemType)
Returns a new instance by mapping fields to elements in this content item.
|
java.lang.Object |
castToDefault()
Returns a new instance by mapping fields to elements in this content item.
|
boolean |
equals(java.lang.Object o) |
java.util.List<Asset> |
getAssets(java.lang.String codename)
Convenience method to get the value of an Assets element without traversing the Elements map.
|
java.util.Map<java.lang.String,Element> |
getElements()
Content type elements in the content item.
|
ContentItem |
getLinkedItem(java.lang.String codename)
Convenience method to retrieve the ContentItem from linked items.
|
kontent.ai.delivery.LinkedItemProvider |
getLinkedItemProvider() |
java.lang.String |
getString(java.lang.String codename)
Convenience method to get the value of a Text or Rich text element without traversing the Elements map.
|
StronglyTypedContentItemConverter |
getStronglyTypedContentItemConverter() |
System |
getSystem()
System attributes of the content item. |
int |
hashCode() |
void |
setElements(java.util.Map<java.lang.String,Element> elements)
Content type elements in the content item.
|
void |
setSystem(System system)
System attributes of the content item. |
java.lang.String |
toString() |
public ContentItem()
public ContentItem(System system, java.util.Map<java.lang.String,Element> elements, kontent.ai.delivery.LinkedItemProvider linkedItemProvider, StronglyTypedContentItemConverter stronglyTypedContentItemConverter)
public void setElements(java.util.Map<java.lang.String,Element> elements)
Note: The order of the Element objects might not match the order in the Kontent.ai UI.
elements - New value for this ContentItem's Element objects.public java.lang.String getString(java.lang.String codename)
codename - The element codename to retrieve the String rendering of from this ContentItem.TextElement or RichTextElement.public java.util.List<Asset> getAssets(java.lang.String codename)
codename - The element codename to get the Asset list of from this ContentItem.Asset objects. Returns an empty collection if the element does not exist, or
if it is not an AssetsElement.public ContentItem getLinkedItem(java.lang.String codename)
codename - The ContentItem codename of the linked item.ContentItem. Returns null if it was not included in the response.public <T> T castTo(java.lang.Class<T> tClass)
ElementMapping
annotation. T must have a default constructor and have standard setter methods.
When passing in Object.class, the type returned will be an instance of the class registered with the
DeliveryClient that is annotated with ContentItemMapping that matches the
System.type of this ContentItem (however still returned as type Object).
If Object is passed in, the StronglyTypedContentItemConverter will cast this ContentItem to a
type that is mapped this ContentItem's System.type from a previous registration via the registration has
been done, then this same instance of ContentItem will be returned. Invoking castToDefault() is the
same as invoking this method with Object.
T - The type of class which will be returned.tClass - The class which a new instance should be returned from using this ContentItem.ContentItem.DeliveryClient.registerType(Class),
DeliveryClient.registerType(String, Class),
ContentItemMapping,
ElementMapping,
StronglyTypedContentItemConverterpublic java.lang.Object castToDefault()
ElementMapping
annotation. The type returned will be an instance of the class registered with the DeliveryClient that
is annotated with ContentItemMapping that matches the System.type of this ContentItem
(however still returned as type Object).
If no registration has been done, then this same instance of ContentItem will be returned.
ContentItem.castTo(Class),
DeliveryClient.registerType(Class),
DeliveryClient.registerType(String, Class),
ContentItemMapping,
ElementMapping,
StronglyTypedContentItemConverterpublic java.lang.Object castTo(java.lang.String contentItemSystemType)
ElementMapping
annotation. The type returned will be an instance of the class registered with the DeliveryClient that
that matches the System.type provided.
If no registration has been done, then this same instance of ContentItem will be returned.
contentItemSystemType - The contentItemSystemType to match this ContentItem too.ContentItem.castTo(Class),
DeliveryClient.registerType(Class),
DeliveryClient.registerType(String, Class),
ContentItemMapping,
ElementMapping,
StronglyTypedContentItemConverterpublic static ContentItem.ContentItemBuilder builder()
public System getSystem()
System attributes of the content item.public java.util.Map<java.lang.String,Element> getElements()
Note: The order of the Element objects might not match the order in the Kontent.ai UI.
Element objects.public kontent.ai.delivery.LinkedItemProvider getLinkedItemProvider()
public StronglyTypedContentItemConverter getStronglyTypedContentItemConverter()
public void setSystem(System system)
System attributes of the content item.system - New value for System attributes of this content item.public boolean equals(java.lang.Object o)
equals in class java.lang.Objectprotected boolean canEqual(java.lang.Object other)
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object