37
37
public static class CacheIdentifier
39
public enum Type { NAME, ORGANISATION, PRIMARY_NUMBER, PRIMARY_EMAIL }
40
NONE, NAME, ORGANISATION, PRIMARY_NUMBER, PRIMARY_EMAIL }
41
42
private Type _type;
42
43
private String _detail;
45
protected CacheIdentifier()
45
51
* Obtain a cache identifier. This routine is designed to be as robust
46
52
* as possible (in terms of bad or null detail values), and to return
73
79
public static CacheIdentifier factory( Importer.ContactData contact )
75
CacheIdentifier identifier = null;
81
CacheIdentifier ret = null;
77
83
if( contact.hasName() )
78
identifier = factory( CacheIdentifier.Type.NAME,
84
ret = factory( CacheIdentifier.Type.NAME,
79
85
contact.getName() );
80
if( identifier != null ) return identifier;
82
if( contact.hasPrimaryOrganisation() )
83
identifier = factory( CacheIdentifier.Type.ORGANISATION,
86
if( ret == null && contact.hasPrimaryOrganisation() )
87
ret = factory( CacheIdentifier.Type.ORGANISATION,
84
88
contact.getPrimaryOrganisation() );
85
if( identifier != null ) return identifier;
87
if( contact.hasPrimaryNumber() )
88
identifier = factory( CacheIdentifier.Type.PRIMARY_NUMBER,
89
if( ret == null && contact.hasPrimaryNumber() )
90
ret = factory( CacheIdentifier.Type.PRIMARY_NUMBER,
89
91
contact.getPrimaryNumber() );
90
if( identifier != null ) return identifier;
92
if( contact.hasPrimaryEmail() )
93
identifier = factory( CacheIdentifier.Type.PRIMARY_EMAIL,
92
if( ret == null && contact.hasPrimaryEmail() )
93
ret = factory( CacheIdentifier.Type.PRIMARY_EMAIL,
94
94
contact.getPrimaryEmail() );
95
if( identifier != null ) return identifier;
100
99
protected CacheIdentifier( Type type, String detail )