-
Notifications
You must be signed in to change notification settings - Fork 0
Keys
Jamie Mansfield edited this page Nov 3, 2015
·
9 revisions
Keys are a unique identifier for accessing meta from a ValueHolder.
int time = holder.get(Keys.TIME).get();
The above above example shows an example of using ValueHolders, something of which is covered elsewhere.
Most applications that use Meta API will choose to create a final class to contain all the Keys.
import uk.jamierocks.meta.api.MetaQuery;
import uk.jamierocks.meta.api.key.Key;
import uk.jamierocks.meta.api.key.KeyHelper;
import uk.jamierocks.meta.api.value.Value;
public final class Keys {
public final Key<Value<Integer>> TIME = KeyHelper.newSingleKey(Value.class, MetaQuery.of("Time"));
}
Keys are unique and therefor you should only ever pass around ONE instance of it, hence the reason Keys is useful.