Hi, how about declaring name @Transient and to resolve the current translation in your getter- or toString-Method ?
Same in your enum Color. (By the way @Transient isn't required there.)
Cause you can be sure that the string will be empty unless you have initialized it with the current language, so you have to do this only once.
If you want to change it, while your app is running and the products were already loaded, I would use the Observer/Observable-Pattern (see java.uitl).
So you can notify the products to update their describing. (Similar to Event-listeners)
By the way, you can do it by hand (not recommended). with your
Code:
public Product(String name, Color color, price){this.bla = bla}
}
But then you can't use Color as enum, you have to pass it as String and use
Quote:
public static <T extends Enum<T>> T valueOf(Class<T> enumType,
String name)
to resolve it. (Or use the valueOf-Method before you call the constructor, then you can keep your method signature unchanged.)
By the way, I wouldn't store the locale as attribute of PrroductXYZ.
It's a global variable, so place in an singleton class, so it is common to all objects. (If don't know what a singelton is, refer to "Effective Java" from Josuha Bloch.)
You surely don't want to display product1 in English and product 2 in German.
Greetings Michael