Re: How to emluate "properties" in Java?
Thomas Pornin <pornin@bolet.org> writes:
What you describe as being a special characteristic of properties (with
regards to plain methods) is just a simple boolean metadata accessible
at runtime through reflection. Java has a generic support for metadata,
When there is no general specification about exactly which
annotation (fully qualified name) does mark a property, this
is less support for tools independent of a special manufacturer,
Simply define this:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface Property { }
Yes, this way everyone has his own, so there will be:
com.manufacturer.a.misc.Property
com.manufacturer.b.general.annotations.Property
com.manufacturer.c.Property
my.own.Property
This is not the same as a single Property annotation for the
whole Java community, similar to - say
java.lang.Override
. (In the same way Java also lacks some common general
interfaces such as
interface Action { void run(); }
interface Function<Y,X> { Y of( X x ); }
interface Add<X> { add( X ); }
interface Possibility { boolean isValid(); }
and so on
with a certain semantics.)