Package org.cyclos.utils
Class AddressHelper
- java.lang.Object
-
- org.cyclos.utils.AddressHelper
-
public class AddressHelper extends Object
A Helper to access Address fields
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAddressHelper.AddressSnapshotIt's an address DTO's snapshot
-
Constructor Summary
Constructors Constructor Description AddressHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubledistance(double lat1, double lon1, double lat2, double lon2, DistanceUnit distanceUnit)Returns the geo distance between the 2 lat / lonstatic Stringformat(IAddress address)Returns the formatted address.static StringgetDefaultValue(AddressFields field, AddressConfigurationData config)Returns the default value for the given field under the given configurationstatic Property<String,AddressDTO>getDTOPropertyForField(AddressFields field)Returns the correspondent property object of an optional address field from the given addressstatic StringgetValue(AddressFields field, IAddress address)Returns the value for a given optional field for the given addressstatic Property<String,AddressVO>getVOPropertyForField(AddressFields field)Returns the correspondent property object of an optional address field from the AddressVO bean.static booleanisEquals(IAddress address1, IAddress address2)Returns true if the address1 is equals to address2 by comparing it's fieldsstatic booleanisLocalizable(IAddress address)static booleanisRequired(List<AddressFields> requiredAddressFields, AddressFields field)Returns true if the given address field is included in the given required address fieldsstatic MessageKeyresolveKey(Collection<AddressFields> enabledAddressFields, AddressFields field)Returns the message key of the given field according to the enabled address fieldsstatic voidsetValue(AddressFields field, IAddress address, String value)Sets the value for a given optional field on the given addressstatic AddressHelper.AddressSnapshotsnapshot(Collection<AddressFields> fields, AddressDTO dto)It takes a snapshot of the address dto parameter taking into account the specified fields
-
-
-
Method Detail
-
distance
public static double distance(double lat1, double lon1, double lat2, double lon2, DistanceUnit distanceUnit)Returns the geo distance between the 2 lat / lon
-
format
public static String format(IAddress address)
Returns the formatted address. Basically, if there's an addressLine1, use it, optionally with addressLine2. Otherwise, if there are street / building number / complement fields, use them. Finally, if neither, return the city name if available.
-
getDefaultValue
public static String getDefaultValue(AddressFields field, AddressConfigurationData config)
Returns the default value for the given field under the given configuration
-
getDTOPropertyForField
public static Property<String,AddressDTO> getDTOPropertyForField(AddressFields field)
Returns the correspondent property object of an optional address field from the given address
-
getValue
public static String getValue(AddressFields field, IAddress address)
Returns the value for a given optional field for the given address
-
getVOPropertyForField
public static Property<String,AddressVO> getVOPropertyForField(AddressFields field)
Returns the correspondent property object of an optional address field from the AddressVO bean.
-
isEquals
public static boolean isEquals(IAddress address1, IAddress address2)
Returns true if the address1 is equals to address2 by comparing it's fields
-
isLocalizable
public static boolean isLocalizable(IAddress address)
- Returns:
- true if the current address has city or zipCode and addressLine1 or street defined
-
isRequired
public static boolean isRequired(List<AddressFields> requiredAddressFields, AddressFields field)
Returns true if the given address field is included in the given required address fields
-
resolveKey
public static MessageKey resolveKey(Collection<AddressFields> enabledAddressFields, AddressFields field)
Returns the message key of the given field according to the enabled address fields
-
setValue
public static void setValue(AddressFields field, IAddress address, String value)
Sets the value for a given optional field on the given address
-
snapshot
public static AddressHelper.AddressSnapshot snapshot(Collection<AddressFields> fields, AddressDTO dto)
It takes a snapshot of the address dto parameter taking into account the specified fields
-
-