Skip to content
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.

Storing keys

Most applications that use Meta API will choose to create a final class to contain all the Keys.

import uk.jamierocks.meta.api.key.Key;
import uk.jamierocks.meta.api.key.KeysBase;
import uk.jamierocks.meta.api.value.Value;

public final class Keys extends KeysBase {

    public static final Key<Value<Integer>> TIME = newSingleKey(Value.class, Queries.TIME);
}

Keys are unique and therefore you should only ever pass around ONE instance of it, hence the reason Keys is useful.

As a helping-hand, I have make KeysBase an abstract class containing methods from KeyFactory and related.

Clone this wiki locally