boolean evaluate(Address address, AddressTypes... types) { for (AddressType type : types) { if (address.getTypes().contains(type)) { return true; } } return false; }
@Override protected void _validate(List<ValidationWarning> warnings, VCardVersion version, VCard vcard) { for (AddressType type : getTypes()) { if (type == AddressType.PREF) { //ignore because it is converted to a PREF parameter for 4.0 vCards continue; } if (!type.isSupportedBy(version)) { warnings.add(new ValidationWarning(9, type.getValue())); } } /* * 2.1 does not allow multi-valued components. */ if (version == VCardVersion.V2_1) { //@formatter:off if (poBoxes.size() > 1 || extendedAddresses.size() > 1 || streetAddresses.size() > 1 || localities.size() > 1 || regions.size() > 1 || postalCodes.size() > 1 || countries.size() > 1) { warnings.add(new ValidationWarning(35)); } //@formatter:on } }
/** * Matches up a list of {@link Label} properties with their corresponding * {@link Address} properties. If no match can be found, then the LABEL * property itself is assigned to the vCard. * @param vcard the vCard that the properties belong to * @param labels the LABEL properties */ protected void assignLabels(VCard vcard, List<Label> labels) { List<Address> adrs = vcard.getAddresses(); for (Label label : labels) { boolean orphaned = true; Set<AddressType> labelTypes = new HashSet<AddressType>(label.getTypes()); for (Address adr : adrs) { if (adr.getLabel() != null) { //a label has already been assigned to it continue; } Set<AddressType> adrTypes = new HashSet<AddressType>(adr.getTypes()); if (adrTypes.equals(labelTypes)) { adr.setLabel(label.getValue()); orphaned = false; break; } } if (orphaned) { vcard.addOrphanedLabel(label); } } }
label.getTypes().addAll(adr.getTypes()); propertiesToAdd.add(label);
for (AddressType addressType : address.getTypes()) { if (AddressType.PREF.equals(addressType) || AddressType.WORK.equals(addressType)) { workAddress = true;
String country = postalAddress.getRelatedOne("CountryGeo", false).getString("geoName"); address.setCountry(country); address.getTypes().add(AddressType.WORK);;