/** * Creates a {@link UniqueKeyIndex} for matching with field paths and types declared by * {@link FieldPath} annotated fields or methods on the given key type. * * @param keyType the key type * @param <Q> the key type * @return a {@code UniqueKeyIndex} * @throws IllegalArgumentException if the key type declares one or more invalid field paths * or invalid types given resolution of corresponding field paths * @throws IllegalArgumentException if the builder is bound to the primary key of the unique type and * the field paths declared by the key type are not the identical to those declared by the primary key */ public <Q> UniqueKeyIndex<T, Q> usingBean(Class<Q> keyType) { Objects.requireNonNull(keyType); return new UniqueKeyIndex<>(consumer, uniqueType, primaryTypeKey, keyType); }
/** * Creates a {@link UniqueKeyIndex} for matching with a single key field path and type. * * @param keyFieldPath the key field path * @param keyFieldType the key type * @param <Q> the key type * @return a {@code UniqueKeyIndex} * @throws IllegalArgumentException if the key field path is empty or invalid * @throws IllegalArgumentException if the key field type is invalid given resolution of the * key field path * @throws IllegalArgumentException if the builder is bound to the primary key of the unique type and * the field path declared by the key type is not identical to the keyFieldPath */ public <Q> UniqueKeyIndex<T, Q> usingPath(String keyFieldPath, Class<Q> keyFieldType) { Objects.requireNonNull(keyFieldPath); if (keyFieldPath.isEmpty()) { throw new IllegalArgumentException("keyFieldPath argument is an empty String"); } Objects.requireNonNull(keyFieldType); return new UniqueKeyIndex<>(consumer, uniqueType, primaryTypeKey, keyFieldPath, keyFieldType); } }