public interface ProductType extends Resource<ProductType>, AttributeDefinitionContainer, WithKey
Modifier and Type | Method and Description |
---|---|
default Optional<AttributeDefinition> |
findAttribute(String attributeName) |
default AttributeDefinition |
getAttribute(String attributeName) |
List<AttributeDefinition> |
getAttributes() |
String |
getDescription() |
String |
getKey() |
String |
getName() |
static Reference<ProductType> |
reference(ProductType productType) |
static Reference<ProductType> |
reference(String id) |
static Reference<ProductType> |
referenceOfId(String id)
Creates a reference for one item of this class by a known ID.
|
static String |
referenceTypeId()
A type hint for references which resource type is linked in a reference.
|
static String |
resourceTypeId() |
default Reference<ProductType> |
toReference()
Creates a reference to this resource, the reference may not be filled.
|
static com.fasterxml.jackson.core.type.TypeReference<ProductType> |
typeReference()
Creates a container which contains the full Java type information to deserialize this class from JSON.
|
getCreatedAt, getId, getLastModifiedAt, getVersion
hasSameIdAs, toResourceIdentifier
String getName()
String getDescription()
List<AttributeDefinition> getAttributes()
getAttributes
in interface AttributeDefinitionContainer
@Nullable default AttributeDefinition getAttribute(String attributeName)
getAttribute
in interface AttributeDefinitionContainer
default Optional<AttributeDefinition> findAttribute(String attributeName)
findAttribute
in interface AttributeDefinitionContainer
default Reference<ProductType> toReference()
Referenceable
toReference
in interface Referenceable<ProductType>
toReference
in interface Resource<ProductType>
static String referenceTypeId()
Reference.getTypeId()
static String resourceTypeId()
static Reference<ProductType> reference(ProductType productType)
static Reference<ProductType> reference(String id)
static com.fasterxml.jackson.core.type.TypeReference<ProductType> typeReference()
static Reference<ProductType> referenceOfId(String id)
An example for categories but this applies for other resources, too:
final String categoryIdFromFormOrSession = "84ac4271-0fec-49d0-9fee-55586c565c58"; final Reference<Category> categoryReference = Category.referenceOfId(categoryIdFromFormOrSession); assertThat(categoryReference.getId()).isEqualTo(categoryIdFromFormOrSession);
See the test code.
If you already have a resource object, then use toReference()
instead:
final Category category = getCategory1(); final Reference<Category> categoryReference = category.toReference(); assertThat(category.getId()).isEqualTo(categoryReference.getId());
See the test code.
id
- the ID of the resource which should be referenced.