Skip to content

Gigamap custom type indexers? #442

Answered by fh-ms
hrstoyanov asked this question in Q&A
Discussion options

You must be logged in to vote

If you want a nice reusable, typed indexer for Tsids, this is the implementation:

public abstract class TsidIndexer<E> extends BinaryIndexer.Abstract<E>
{
	@Override
	public final long indexBinary(final E entity)
	{
		return this.getTsid(entity).toLong();
	}
	
	protected abstract Tsid getTsid(E entity);
	
	public <S extends E> Condition<S> is(final Tsid id)
	{
		return super.is(id.toLong());
	}
}

and this the usage

final static TsidIndexer<MyEntity> tsidIndex = new TsidIndexer<>()
{
	@Override
	protected Tsid getTsid(final MyEntity entity)
	{
		return entity.getTsid();
	}
};

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by hrstoyanov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants