public static class BaseResourceTypes.ReadContained<BE> extends Traversal<BE,E> implements ResourceTypes.ReadContained
| Constructor and Description |
|---|
ReadContained(TraversalContext<BE,ResourceType> context) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanup(BE deletedEntity)
Serves the same purpose as
Mutator.cleanup(Object, Object) and is called during the delete()
method inside the transaction. |
void |
delete()
Deletes the entity.
|
Page<E> |
entities(Pager pager) |
E |
entity()
Resolves the entity and returns it.
|
ResourceTypes.Single |
get(String id)
Tries to find a single entity in the current position in the inventory traversal.
|
ResourceTypes.Multiple |
getAll(Filter[][] filters)
Returns access interface to all entities conforming to the provided filters in the current position in the
inventory traversal.
|
protected <T> Page<T> |
loadEntities(Pager pager,
BiFunction<BE,E,T> conversionFunction)
Loads the entities given the pager and converts them using the provided conversion function to the desired type.
|
protected <T> T |
loadEntity(BiFunction<BE,E,T> conversion)
Loads the entity from the backend and let's the caller do some conversion on either the backend representation of
the entity or the converted entity (both of these are required even during the loading so no unnecessary work is
done by providing both of the to the caller).
|
protected void |
preUpdate(BE updatedEntity,
U update)
Hook to be run prior to update.
|
void |
update(U u)
Updates the entity.
|
getSingle, isApplicable, mutating, readOnlyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllexistsanyExists, entitiespublic ReadContained(TraversalContext<BE,ResourceType> context)
public ResourceTypes.Multiple getAll(Filter[][] filters)
ResolvingToMultipleThe filters parameter is actually composed of individual sets of filters each of which is applied to the "source" entities. Each set can have multiple filters that are then applied one after another on their intermediate results. This becomes useful when you want to filter by sources having some kind of relationships with other entities and in addition filter on the sources themselves, too. E.g.:
inventory.tenants().getAll(new Filter[][]{{Related.by("myRel"), With.type(ResourceType.class)},
{With.id("asf")}}).entities();
The filter above would first check that the tenants in question have a relationship called "myRel" with some
resource types and then would also check if the tenant has ID "asf".getAll in interface ResolvingToMultiple<ResourceTypes.Multiple>filters - the sets of filters to applypublic ResourceTypes.Single get(String id) throws EntityNotFoundException
ResolvingToSingleget in interface ResolvingToSingle<ResourceTypes.Single,String>id - the identification of sorts of the entity to find in the current traversal positionEntityNotFoundExceptionpublic E entity()
throws EntityNotFoundException,
RelationNotFoundException
ResolvableToSingleentity in interface ResolvableToSingle<E extends AbstractElement<?,U>,U extends AbstractElement.Update>EntityNotFoundException - if there is no entity corresponding to the traversalRelationNotFoundException - if there is no relation corresponding to the traversalprotected <T> T loadEntity(BiFunction<BE,E,T> conversion) throws EntityNotFoundException, RelationNotFoundException
T - the result typeconversion - the conversion function taking the backend entity as well as the model entityEntityNotFoundExceptionRelationNotFoundExceptionpublic void delete()
ResolvableToSingledelete in interface ResolvableToSingle<E extends AbstractElement<?,U>,U extends AbstractElement.Update>public void update(U u)
throws EntityNotFoundException,
RelationNotFoundException
ResolvableToSingleupdate in interface ResolvableToSingle<E extends AbstractElement<?,U>,U extends AbstractElement.Update>u - the update to be appliedEntityNotFoundException - if there is no entity corresponding to the traversalRelationNotFoundException - if there is no relation corresponding to the traversalprotected void cleanup(BE deletedEntity)
Mutator.cleanup(Object, Object) and is called during the delete()
method inside the transaction.deletedEntity - the backend representation of the deleted entityprotected void preUpdate(BE updatedEntity,
U update)
Mutator.preUpdate(Object, Object, AbstractElement.Update) but is not supplied the id object that can be
determined from the updated entity.
By default, this does nothing.
updatedEntity - the backend representation of the updated entityupdate - the update objectpublic Page<E> entities(Pager pager)
entities in interface ResolvableToMany<E extends AbstractElement<?,U>>pager - the pager object describing the subset of the entities to returnprotected <T> Page<T> loadEntities(Pager pager, BiFunction<BE,E,T> conversionFunction)
Note that the conversion function accepts both the backend entity and the converted entity because both of them are required anyway during the loading and thus the function can choose which one to use without any additional conversion cost.
T - the desired target type of the elements of the returned pagepager - the pager specifying the page of the data to loadconversionFunction - the conversion function to convert to the desired target typeCopyright © 2015 Red Hat, Inc.. All rights reserved.