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

it.tidalwave.bluebill.taxonomy.elmo.impl.XXXFinder Maven / Gradle / Ivy

/***********************************************************************************************************************
 *
 * blueBill Core - open source birding
 * Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************
 *
 * WWW: http://bluebill.tidalwave.it
 * SCM: https://kenai.com/hg/bluebill~core-src
 *
 **********************************************************************************************************************/
package it.tidalwave.bluebill.taxonomy.elmo.impl;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import it.tidalwave.util.Finder;
import it.tidalwave.util.Finder.SortDirection;
import it.tidalwave.util.Finder.SortCriterion;
import it.tidalwave.util.NotFoundException;

/**
 * FIXME: drop this and use FinderSupport
 * @author fritz
 */
public class XXXFinder implements it.tidalwave.util.Finder
  {
    private final List list;

    public XXXFinder (final @Nonnull List list) 
      {
        this.list = list;
      }

    @Override
    public int count()
      {
        return list.size();
      }

    @Override
    public Finder from (int index)
      {
        return new XXXFinder(list.subList(index, list.size() - 1));
      }

    @Override
    public it.tidalwave.util.Finder max (int size)
      {
        return new XXXFinder(list.subList(0, size - 1));
      }

    @Override
    public T result() throws NotFoundException
      {
        if (list.size() == 0)
          {
            throw new NotFoundException();
          }

        return list.get(0); // FIXME: size check?
      }

    @Override
    public List results() 
      {
        return new CopyOnWriteArrayList(list);
      }

    @Override
    public Finder sort (final @Nonnull SortCriterion sortCriterion,
                           final @Nonnull SortDirection sortDirection)
      {
        return this; // FIXME
      }

    @Override
    public Finder sort (final @Nonnull SortCriterion sortCriterion)
      {
        return sort(sortCriterion, SortDirection.ASCENDING);
      }

    public  Finder ofType (Class type)
      {
        throw new UnsupportedOperationException("Not supported yet.");
      }

    public T firstResult()
      throws NotFoundException
      {
        throw new UnsupportedOperationException("Not supported yet.");
      }
  }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy