/** * Get am Unique Identifier (UID) of the cloudlet. * * @return The UID */ public String getUid() { return getUserId() + "-" + getCloudletId(); }
/** * Finds the index of a ResCloudlet inside a list. * This method needs a combination of Cloudlet Id * and User Id because each Cloud User might have exactly the same Cloudlet Id. * * @param cloudletId a Cloudlet Id * @param userId an User Id * @param list the list of ResCloudlets * @return the index in this list of the first occurrence of the specified Cloudlet, or * <code>-1</code> if the list does not contain the Cloudlet. * @pre cloudletId >= 0 * @pre userId >= 0 * @post $none */ public static <T extends ResCloudlet> int indexOf(List<T> list, int cloudletId, int userId) { int i = 0; for (T rcl : list) { if (rcl.getCloudletId() == cloudletId && rcl.getUserId() == userId) { return i; } i++; } return -1; }
/** * Gets a {@link ResCloudlet} with a given id and owned by a given user. * This method needs a combination of Cloudlet Id and User Id because * each Cloud User might have exactly the same Cloudlet Id. * * @param cloudletId a Cloudlet Id * @param userId an User Id * @param list the list of ResCloudlet * @return a Cloudlet or null if not found * @pre cloudletId >= 0 * @pre userId >= 0 * @post $none * * @todo The second phrase of the class documentation is not clear. */ public static <T extends ResCloudlet> ResCloudlet getByIdAndUserId( List<T> list, int cloudletId, int userId) { for (T rcl : list) { if (rcl.getCloudletId() == cloudletId && rcl.getUserId() == userId) { return rcl; } } return null; }