Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* *********************************************************************************************************************
*
* TheseFoolishThings: Miscellaneous utilities
* http://tidalwave.it/projects/thesefoolishthings
*
* Copyright (C) 2009 - 2023 by Tidalwave s.a.s. (http://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.
*
* *********************************************************************************************************************
*
* git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
* git clone https://github.com/tidalwave-it/thesefoolishthings-src
*
* *********************************************************************************************************************
*/
package it.tidalwave.util.spi;
import java.lang.reflect.Constructor;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import it.tidalwave.util.Finder;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import static it.tidalwave.util.CollectionUtils.concat;
/***********************************************************************************************************************
*
* A support class for implementing a {@link Finder}. Subclasses only need to implement the {@link #computeResults()}
* method where raw results are retrieved (with raw we mean that they shouldn't be filtered or sorted, as
* post-processing will be performed by this class) and a clone constructor.
*
* If you don't need to extend the {@link Finder} with extra methods, please use the simplified
* {@link SimpleFinderSupport}.
*
* @author Fabrizio Giudici
* @it.tidalwave.javadoc.draft
*
**********************************************************************************************************************/
@Slf4j @AllArgsConstructor(access = AccessLevel.PRIVATE) @ToString
public class HierarchicFinderSupport> implements Finder
{
private static final long serialVersionUID = 2467809593956684L;
@RequiredArgsConstructor
static class Sorter
{
@Nonnull
private final InMemorySortCriterion sortCriterion;
@Nonnull
private final SortDirection sortDirection;
public void sort (@Nonnull final List extends U> results)
{
sortCriterion.sort(results, sortDirection);
}
}
private static final String MESSAGE =
"Since version 2.0, Implementations of Finder must have a clone constructor such as "
+ "MyFinder(MyFinder other, Object override). This means that they can't be implemented by anonymous or inner, "
+ "non static classes. See the javadoc for further information. Could not find constructor: ";
@Nonnull
private final String name;
@Nonnegative
protected final int firstResult;
@Nonnegative
protected final int maxResults;
@Nonnull @Getter(AccessLevel.PROTECTED)
private final List