List<Contact> contacts = new ArrayList<Contact>(); // Fill it. // Now sort by address instead of name (default). Collections.sort(contacts, new Comparator<Contact>() { public int compare(Contact one, Contact other) { return one.getAddress().compareTo(other.getAddress()); } });
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(Contact) */ public DefaultContact(final Contact object) { super(object); if (object != null) { hoursOfService = object.getHoursOfService(); contactInstructions = object.getContactInstructions(); if (object instanceof DefaultContact) { final DefaultContact c = (DefaultContact) object; phones = copyCollection(c.getPhones(), Telephone.class); addresses = copyCollection(c.getAddresses(), Address.class); onlineResources = copyCollection(c.getOnlineResources(), OnlineResource.class); contactType = c.getContactType(); } else { phones = singleton(object.getPhone(), Telephone.class); addresses = singleton(object.getAddress(), Address.class); onlineResources = singleton(object.getOnlineResource(), OnlineResource.class); } } }
address = contact.getAddress(); resource = contact.getOnlineResource();
/** * Validates the given contact information. * * @param object the object to validate, or {@code null}. * * @since 3.1 */ public void validate(final Contact object) { if (object == null) { return; } for (final Telephone e : toArray(Telephone.class, object.getPhones())) { validate(e); } for (final Address e : toArray(Address.class, object.getAddresses())) { validate(e); } for (final OnlineResource e : toArray(OnlineResource.class, object.getOnlineResources())) { validate(e); } for (final InternationalString e : toArray(InternationalString.class, object.getHoursOfService())) { container.validate(e); } validateOptional(object.getContactInstructions()); }
/** * Tests {@link Store#getMetadata()}. * * @throws DataStoreException if en error occurred while reading the XML. */ @Test public void testMetadata() throws DataStoreException { final Metadata metadata; try (Store store = new Store(null, new StorageConnector(new StringReader(XML)))) { metadata = store.getMetadata(); assertSame("Expected cached value.", metadata, store.getMetadata()); } final ResponsibleParty resp = getSingleton(metadata.getContacts()); final Contact contact = resp.getContactInfo(); final OnlineResource resource = contact.getOnlineResource(); assertEquals(Locale.ENGLISH, metadata.getLanguage()); if (!REGRESSION) assertEquals(CharacterSet.UTF_8, metadata.getCharacterSet()); assertEquals(Role.PRINCIPAL_INVESTIGATOR, resp.getRole()); assertEquals("Apache SIS", String.valueOf(resp.getOrganisationName())); assertEquals("http://sis.apache.org", String.valueOf(resource.getLinkage())); assertEquals(OnLineFunction.INFORMATION, resource.getFunction()); } }
int itemsBeforeUpdate = 10; public void onBindViewHolder(MyViewHolder holder, final int position) { Contact c = List1.get(position); holder.text_rating.setText("Rating "+c.getRating()); holder.text_address.setText(c.getAddress()); if(List1.size() - position <10){ // Do your Volley Request, add response to the list and notify the adapter that the data changed } }
/** * Tests XML unmarshalling for a metadata version. * The version is not specified since it should be detected automatically. * * @param file file containing the metadata to unmarshal. */ private void testUnmarshalling(final String file) throws JAXBException { final DefaultCitation c = unmarshalFile(DefaultCitation.class, file); assertTitleEquals("title", "Fight against poverty", c); final CitationDate date = getSingleton(c.getDates()); assertEquals("date", date.getDate(), TestUtilities.date("2015-10-17 00:00:00")); assertEquals("dateType", DateType.valueOf("adopted"), date.getDateType()); assertEquals("presentationForm", PresentationForm.valueOf("physicalObject"), getSingleton(c.getPresentationForms())); final Iterator<ResponsibleParty> it = c.getCitedResponsibleParties().iterator(); final Contact contact = assertResponsibilityEquals(Role.ORIGINATOR, "Maid Marian", it.next()); assertEquals("Contact instruction", "Send carrier pigeon.", String.valueOf(contact.getContactInstructions())); final OnlineResource resource = contact.getOnlineResource(); assertEquals("Resource name", "IP over Avian Carriers", String.valueOf(resource.getName())); assertEquals("Resource description", "High delay, low throughput, and low altitude service.", String.valueOf(resource.getDescription())); assertEquals("Resource linkage", "https://tools.ietf.org/html/rfc1149", String.valueOf(resource.getLinkage())); assertEquals("Resource function", OnLineFunction.OFFLINE_ACCESS, resource.getFunction()); // Thanks to xlink:href, the Contact shall be the same instance as above. assertSame("contact", contact, assertResponsibilityEquals(Role.valueOf("funder"), "Robin Hood", it.next())); assertFalse(it.hasNext()); }
Set<String> phoneNumbers = new HashSet<>(); for (Contact c : phone_contacts) { phoneNumbers.add(c.getPhone()); } Set<String> overlappingNumbers = new HashSet<>(); for (Contact registered : registered_users) { if (phoneNumbers.contains(registered.getPhone())) { overlappingNumbers.add(registered.getPhone()); } } List<Contact> common_contacts = new ArrayList<>(); for (Contact contact : phone_contacts) { if (overlappingNumbers.contains(contact.getPhone())) { common_contacts.add(contact); } } }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(Contact) */ public DefaultContact(final Contact object) { super(object); if (object != null) { hoursOfService = object.getHoursOfService(); contactInstructions = object.getContactInstructions(); if (object instanceof DefaultContact) { final DefaultContact c = (DefaultContact) object; phones = copyCollection(c.getPhones(), Telephone.class); addresses = copyCollection(c.getAddresses(), Address.class); onlineResources = copyCollection(c.getOnlineResources(), OnlineResource.class); contactType = c.getContactType(); } else { phones = singleton(object.getPhone(), Telephone.class); addresses = singleton(object.getAddress(), Address.class); onlineResources = singleton(object.getOnlineResource(), OnlineResource.class); } } }
address = contact.getAddress(); resource = contact.getOnlineResource();
OnlineResource resource = responsible.getContactInfo().getOnlineResource(); assertEquals("http://www.epsg.org", resource.getLinkage().toString()); assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
Map<Long, String> hm = new HashMap<>(); final Contact c = ...; Optional<Long> idOpt = hm.entrieSet().stream() .filter((e) -> e.getValue().equals(c.getPhone()) .map((e2) -> e2.getKey()) .findAny(); idOpt.ifPresent(id -> System.out.println(id)); long id = idOpt.orElse(-1L);
Collections.sort(contacts, new Comparator<Contact>() { public int compare(Contact one, Contact other) { return one.getAddress().compareTo(other.getAddress()); } });
final OnlineResource onlineResource = contact.getContactInfo().getOnlineResource(); assertNotNull("onlineResource", onlineResource); assertEquals("organisationName", "Apache SIS", contact.getOrganisationName().toString());
for(String s:r.getContactInfo().getAddress().getElectronicMailAddresses()) { metadata.add("CitedResponsiblePartyEMail ",s.toString());
for(String s:r.getContactInfo().getAddress().getElectronicMailAddresses()) { metadata.add("CitedResponsiblePartyEMail ",s.toString());
for(String s:r.getContactInfo().getAddress().getElectronicMailAddresses()) { metadata.add("CitedResponsiblePartyEMail ",s.toString());