List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:com.evermal.xtractor.MaintenanceClassifierWordMatcher.java
private HashSet<String> correctiveWords() { HashSet<String> words = new HashSet<String>(); words.add("bug"); words.add("fixes"); words.add("LUCENE"); words.add("SOLR"); words.add("bugfix"); words.add("correction"); words.add("merge"); return words; }
From source file:ProductosFacadeTest.java
@Test public void almacenarProductosTest() { try {// w w w . j a va 2 s . c o m Producto producto1 = new Producto("Papa criolla", 30, false); Producto producto2 = new Producto("Tomate", 10, true); Producto producto3 = new Producto("Zanahoria", 15, false); Producto producto4 = new Producto("Cebolla", 20, false); Producto producto5 = new Producto("Patilla", 5, true); pf.saveProducto(producto1); pf.saveProducto(producto2); pf.saveProducto(producto3); pf.saveProducto(producto4); pf.saveProducto(producto5); List<Producto> listaProd = pf.getProductos(); // HashSet<Producto> prodAlmacenados = new HashSet<>(); prodAlmacenados.add(producto1); prodAlmacenados.add(producto2); prodAlmacenados.add(producto3); prodAlmacenados.add(producto4); prodAlmacenados.add(producto5); //assertTrue("Se esperaba un grupo de tamao diferente de objetos persistentes", listaProd.size()==prodAlmacenados.size()); // for (Producto p1 : prodAlmacenados) { boolean existsProd = false; for (int i = 0; i < listaProd.size() && !existsProd; i++) { Producto p2 = listaProd.get(i); existsProd = p1.getNombre().equals(p2.getNombre()) && p1.getDuracion() == p2.getDuracion() && p1.isRefrigeracion() == p2.isRefrigeracion(); } assertTrue("No se encontro un producto que debio estar persistente", existsProd); } } catch (OperationFailedException ex) { Logger.getLogger(ProductosFacadeTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:thingynet.hierarchy.HierarchyTest.java
@Test public void getDescendantsShouldReturnExpectedHierarchies() { Hierarchy parent = hierarchyService.createRoot(PARENT, null); Hierarchy child = hierarchyService.createChild(parent, CHILD, null); Hierarchy sibling = hierarchyService.createChild(parent, SIBLING, null); Hierarchy grandChild = hierarchyService.createChild(child, GRAND_CHILD, null); Hierarchy greatGrandChild = hierarchyService.createChild(grandChild, GREAT_GRAND_CHILD, null); Hierarchy other = hierarchyService.createRoot(OTHER, null); hierarchyService.createChild(other, CHILD, null); HashSet<String> expectedIds = new HashSet<>(); expectedIds.add(child.getPath()); expectedIds.add(sibling.getPath());/*from w ww. j av a 2 s .c o m*/ expectedIds.add(grandChild.getPath()); expectedIds.add(greatGrandChild.getPath()); Iterable<Hierarchy> actual = hierarchyService.getDescendants(parent); while (actual.iterator().hasNext()) { Hierarchy descendant = actual.iterator().next(); assertThat(expectedIds.remove(descendant.getPath()), is(true)); } assertThat(expectedIds.size(), is(0)); }
From source file:com.evermal.xtractor.MaintenanceClassifierWordMatcher.java
private HashSet<String> featureAdditionWords() { HashSet<String> words = new HashSet<String>(); words.add("initial"); words.add("spirit"); words.add("version"); words.add("checkin"); words.add("merged"); words.add("create"); words.add("revision"); words.add("types"); return words; }
From source file:dhbw.clippinggorilla.objects.user.UserUtils.java
/** * Returns all Clipping sending times for all users * * @return The Times for all users//from w w w . j ava2 s . c om */ public static Map<User, Set<LocalTime>> getAllClippingSendTimesForAllUsers() { String sql = "SELECT * FROM " + Tables.USER_CLIPPING_TIMES + " ORDER BY " + Columns.USER_ID; Map<User, Set<LocalTime>> allClippingTimes = new HashMap<>(); try { Statement statement = Database.getConnection().createStatement(); ResultSet result = statement.executeQuery(sql); while (result.next()) { User user = getUser(result.getInt(Columns.USER_ID)); LocalTime userTime = LocalTime.parse(result.getString(Columns.CLIPPING_TIME)); if (allClippingTimes.containsKey(user)) { allClippingTimes.get(user).add(userTime); } else { HashSet<LocalTime> userTimes = new HashSet<>(); userTimes.add(userTime); allClippingTimes.put(user, userTimes); } } } catch (SQLException ex) { Log.warning("Sql failed: getAllClippingTime", ex); } return allClippingTimes; }
From source file:com.evermal.xtractor.MaintenanceClassifierWordMatcher.java
private HashSet<String> perfectiveWords() { HashSet<String> words = new HashSet<String>(); words.add("package"); words.add("reorganized"); words.add("nuke"); words.add("major"); words.add("refactoring"); words.add("cleanup"); words.add("removed"); words.add("moved"); words.add("directory"); return words; }
From source file:cz.fi.muni.pa165.library.web.LoanController.java
@RequestMapping(value = "/loan/addloan/member", method = RequestMethod.POST) public String addloanstep1(@ModelAttribute SearchModel search, RedirectAttributes redirectAttributes, @RequestParam("dateto") String dateto) { if (search.getSearch() == null) { redirectAttributes.addFlashAttribute("error", "validationmissing"); return "redirect:/loan/addloan"; }// ww w . j a v a 2s. c om LoanDTO loan = new LoanDTO(); loan.setReturned(Boolean.FALSE); loan.setDescription("description"); loan.setFromDate(new Date()); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); Date date; try { date = formatter.parse(dateto); } catch (ParseException e) { redirectAttributes.addFlashAttribute("error", "wrongdate"); return "redirect:/loan/addloan"; } loan.setToDate(date); if (loan.getFromDate().after(date)) { redirectAttributes.addFlashAttribute("error", "wrongdate"); return "redirect:/loan/addloan"; } List<PrintedBookDTO> pbooks = pbookService .findPrintedBookByState(bookService.findBookById(Long.parseLong(search.getBook())), Boolean.FALSE); if (pbooks.isEmpty()) { redirectAttributes.addFlashAttribute("error", "nofreebook"); return "redirect:/loan/addloan"; } PrintedBookDTO pbook = pbooks.get(0); loan.setPrintedBook(pbook); MemberDTO member = memberService.findMemberByIdMember(Long.parseLong(search.getSearch(), 10)); loan.setMember(member); pbook.setLoan(loan); pbook.setState(Boolean.TRUE); loanService.insertLoan(loan); pbookService.updatePrintedBook(pbook); HashSet set = new HashSet(); set.add(loan); member.setLoans(set); memberService.updateMember(member); return "redirect:/loan/listloans"; }
From source file:org.osiam.resources.converter.ExtensionConverter.java
@Override public Set<Extension> toScim(Set<ExtensionFieldValueEntity> entity) { Map<String, Extension.Builder> extensionMap = new HashMap<>(); for (ExtensionFieldValueEntity fieldValueEntity : checkNotNull(entity)) { String urn = fieldValueEntity.getExtensionField().getExtension().getUrn(); Extension.Builder extensionBuilder; if (extensionMap.containsKey(urn)) { extensionBuilder = extensionMap.get(urn); } else {/* w w w. j a v a 2 s . c o m*/ extensionBuilder = new Extension.Builder(urn); extensionMap.put(urn, extensionBuilder); } ExtensionFieldType<?> type = fieldValueEntity.getExtensionField().getType(); if (type == null) { // If this is ever true, something went very, very wrong. throw new IllegalArgumentException("The ExtensionField type can't be null"); } String value = fieldValueEntity.getValue(); if (type == ExtensionFieldType.INTEGER || type == ExtensionFieldType.DECIMAL) { value = numberPadder.unpad(value); } String name = fieldValueEntity.getExtensionField().getName(); addField(extensionBuilder, type, name, value); } HashSet<Extension> extensions = new HashSet<>(); for (Extension.Builder builder : extensionMap.values()) { extensions.add(builder.build()); } return extensions; }
From source file:com.thoughtworks.go.plugin.configrepo.contract.CREnvironmentVariable.java
public String validateNameUniqueness(HashSet<String> keys) { if (keys.contains(this.getName())) return String.format("Environment variable %s defined more than once", this.getName()); else/*from ww w .j a v a 2s . com*/ keys.add(this.getName()); return null; }
From source file:annis.sqlgen.AnnotateSqlGenerator.java
@Override public Set<String> whereConditions(QueryData queryData, List<QueryNode> alternative, String indent) { TableAccessStrategy tables = tables(null); StringBuilder sb = new StringBuilder(); // restrict node table to corpus list List<Long> corpusList = queryData.getCorpusList(); if (corpusList != null && !corpusList.isEmpty()) { sb.append(indent);//from ww w.ja va 2 s . c om sb.append(tables.aliasedColumn(NODE_TABLE, "toplevel_corpus")); sb.append(" IN ("); sb.append(StringUtils.join(corpusList, ", ")); sb.append(") AND\n"); if (!tables.isMaterialized(RANK_TABLE, NODE_TABLE)) { sb.append(indent); sb.append(tables.aliasedColumn(RANK_TABLE, "toplevel_corpus")); sb.append(" IN ("); sb.append(StringUtils.join(corpusList, ", ")); sb.append(") AND\n"); } } String overlap = CommonAnnotateWithClauseGenerator.overlapForOneRange(indent + TABSTOP, "solutions.\"min\"", "solutions.\"max\"", "solutions.text", "solutions.corpus", tables); sb.append(overlap); sb.append("\n"); // corpus constriction sb.append(" AND\n"); sb.append(indent).append(TABSTOP); sb.append(tables.aliasedColumn(CORPUS_TABLE, "id")); sb.append(" = "); sb.append(tables.aliasedColumn(NODE_TABLE, "corpus_ref")); HashSet<String> result = new HashSet<String>(); result.add(sb.toString()); return result; }