List of usage examples for java.util List indexOf
int indexOf(Object o);
From source file:natalia.dymnikova.cluster.scheduler.impl.SetFlowFactory.java
private Optional<Address> previousStageContainerAddress(final List<StageContainer> resolvedStages, final StageContainer stageContainer, final List<Optional<Address>> address) { return address.get(resolvedStages.indexOf(resolvedStages.stream() .filter(stage -> stage.previous.contains(stageContainer)).findFirst().get())); }
From source file:quanlyhocvu.api.mongodb.DAO.DiemDAO.java
public boolean updateDiemSo(String loaiDiem, String idDiem, Float diemCu, Float diemMoi) { DiemDTO dto = getDiemById(idDiem);//from w ww . jav a 2 s . com if (loaiDiem == "DiemKTMieng") { List<Float> tempList = dto.getListDiemKTMieng(); int index = tempList.indexOf(diemCu); tempList.set(index, diemMoi); dto.setListDiemKTMieng(tempList); } else if (loaiDiem == "DiemKT15") { List<Float> tempList = dto.getListDiemKT15(); int index = tempList.indexOf(diemCu); tempList.set(index, diemMoi); dto.setListDiemKTMieng(tempList); } else if (loaiDiem == "DiemKT15") { List<Float> tempList = dto.getListDiemKT1Tiet(); int index = tempList.indexOf(diemCu); tempList.set(index, diemMoi); dto.setListDiemKTMieng(tempList); } else if (loaiDiem == "DiemGiuaKy") { dto.setDiemGiuaKy(diemMoi); } else if (loaiDiem == "DiemCuoiKy") { dto.setDiemCuoiKy(diemMoi); } update(dto); return true; }
From source file:org.wallerlab.yoink.adaptive.smooth.DASWeightFactors.java
private double getMMLambdaMinimum(List<Double> lambda, List<Integer> bufferIndices, Set<Integer> mmSet, double lambdaMMMin) { for (Integer molecularIndex : mmSet) { int index = bufferIndices.indexOf(molecularIndex); if (lambdaMMMin > lambda.get(index)) { lambdaMMMin = lambda.get(index); }// w w w . j av a 2 s .c om } return lambdaMMMin; }
From source file:org.wallerlab.yoink.adaptive.smooth.DASWeightFactors.java
private double getQMLambdaMaximum(List<Double> lambda, List<Integer> bufferIndices, List<Integer> qmSet, double lambdaQMMax) { for (Integer molecularIndex : qmSet) { int index = bufferIndices.indexOf(molecularIndex); if (lambdaQMMax < lambda.get(index)) { lambdaQMMax = lambda.get(index); }//w w w.j a v a2 s . c o m } return lambdaQMMax; }
From source file:org.wallride.web.controller.admin.user.UserDescribeController.java
@RequestMapping public String describe(@PathVariable String language, @RequestParam long id, String query, Model model) { User user = userService.getUserById(id); if (user == null) { throw new HttpNotFoundException(); }//from w w w.ja va2s .c o m MutablePropertyValues mpvs = new MutablePropertyValues( UriComponentsBuilder.newInstance().query(query).build().getQueryParams()); for (Iterator<PropertyValue> i = mpvs.getPropertyValueList().iterator(); i.hasNext();) { PropertyValue pv = i.next(); boolean hasValue = false; for (String value : (List<String>) pv.getValue()) { if (StringUtils.hasText(value)) { hasValue = true; break; } } if (!hasValue) { i.remove(); } } BeanWrapperImpl beanWrapper = new BeanWrapperImpl(new UserSearchForm()); beanWrapper.setConversionService(conversionService); beanWrapper.setPropertyValues(mpvs, true, true); UserSearchForm form = (UserSearchForm) beanWrapper.getWrappedInstance(); List<Long> ids = userService.getUserIds(form.toUserSearchRequest()); if (!CollectionUtils.isEmpty(ids)) { int index = ids.indexOf(user.getId()); if (index < ids.size() - 1) { Long next = ids.get(index + 1); model.addAttribute("next", next); } if (index > 0) { Long prev = ids.get(index - 1); model.addAttribute("prev", prev); } } model.addAttribute("user", user); model.addAttribute("query", query); return "user/describe"; }
From source file:de.widone.web.page.home.HomePage.java
@Override public void onEvent(IEvent<?> event) { super.onEvent(event); if (event.getPayload() instanceof ChangeTaskPositionEvent) { ChangeTaskPositionEvent changePosEvent = (ChangeTaskPositionEvent) event.getPayload(); Task task = changePosEvent.getTask(); List<Task> tasks = changePosEvent.getTaskList().getTasks(); Integer newPos = changePosEvent.getNewPosition(); Integer oldPos = tasks.indexOf(task); if (newPos < 0 || newPos >= tasks.size()) { return; }//w w w. j a v a2 s . c o m tasks.remove(task); List<Task> sublist = new ArrayList<Task>(tasks.subList(newPos, tasks.size())); tasks.removeAll(sublist); tasks.add(task); tasks.addAll(sublist); ((IModel<TaskList>) getDefaultModel()).setObject(taskListService.update(changePosEvent.getTaskList())); } else if (event.getPayload() instanceof DoneTaskEvent) { DoneTaskEvent deleteTaskEvent = (DoneTaskEvent) event.getPayload(); TaskList taskList = deleteTaskEvent.getTaskList(); taskList.getTasks().remove(deleteTaskEvent.getTask()); ((IModel<TaskList>) getDefaultModel()).setObject(taskListService.update(taskList)); } else if (event.getPayload() instanceof DeleteTaskEvent) { DeleteTaskEvent deleteTaskEvent = (DeleteTaskEvent) event.getPayload(); TaskList taskList = deleteTaskEvent.getTaskList(); taskList.getTasks().remove(deleteTaskEvent.getTask()); ((IModel<TaskList>) getDefaultModel()).setObject(taskListService.update(taskList)); } else if (event.getPayload() instanceof NewTaskEvent) { NewTaskEvent newTaskEvent = (NewTaskEvent) event.getPayload(); ((IModel<TaskList>) getDefaultModel()).setObject(taskListService.addTaskToTaskList( newTaskEvent.getNewTask(), ((IModel<TaskList>) getDefaultModel()).getObject())); } else if (event.getPayload() instanceof NewTaskListEvent) { NewTaskListEvent newTaskListEvent = (NewTaskListEvent) event.getPayload(); User user = userService.initTaskLists(new CurrentUserModel().getObject()); user.getTaskLists().add(newTaskListEvent.getNewTaskList()); userService.update(user); } }
From source file:org.wallride.web.controller.guest.page.PageDescribeController.java
protected ModelAndView createModelAndView(Page page) { ModelAndView modelAndView = new ModelAndView(); List<Long> ids = pageService.getPageIds(new PageSearchRequest().withStatus(Post.Status.PUBLISHED)); if (!CollectionUtils.isEmpty(ids)) { int index = ids.indexOf(page.getId()); if (index < ids.size() - 1) { Page next = pageService.getPageById(ids.get(index + 1)); modelAndView.addObject("next", next); }//w ww .j ava 2s . c o m if (index > 0) { Page prev = pageService.getPageById(ids.get(index - 1)); modelAndView.addObject("prev", prev); } } modelAndView.addObject("page", page); modelAndView.setViewName("page/describe"); return modelAndView; }
From source file:com.manydesigns.portofino.reflection.TableAccessor.java
private void setupKeyColumns(List<Column> columns, List<Column> pkColumns) { int i = 0;// w ww .j a v a 2 s .co m for (Column current : pkColumns) { int index = columns.indexOf(current); ColumnAccessor columnAccessor = columnAccessors[index]; keyColumnAccessors[i] = columnAccessor; i++; } }
From source file:at.ac.tuwien.qse.sepm.gui.FullscreenWindow.java
public void present(List<Photo> photos, Photo initial) { this.photos = photos; activeIndex = photos.indexOf(initial); if (activeIndex < 0) { activeIndex = 0;//from w w w. j a v a 2s. com } loadImage(); stage.setFullScreen(true); stage.show(); }
From source file:org.shredzone.cilla.admin.page.gallery.GalleryBean.java
/** * Moves a picture within the picture list. * * @param picture/*from ww w .ja v a 2s. c om*/ * {@link PictureDto} to be moved * @param relative * Relative new position of the picture */ public void moveImage(PictureDto picture, int relative) { synchronized (this) { List<PictureDto> list = section.getPictures(); int current = list.indexOf(picture); if (current < 0) { return; } int target = current + relative; if (target < 0) { // Item moved out from the left, wrap around PictureDto wrap = list.remove(current); list.add(list.size() + 1 + target, wrap); } else if (target >= list.size()) { // Item moved out from the right, wrap around PictureDto wrap = list.remove(current); list.add(target - list.size() - 1, wrap); } else { // No wrap-around: just swap the items PictureDto swap = list.get(target); list.set(target, picture); list.set(current, swap); } } }