org.nakedobjects.example.expenses.fixtures.CurrencyFixture Maven / Gradle / Ivy
The newest version!
package org.nakedobjects.example.expenses.fixtures;
import org.nakedobjects.applib.DomainObjectContainer;
import org.nakedobjects.applib.fixtures.AbstractFixture;
import org.nakedobjects.example.expenses.currency.Currency;
public class CurrencyFixture extends AbstractFixture {
// {{ Injected: Container
private DomainObjectContainer container;
/**
* This field is not persisted, nor displayed to the user.
*/
protected DomainObjectContainer getContainer() {
return this.container;
}
/**
* Injected by the application container itself.
*/
public final void setContainer(final DomainObjectContainer container) {
this.container = container;
}
// }}
public static Currency EUR;
public static Currency USD;
public static Currency GBP;
public void install() {
EUR = createCurrency("EUR", "Euro Member Countries", "Euro");
GBP = createCurrency("GBP", "United Kingdom", "Pounds");
USD = createCurrency("USD", "United States of America", "Dollars");
}
private Currency createCurrency(final String code, final String country, final String name) {
final Currency currency = (Currency) newTransientInstance(Currency.class);
currency.setCurrencyCode(code);
currency.setCurrencyCountry(country);
currency.setCurrencyName(name);
makePersistent(currency);
return currency;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy