All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.redislabs.lettusearch.search.field.Field Maven / Gradle / Ivy

There is a newer version: 3.1.2
Show newest version
package com.redislabs.lettusearch.search.field;

import static com.redislabs.lettusearch.CommandKeyword.NOINDEX;
import static com.redislabs.lettusearch.CommandKeyword.SORTABLE;

import io.lettuce.core.CompositeArgument;
import io.lettuce.core.internal.LettuceAssert;
import io.lettuce.core.protocol.CommandArgs;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public abstract class Field implements CompositeArgument {

	static final String MUST_NOT_BE_EMPTY = "must not be empty";
	static final String MUST_NOT_BE_NULL = "must not be null";

	private final String name;
	private final boolean sortable;
	private final boolean noIndex;

	@Override
	public  void build(CommandArgs args) {
		LettuceAssert.notNull(name, "name " + MUST_NOT_BE_NULL);
		LettuceAssert.notEmpty(name, "name " + MUST_NOT_BE_EMPTY);
		args.add(name);
		buildField(args);
		if (sortable) {
			args.add(SORTABLE);
		}
		if (noIndex) {
			args.add(NOINDEX);
		}
	}

	protected abstract  void buildField(CommandArgs args);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy