Is there any way to force a class to implement a property of a certain type?
For example, I have the classes Xxx
and Zzz
, and I want both of them to be forced to implement the property name
of type String .
Edited
What I want is Xxx and Zzz (and any other class that is subsequently created in the package), have the following structure:
package xxx.tests;
public class Foo {
private final static String NAME;
static {
NAME = "mi name";
};
public static String get(String name) {
if (name.equals("")) {
return name;
}
return NAME;
}
} // class
This means that all these classes have a property of a specific type that they must initialize and the method with a defined argument and return type. For the method implemented an interface.