public static class BaseMetricTypes.Single<BE> extends Traversal<BE,E> implements MetricTypes.Single
| Constructor and Description |
|---|
Single(TraversalContext<BE,MetricType> 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.
|
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).
|
Metrics.Read |
metrics() |
protected void |
preUpdate(BE updatedEntity,
U update)
Hook to be run prior to update.
|
Relationships.ReadWrite |
relationships() |
Relationships.ReadWrite |
relationships(Relationships.Direction direction) |
void |
update(U u)
Updates the entity.
|
getSingle, isApplicable, mutating, readOnlyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdelete, entity, exists, updaterelationships, relationshipsanyExists, entitiespublic Single(TraversalContext<BE,MetricType> context)
public Metrics.Read metrics()
public Relationships.ReadWrite relationships()
public Relationships.ReadWrite relationships(Relationships.Direction direction)
public 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.