Ejemplo n.º 1
0
 /**
  * Makes a name distinct from other names which have already been used, adds it to the list, and
  * returns it.
  *
  * @param name Suggested name, may not be unique
  * @param nameList Collection of names already used
  * @param suggester Base for name when input name is null
  * @return Unique name
  */
 public static String uniquify(String name, Set<String> nameList, Suggester suggester) {
   if (name != null) {
     if (nameList.add(name)) {
       return name;
     }
   }
   final String originalName = name;
   for (int j = 0; ; j++) {
     name = suggester.apply(originalName, j, nameList.size());
     if (nameList.add(name)) {
       return name;
     }
   }
 }
Ejemplo n.º 2
0
  //
  // ONE TIME ADD CONTACTS
  //
  //
  private static void oneTimeAddContacts() {

    String firstNameLastName = "";
    String saltS = "";
    String ssnhash = "";

    Set<String> unionSet = new HashSet<>();
    unionSet.addAll(set1);
    unionSet.addAll(set2);

    String strArrr[] = unionSet.toArray(new String[unionSet.size()]);

    int numEntries = saltHashMap.size();

    for (int i = 0; i < numEntries; i++) {
      firstNameLastName = strArrr[i];
      saltS = saltHashMap.get(strArrr[i]);
      ssnhash = hashedssnHashMap.get(strArrr[i]);

      Map<String, AttributeValue> item = newContactItem(firstNameLastName, saltS, ssnhash);
      PutItemRequest putItemRequest = new PutItemRequest("contacts-table", item);
      PutItemResult putItemResult = dynamoDB.putItem(putItemRequest);
    }
  }