org.springframework.samples.petclinic.model.BaseEntity Java Examples

The following examples show how to use org.springframework.samples.petclinic.model.BaseEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityUtils.java    From spring-graalvm-native with Apache License 2.0 5 votes vote down vote up
/**
 * Look up the entity of the given class with the given id in the given collection.
 * @param entities the collection to search
 * @param entityClass the entity class to look up
 * @param entityId the entity id to look up
 * @return the found entity
 * @throws ObjectRetrievalFailureException if the entity was not found
 */
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
		throws ObjectRetrievalFailureException {
	for (T entity : entities) {
		if (entity.getId() == entityId && entityClass.isInstance(entity)) {
			return entity;
		}
	}
	throw new ObjectRetrievalFailureException(entityClass, entityId);
}
 
Example #2
Source File: EntityUtils.java    From spring-init with Apache License 2.0 5 votes vote down vote up
/**
 * Look up the entity of the given class with the given id in the given collection.
 *
 * @param entities    the collection to search
 * @param entityClass the entity class to look up
 * @param entityId    the entity id to look up
 * @return the found entity
 * @throws ObjectRetrievalFailureException if the entity was not found
 */
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
    throws ObjectRetrievalFailureException {
    for (T entity : entities) {
        if (entity.getId() == entityId && entityClass.isInstance(entity)) {
            return entity;
        }
    }
    throw new ObjectRetrievalFailureException(entityClass, entityId);
}
 
Example #3
Source File: EntityUtils.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
/**
 * Look up the entity of the given class with the given id in the given collection.
 *
 * @param entities    the collection to search
 * @param entityClass the entity class to look up
 * @param entityId    the entity id to look up
 * @return the found entity
 * @throws ObjectRetrievalFailureException if the entity was not found
 */
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
    throws ObjectRetrievalFailureException {
    for (T entity : entities) {
        if (entity.getId() == entityId && entityClass.isInstance(entity)) {
            return entity;
        }
    }
    throw new ObjectRetrievalFailureException(entityClass, entityId);
}
 
Example #4
Source File: EntityUtils.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
/**
 * Look up the entity of the given class with the given id in the given collection.
 *
 * @param entities    the collection to search
 * @param entityClass the entity class to look up
 * @param entityId    the entity id to look up
 * @return the found entity
 * @throws ObjectRetrievalFailureException if the entity was not found
 */
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
    throws ObjectRetrievalFailureException {
    for (T entity : entities) {
        if (entity.getId() == entityId && entityClass.isInstance(entity)) {
            return entity;
        }
    }
    throw new ObjectRetrievalFailureException(entityClass, entityId);
}
 
Example #5
Source File: EntityUtils.java    From docker-workflow-plugin with MIT License 3 votes vote down vote up
/**
 * Look up the entity of the given class with the given id in the given collection.
 *
 * @param entities    the collection to search
 * @param entityClass the entity class to look up
 * @param entityId    the entity id to look up
 * @return the found entity
 * @throws ObjectRetrievalFailureException
 *          if the entity was not found
 */
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
        throws ObjectRetrievalFailureException {
    for (T entity : entities) {
        if (entity.getId().intValue() == entityId && entityClass.isInstance(entity)) {
            return entity;
        }
    }
    throw new ObjectRetrievalFailureException(entityClass, entityId);
}
 
Example #6
Source File: EntityUtils.java    From audit4j-demo with Apache License 2.0 3 votes vote down vote up
/**
 * Look up the entity of the given class with the given id in the given collection.
 *
 * @param entities    the collection to search
 * @param entityClass the entity class to look up
 * @param entityId    the entity id to look up
 * @return the found entity
 * @throws ObjectRetrievalFailureException
 *          if the entity was not found
 */
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
        throws ObjectRetrievalFailureException {
    for (T entity : entities) {
        if (entity.getId().intValue() == entityId && entityClass.isInstance(entity)) {
            return entity;
        }
    }
    throw new ObjectRetrievalFailureException(entityClass, entityId);
}