List of usage examples for java.util List set
E set(int index, E element);
From source file:com.haulmont.cuba.gui.CompanionDependencyInjector.java
private List<Field> getAllFields(List<Class> classes) { List<Field> list = new ArrayList<>(); for (Class c : classes) { if (c != Object.class) { for (Field field : c.getDeclaredFields()) { int idx = indexOfFieldWithSameName(list, field); if (idx > -1) list.set(idx, field); else list.add(field);// ww w. j a v a 2 s . com } } } return list; }
From source file:br.com.d4n.ui4entity.mvc.SpringContextConfigurer.java
private void decorateHandlers(List<HandlerMethodReturnValueHandler> handlers) { for (HandlerMethodReturnValueHandler handler : handlers) { if (handlerReturnValueType.equals(handler.getClass())) { HandlerMethodReturnValueHandler decorator = new ValueOptionReturnValueHandler( new ControllerReturnValueHandler(handler, parserEngine)); int index = handlers.indexOf(handler); handlers.set(index, decorator); logger.info("@TODO: Metadata Injecting decorator wired up"); }/*from w ww. ja v a 2s . co m*/ } }
From source file:com.quigley.filesystem.FilesystemPath.java
public FilesystemPath set(int idx, String component) { List<String> elementsCopy = new ArrayList<String>(elements); elementsCopy.set(idx, component); FilesystemPath pathCopy = new FilesystemPath(elementsCopy); pathCopy.isAbsolute = isAbsolute;//from w ww.j a va 2 s . com return pathCopy; }
From source file:com.gmail.gkovalechyn.automaticevents.events.Event.java
private void replaceVariables(List<String>... lists) { for (Map.Entry<String, Variable> entry : vars.entrySet()) { String var = StringUtils.join(entry.getValue().toArgs(), " "); for (List<String> list : lists) { for (int i = 0; i < list.size(); i++) { list.set(i, list.get(i).replaceAll(entry.getKey(), var)); }/*from ww w. jav a2 s.co m*/ } } }
From source file:com.gargoylesoftware.htmlunit.javascript.host.PropertiesTest.java
/** * To be removed once {@link com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollectionTest#typeof()} * is fixed./* w ww. j a v a 2 s. com*/ */ private void removeParentheses(final List<String> list) { for (int i = 0; i < list.size(); i++) { final String string = list.get(i); if (string.endsWith("()")) { list.set(i, string.substring(0, string.length() - 2)); } } }
From source file:com.dshue.web.WebConfiguration.java
@Bean ViewInjectingReturnValueHandler viewInjectingReturnValueHandler() { List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>( this.requestMappingHandlerAdapter.getReturnValueHandlers().getHandlers()); for (HandlerMethodReturnValueHandler handler : handlers) { if (handler instanceof RequestResponseBodyMethodProcessor) { ViewInjectingReturnValueHandler decorator = new ViewInjectingReturnValueHandler(handler); int index = handlers.indexOf(handler); handlers.set(index, decorator); this.requestMappingHandlerAdapter.setReturnValueHandlers(handlers); return decorator; }/*from w ww. j a va 2 s .c om*/ } return null; }
From source file:de.openali.odysseus.chart.ext.base.layer.HoverIndex.java
public synchronized EditInfo findElement(final Point pos) { final com.infomatiq.jsi.Point searchPoint = new com.infomatiq.jsi.Point(pos.x, pos.y); final List<Pair<Polygon, EditInfo>> result = new ArrayList<>(1); result.add(null);//from w ww . j a va2 s . c o m final List<Pair<Polygon, EditInfo>> elements = m_elements; final TIntProcedure receiver = new TIntProcedure() { @Override public boolean execute(final int index) { final Pair<Polygon, EditInfo> element = elements.get(index); result.set(0, element); return false; } }; // REMARK: use snap distance 0, we assume that the given rectangle was already including a 'snap' m_index.nearest(searchPoint, receiver, 0f); final Pair<Polygon, EditInfo> pair = result.get(0); if (pair == null) return null; final Polygon bounds = pair.getLeft(); final com.vividsolutions.jts.geom.Point searchLocation = bounds.getFactory() .createPoint(new Coordinate(pos.x, pos.y)); if (bounds.distance(searchLocation) > 1) return null; /* Exact position was not set during creation of info..., so we set it now */ final EditInfo info = pair.getRight(); return new EditInfo(info.getLayer(), info.getHoverFigure(), info.getEditFigure(), info.getData(), info.getText(), pos); }
From source file:io.gravitee.management.service.impl.PageServiceImpl.java
private void reorderAndSavePages(final Page pageToReorder) throws TechnicalException { final Collection<Page> pages = pageRepository.findByApi(pageToReorder.getApi()); final List<Boolean> increment = asList(true); pages.stream().sorted((o1, o2) -> Integer.compare(o1.getOrder(), o2.getOrder())).forEachOrdered(page -> { try {/*from w ww .j ava 2 s . c o m*/ if (page.equals(pageToReorder)) { increment.set(0, false); page.setOrder(pageToReorder.getOrder()); } else { final int newOrder; final Boolean isIncrement = increment.get(0); if (page.getOrder() < pageToReorder.getOrder()) { newOrder = page.getOrder() - (isIncrement ? 0 : 1); } else if (page.getOrder() > pageToReorder.getOrder()) { newOrder = page.getOrder() + (isIncrement ? 1 : 0); } else { newOrder = page.getOrder() + (isIncrement ? 1 : -1); } page.setOrder(newOrder); } pageRepository.update(page); } catch (final TechnicalException ex) { throw onUpdateFail(page.getId(), ex); } }); }
From source file:de.micromata.genome.gwiki.umgmt.GWikiUserAuthorization.java
private Matcher<String> replaceMatcherRules(GWikiRoleConfig rc, Matcher<String> m) { if (m instanceof EqualsMatcher) { EqualsMatcher<String> em = (EqualsMatcher<String>) m; GWikiRight role = rc.getRoles().get(em.getOther()); if (role != null && role.getDefinitionRule() != null) { return role.getDefinitionRule(); }/*from ww w.jav a 2 s . c o m*/ return m; } if (m instanceof BooleanListMatcher) { BooleanListMatcher<String> bm = (BooleanListMatcher<String>) m; List<Matcher<String>> ml = bm.getMatcherList(); for (int i = 0; i < ml.size(); ++i) { ml.set(i, replaceMatcherRules(rc, ml.get(i))); } return m; } if (m instanceof TreeStateMatcher) { TreeStateMatcher<String> tm = (TreeStateMatcher<String>) m; tm.setNested(replaceMatcherRules(rc, tm.getNested())); } return m; }
From source file:com.gargoylesoftware.htmlunit.source.BrowserVersionFeaturesSource.java
private void rename(final File file, final String oldName, final String newName) throws IOException { final List<String> lines = FileUtils.readLines(file); boolean modified = false; for (int i = 0; i < lines.size(); i++) { String line = lines.get(i); if (line.equals(oldName) || line.contains(oldName + ")") || line.contains(oldName + ",")) { line = line.replace(oldName, newName); lines.set(i, line); modified = true;//from w w w. j a v a2s .co m } } if (modified) { FileUtils.writeLines(file, lines); } }