@Override public Pagination<Account> searchAccounts(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) { final List<Account> results = new LinkedList<Account>(); for (final Account account : accounts) { if ((account.getName() != null && account.getName().contains(searchKey)) || (account.getEmail() != null && account.getEmail().contains(searchKey)) || (account.getExternalKey() != null && account.getExternalKey().contains(searchKey)) || (account.getCompanyName() != null && account.getCompanyName().contains(searchKey))) { results.add(account); } } return DefaultPagination.<Account>build(offset, limit, accounts.size(), results); }
@Test(groups = "fast", description = "Test if Account constructor can accept null values") public void testConstructorAcceptsNullValues() throws Exception { final AccountData accountData = getNullAccountData(); final Account account = new DefaultAccount(UUID.randomUUID(), accountData); Assert.assertNull(account.getExternalKey()); Assert.assertNull(account.getEmail()); Assert.assertNull(account.getName()); Assert.assertNull(account.getFirstNameLength()); Assert.assertNull(account.getCurrency()); Assert.assertEquals(account.getBillCycleDayLocal(), (Integer) 0); Assert.assertNull(account.getPaymentMethodId()); Assert.assertNull(account.getTimeZone()); Assert.assertNull(account.getLocale()); Assert.assertNull(account.getAddress1()); Assert.assertNull(account.getAddress2()); Assert.assertNull(account.getCompanyName()); Assert.assertNull(account.getCity()); Assert.assertNull(account.getStateOrProvince()); Assert.assertNull(account.getCountry()); Assert.assertNull(account.getPostalCode()); Assert.assertNull(account.getPhone()); Assert.assertNull(account.isMigrated()); }
private void checkAccountEquals(final Account finalAccount, final Account delegateAccount) { Assert.assertEquals(finalAccount.getExternalKey(), delegateAccount.getExternalKey()); Assert.assertEquals(finalAccount.getEmail(), delegateAccount.getEmail()); Assert.assertEquals(finalAccount.getName(), delegateAccount.getName()); Assert.assertEquals(finalAccount.getFirstNameLength(), delegateAccount.getFirstNameLength()); Assert.assertEquals(finalAccount.getCurrency(), delegateAccount.getCurrency()); Assert.assertEquals(finalAccount.getBillCycleDayLocal(), delegateAccount.getBillCycleDayLocal()); Assert.assertEquals(finalAccount.getPaymentMethodId(), delegateAccount.getPaymentMethodId()); Assert.assertEquals(finalAccount.getTimeZone(), delegateAccount.getTimeZone()); Assert.assertEquals(finalAccount.getLocale(), delegateAccount.getLocale()); Assert.assertEquals(finalAccount.getAddress1(), delegateAccount.getAddress1()); Assert.assertEquals(finalAccount.getAddress2(), delegateAccount.getAddress2()); Assert.assertEquals(finalAccount.getCompanyName(), delegateAccount.getCompanyName()); Assert.assertEquals(finalAccount.getCity(), delegateAccount.getCity()); Assert.assertEquals(finalAccount.getStateOrProvince(), delegateAccount.getStateOrProvince()); Assert.assertEquals(finalAccount.getCountry(), delegateAccount.getCountry()); Assert.assertEquals(finalAccount.getPostalCode(), delegateAccount.getPostalCode()); Assert.assertEquals(finalAccount.getPhone(), delegateAccount.getPhone()); Assert.assertEquals(finalAccount.getNotes(), delegateAccount.getNotes()); Assert.assertEquals(finalAccount.isMigrated(), delegateAccount.isMigrated()); }
accountData.setName(name != null ? name : currentAccount.getName()); final Integer firstNameLength = this.firstNameLength != null ? this.firstNameLength : currentAccount.getFirstNameLength(); if (firstNameLength != null) {
@RequestMapping(value="/availability", method=RequestMethod.GET) public @ResponseBody AvailabilityStatus getAvailability(@RequestParam String name) { for (Account a : accounts.values()) { if (a.getName().equals(name)) { return AvailabilityStatus.notAvailable(name); } } return AvailabilityStatus.available(); }
class Account implements Comparable<Account> { [...] @Override public int compareTo(Account another) { return name.compareTo(another.getName()); } }
boolean found = false; for (int index = 0; index < dataStore.size(); index++) { Account datum = (Account)dataStore.get(index); if (str.equals(datum.getName())) { name = datum.getName(); textArea.setText("Found Account for " + name); found = true; } } if(!found){ textArea.setText("No Accounts found!"); }
for( Account account : accountList ) { String name = account.getName(); // .. do whatever you need to for each account... }
return FluentIterable.from(allAccounts).transform(new Function<Account,String>(){ public String apply(Account account){return account.getName();} }).toImmutableList()
public class AccountRenderer extends DefaultListCellRenderer { private static final long serialVersionUID = 1L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { Account entry = (Account) value; renderer.setText(entry.getName()); } return renderer; }
void choose(String name) { Account found = null; for (Account acc : accounts) { if (acc.getName().equals(name)) { found = acc; } } if (found) { selected = found; } else { System.out.println(name + " not found in list."); }
Query query= session.createQuery("from Account where name=?"); Account user=(Account)query.setString(0,user.getName()).uniqueResult(); if(user!=null){ //Do whatever you want to do }else{ //Insert user }
Facebook facebook = new FacebookFactory().getInstance(); facebook.setOAuthAppId(Constants.FACEBOOK_APP_ID, Constants.FACEBOOK_APP_SECRET); facebook.setOAuthAccessToken(new AccessToken(longToken)); try { String pageToken = null; for (Account a : facebook.getAccounts()) { if (a.getName().toLowerCase().contains("nameOfPage")) { pageToken = a.getAccessToken(); } }
public int UpdateAcc(Account acc) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues cv = new ContentValues(); cv.put(colName, acc.getName()); cv.put(colScore, acc.getScore()); return db.update(myTable, cv, colID + "=?", new String[]{params}); }
public class AccountTest { public static void main(String[] args) { Account account1 = new Account("Jane Green", 50.00); Account account2 = new Account("John Blue", -7.53); displayAccount(account1); ... } public static void displayAccount(Account accountToDisplay) { System.out.printf("%s balance: $%.2f%n", accountToDisplay.getName(), accountToDisplay.getBalance()); }
@Override public Pagination<Account> searchAccounts(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) { final List<Account> results = new LinkedList<Account>(); for (final Account account : accounts) { if ((account.getName() != null && account.getName().contains(searchKey)) || (account.getEmail() != null && account.getEmail().contains(searchKey)) || (account.getExternalKey() != null && account.getExternalKey().contains(searchKey)) || (account.getCompanyName() != null && account.getCompanyName().contains(searchKey))) { results.add(account); } } return DefaultPagination.<Account>build(offset, limit, accounts.size(), results); }