public <W> BuildableKey<T, Rekord<W>> with(BuildableKey<V, Rekord<W>> after) { return new BuildableKeyDecorator<>(new ComposedKey<>(name, before, after), after.builder()); } }
public <T, V> BuildableKey<T, Rekord<V>> builtFrom(Rekord<V> builder) { return new BuildableKeyDecorator<>(new RekordKey<T, V>(name), builder); } }
@Override public boolean test(Properties<T> properties) { for (Key<T, ?> key : keys) { if (!key.test(properties)) { return false; } } return true; }
@Override public Properties<T> set(V value, Properties<T> properties) { return key.set(value, properties); }
public BuildableKeyDecorator(Key<T, V> key, V builder) { super(key.name(), key); this.key = key; this.builder = builder; }
@Override public V get(Properties<T> properties) { V value = underlyingKey.get(properties); if (value == null) { return defaultValue; } return value; }
@Override public <A2, E2 extends Exception> void accumulateIn(Serializer.Accumulator<A2, E2> iterableAccumulator) throws E2 { for (V value : iterable) { contents.accumulate(value, iterableAccumulator); } } });
@Override public final Iterator<Key<T, ?>> iterator() { return keys.iterator(); } }
public static IterableKeyBuilder named(String name) { return new IterableKeyBuilder(name); }
public static UnsourcedComposedKey named(String name) { return new UnsourcedComposedKey(name); }
public static <T, V> Key<T, V> named(String name) { return new SimpleKey<>(name); }
@Override public final Properties<T> set(V value, Properties<T> properties) { return key.set(value, properties); } }
@Override public boolean has(Key<T, ?> key) { return key.test(properties); }
private DefaultedKey(Key<T, V> underlyingKey, V defaultValue) { super(underlyingKey.name(), underlyingKey); this.underlyingKey = underlyingKey; this.defaultValue = defaultValue; }
@Override public final V get(Properties<T> properties) { return key.get(properties); }
@Override public final <A, E extends Exception> void accumulate(V value, Serializer.Accumulator<A, E> accumulator) throws E { for (Key<T, ?> key : keys) { @SuppressWarnings("unchecked") Key<T, Object> castKey = (Key<T, Object>) key; castKey.accumulate(value, accumulator); } }
@Override public boolean test(Properties<T> properties) { return key.test(properties); }
@SuppressWarnings("unchecked") public <U> CopiedKey(Key<U, V> key) { super(key.name(), (Key<T, V>) key); }