-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add locale for GE #92
Changes from all commits
f21bb48
67e72a9
7a36a3f
ff93656
8e50a03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.codearte.jfairy; | ||
|
||
import io.codearte.jfairy.data.DataMaster; | ||
import io.codearte.jfairy.producer.RandomGenerator; | ||
import io.codearte.jfairy.producer.VATIdentificationNumberProvider; | ||
import io.codearte.jfairy.producer.company.locale.ka.KaVATIdentificationNumberProvider; | ||
import io.codearte.jfairy.producer.person.AddressProvider; | ||
import io.codearte.jfairy.producer.person.NationalIdentificationNumberFactory; | ||
import io.codearte.jfairy.producer.person.NationalIdentityCardNumberProvider; | ||
import io.codearte.jfairy.producer.person.PassportNumberProvider; | ||
import io.codearte.jfairy.producer.person.locale.NoNationalIdentificationNumberFactory; | ||
import io.codearte.jfairy.producer.person.locale.ka.KaAddressProvider; | ||
import io.codearte.jfairy.producer.person.locale.ka.KaNationalIdentityCardNumberProvider; | ||
import io.codearte.jfairy.producer.person.locale.ka.KaPassportNumberProvider; | ||
|
||
public class KaFairyModule extends FairyModule { | ||
|
||
public KaFairyModule(DataMaster dataMaster, RandomGenerator randomGenerator) { | ||
super(dataMaster, randomGenerator); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
super.configure(); | ||
bind(NationalIdentificationNumberFactory.class).to(NoNationalIdentificationNumberFactory.class); | ||
bind(NationalIdentityCardNumberProvider.class).to(KaNationalIdentityCardNumberProvider.class); | ||
bind(VATIdentificationNumberProvider.class).to(KaVATIdentificationNumberProvider.class); | ||
bind(AddressProvider.class).to(KaAddressProvider.class); | ||
bind(PassportNumberProvider.class).to(KaPassportNumberProvider.class); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.codearte.jfairy.producer.company.locale.ka; | ||
|
||
import com.google.inject.Inject; | ||
import io.codearte.jfairy.producer.BaseProducer; | ||
import io.codearte.jfairy.producer.VATIdentificationNumberProvider; | ||
|
||
public class KaVATIdentificationNumberProvider implements VATIdentificationNumberProvider { | ||
|
||
private final BaseProducer baseProducer; | ||
|
||
@Inject | ||
public KaVATIdentificationNumberProvider(BaseProducer baseProducer) { | ||
this.baseProducer = baseProducer; | ||
} | ||
|
||
@Override | ||
public String get() { | ||
return baseProducer.randomElement("2", "4") + baseProducer.numerify("########"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.codearte.jfairy.producer.person.locale; | ||
|
||
import io.codearte.jfairy.producer.person.Address; | ||
|
||
/** | ||
* A base of all addresses. It carries all needed fields, but leaves most of formatting to subclasses. | ||
*/ | ||
public abstract class AbstractAddress implements Address { | ||
protected final String street; | ||
protected final String streetNumber; | ||
protected final String apartmentNumber; | ||
protected final String postalCode; | ||
protected final String city; | ||
|
||
public AbstractAddress(String street, String streetNumber, String apartmentNumber, String postalCode, String city) { | ||
this.street = street; | ||
this.streetNumber = streetNumber; | ||
this.postalCode = postalCode; | ||
this.city = city; | ||
this.apartmentNumber = apartmentNumber; | ||
} | ||
|
||
public String getStreet() { | ||
return street; | ||
} | ||
|
||
public String getStreetNumber() { | ||
return streetNumber; | ||
} | ||
|
||
public String getApartmentNumber() { | ||
return apartmentNumber; | ||
} | ||
|
||
public String getPostalCode() { | ||
return postalCode; | ||
} | ||
|
||
public String getCity() { | ||
return city; | ||
} | ||
|
||
public abstract String getAddressLine1(); | ||
|
||
public abstract String getAddressLine2(); | ||
|
||
@Override | ||
public String toString() { | ||
return getAddressLine1() + System.lineSeparator() + getAddressLine2(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.codearte.jfairy.producer.person.locale; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isNotBlank; | ||
|
||
/** | ||
* An address format typical for European countries but the UK and ex-Soviet union. | ||
*/ | ||
public abstract class ContinentalAddress extends AbstractAddress { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if 2 levels of abstractions are needed here. Maybe it would be better to leave the implementation of the methods that most countries use in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that the order of address parts ( street > number, ZIP > city) is really quite common for European countries, but nowhere else. |
||
public ContinentalAddress(String street, String streetNumber, String apartmentNumber, String postalCode, String city) { | ||
super(street, streetNumber, apartmentNumber, postalCode, city); | ||
} | ||
|
||
protected abstract String getApartmentMark(); | ||
|
||
protected String getStreetNumberSeparator() { | ||
return " "; | ||
} | ||
|
||
@Override | ||
public String getAddressLine1() { | ||
return street + getStreetNumberSeparator() + streetNumber | ||
+ (isNotBlank(apartmentNumber) ? getApartmentMark() + apartmentNumber : ""); | ||
} | ||
|
||
@Override | ||
public String getAddressLine2() { | ||
return postalCode + " " + city; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,22 @@ | ||
package io.codearte.jfairy.producer.person.locale.de; | ||
|
||
import io.codearte.jfairy.producer.person.Address; | ||
import io.codearte.jfairy.producer.person.locale.ContinentalAddress; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isNotBlank; | ||
import static org.apache.commons.lang3.SystemUtils.LINE_SEPARATOR; | ||
|
||
/** | ||
* @author Roland Weisleder | ||
*/ | ||
public class DeAddress implements Address { | ||
|
||
private final String streetNumber; | ||
|
||
private final String street; | ||
|
||
private final String apartmentNumber; | ||
|
||
private final String city; | ||
|
||
private final String postalCode; | ||
public class DeAddress extends ContinentalAddress { | ||
|
||
public DeAddress(String streetNumber, String street, String apartmentNumber, String city, String postalCode) { | ||
this.streetNumber = streetNumber; | ||
this.street = street; | ||
this.apartmentNumber = apartmentNumber; | ||
this.city = city; | ||
this.postalCode = postalCode; | ||
} | ||
|
||
public String getStreetNumber() { | ||
return streetNumber; | ||
} | ||
|
||
public String getStreet() { | ||
return street; | ||
} | ||
|
||
public String getApartmentNumber() { | ||
return apartmentNumber; | ||
} | ||
|
||
public String getCity() { | ||
return city; | ||
} | ||
|
||
public String getPostalCode() { | ||
return postalCode; | ||
} | ||
|
||
public String getAddressLine1() { | ||
return street + " " + streetNumber | ||
+ (isNotBlank(apartmentNumber) ? ", " + apartmentNumber : ""); | ||
} | ||
|
||
public String getAddressLine2() { | ||
return postalCode + " " + city; | ||
super(street, streetNumber, apartmentNumber, postalCode, city); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getAddressLine1() + LINE_SEPARATOR + getAddressLine2(); | ||
protected String getApartmentMark() { | ||
return ", "; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,25 @@ | ||
package io.codearte.jfairy.producer.person.locale.en; | ||
|
||
import io.codearte.jfairy.producer.person.Address; | ||
import io.codearte.jfairy.producer.person.locale.AbstractAddress; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isNotBlank; | ||
import static org.apache.commons.lang3.SystemUtils.LINE_SEPARATOR; | ||
|
||
public class EnAddress implements Address { | ||
|
||
private final String streetNumber; | ||
|
||
private final String street; | ||
|
||
private final String apartmentNumber; | ||
|
||
private final String city; | ||
|
||
private final String postalCode; | ||
public class EnAddress extends AbstractAddress { | ||
|
||
public EnAddress(String streetNumber, String street, String apartmentNumber, String city, String postalCode) { | ||
this.streetNumber = streetNumber; | ||
this.street = street; | ||
this.apartmentNumber = apartmentNumber; | ||
this.city = city; | ||
this.postalCode = postalCode; | ||
} | ||
|
||
public String getStreetNumber() { | ||
return streetNumber; | ||
} | ||
|
||
public String getStreet() { | ||
return street; | ||
} | ||
|
||
public String getApartmentNumber() { | ||
return apartmentNumber; | ||
} | ||
|
||
public String getCity() { | ||
return city; | ||
} | ||
|
||
public String getPostalCode() { | ||
return postalCode; | ||
super(street, streetNumber, apartmentNumber, postalCode, city); | ||
} | ||
|
||
@Override | ||
public String getAddressLine1() { | ||
return streetNumber + " " + street | ||
+ (isNotBlank(apartmentNumber) ? " APT " + apartmentNumber : ""); | ||
} | ||
|
||
@Override | ||
public String getAddressLine2() { | ||
return city + " " + postalCode; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getAddressLine1() + LINE_SEPARATOR + getAddressLine2(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.codearte.jfairy.producer.person.locale.ka; | ||
|
||
import io.codearte.jfairy.producer.person.locale.AbstractAddress; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isNotBlank; | ||
|
||
public class KaAddress extends AbstractAddress { | ||
public KaAddress(String street, String streetNumber, String apartmentNumber, String postalCode, String city) { | ||
super(street, streetNumber, apartmentNumber, postalCode, city); | ||
} | ||
|
||
@Override | ||
public String getAddressLine1() { | ||
return postalCode + ", " + city; | ||
} | ||
|
||
@Override | ||
public String getAddressLine2() { | ||
return street + " №" + streetNumber + (isNotBlank(apartmentNumber) ? ", ბინა " + apartmentNumber : ""); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the language code GE or KA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the PR description, this a rare case where a name of the country and language differs. 'GE' is the country (ISO 3166) , 'KA' is the language (https://www.loc.gov/standards/iso639-2/php/langcodes_name.php?iso_639_1=ka).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Looking back at it, the way it's done right now is inconsistent. We use language codes, while the fairy modules really represent specific locale, not only languages. I think you can keep either KA or GE here, but soon we should modify these enums to represent both language and country, cause there can be different document formats in same language speaking countries. However, either way, I would only stick with one of them for now till we get it fixed. Please choose one and stick to it in all your changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there is not much to be decided. The Georgian locale must have the 'ka' language as per ISO-639. If I don't want to change the language-to-module deduction logic in
Bootstrap.getFairyModuleForLocale(...)
as well as the parser of control YAMLs, I have to stay with ka.I do not like it (
KaFairyModule
etc. is counter-intuitive), but I shall follow your rules.See my latest commit, please.