![JAR search and dependency download from the Maven repository](/logo.png)
org.boon.datarepo.spi.SPIFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boon Show documentation
Show all versions of boon Show documentation
Simple opinionated Java for the novice to expert level Java Programmer.
Low Ceremony. High Productivity. A real boon to Java to developers!
/*
* Copyright 2013-2014 Richard M. Hightower
* 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.
*
* __________ _____ __ .__
* \______ \ ____ ____ ____ /\ / \ _____ | | _|__| ____ ____
* | | _// _ \ / _ \ / \ \/ / \ / \\__ \ | |/ / |/ \ / ___\
* | | ( <_> | <_> ) | \ /\ / Y \/ __ \| <| | | \/ /_/ >
* |______ /\____/ \____/|___| / \/ \____|__ (____ /__|_ \__|___| /\___ /
* \/ \/ \/ \/ \/ \//_____/
* ____. ___________ _____ ______________.___.
* | |____ ___ _______ \_ _____/ / _ \ / _____/\__ | |
* | \__ \\ \/ /\__ \ | __)_ / /_\ \ \_____ \ / | |
* /\__| |/ __ \\ / / __ \_ | \/ | \/ \ \____ |
* \________(____ /\_/ (____ / /_______ /\____|__ /_______ / / ______|
* \/ \/ \/ \/ \/ \/
*/
package org.boon.datarepo.spi;
import org.boon.core.Typ;
import org.boon.datarepo.Filter;
import org.boon.datarepo.LookupIndex;
import org.boon.datarepo.RepoBuilder;
import org.boon.datarepo.impl.*;
import org.boon.datarepo.impl.indexes.LookupIndexDefault;
import org.boon.datarepo.impl.indexes.SearchIndexDefault;
import org.boon.datarepo.impl.indexes.UniqueLookupIndex;
import org.boon.datarepo.impl.indexes.UniqueSearchIndex;
import org.boon.datarepo.impl.maps.MapCreatorImpl;
import org.boon.core.Function;
import org.boon.core.Supplier;
/**
* Helper class for SPIFactory interface.
*/
public class SPIFactory {
static Supplier mapCreatorFactory = null;
static Supplier repoBuilderFactory = null;
static Function searchIndexFactory = null;
static Function uniqueLookupIndexFactory = null;
static Function uniqueSearchIndexFactory = null;
static Function lookupIndexFactory = null;
static Supplier repoFactory = null;
static Supplier filterFactory = null;
static Supplier searchableCollectionFactory = null;
static Supplier objectEditorFactory;
public static Supplier getMapCreatorFactory() {
return mapCreatorFactory;
}
public static Supplier getSearchableCollectionFactory() {
return searchableCollectionFactory;
}
public static Supplier getRepoBuilderFactory() {
return repoBuilderFactory;
}
public static Function getSearchIndexFactory() {
return searchIndexFactory;
}
public static Function getUniqueSearchIndexFactory() {
return uniqueSearchIndexFactory;
}
public static Function getLookupIndexFactory() {
return lookupIndexFactory;
}
public static Function getUniqueLookupIndexFactory() {
return uniqueLookupIndexFactory;
}
public static Supplier getRepoFactory() {
return repoFactory;
}
public static Supplier getFilterFactory() {
return filterFactory;
}
public static void init() {
if ( mapCreatorFactory == null ) {
mapCreatorFactory = new Supplier() {
@Override
public MapCreator get() {
return new MapCreatorImpl();
}
};
}
if ( repoBuilderFactory == null ) {
repoBuilderFactory = new Supplier() {
@Override
public RepoBuilder get() {
return new RepoBuilderDefault();
}
};
}
if ( searchIndexFactory == null ) {
searchIndexFactory = new Function() {
public SearchIndex apply( Class keyType ) {
if ( keyType == Typ.string ) {
return new SearchIndexDefault( keyType );
}
else{
return new SearchIndexDefault( keyType );
}
}
};
}
if ( lookupIndexFactory == null ) {
lookupIndexFactory = new Function() {
@Override
public LookupIndex apply( Class keyType ) {
return new LookupIndexDefault( keyType );
}
};
}
if ( uniqueLookupIndexFactory == null ) {
uniqueLookupIndexFactory = new Function() {
@Override
public LookupIndex apply( Class keyType ) {
return new UniqueLookupIndex( keyType );
}
};
}
if ( uniqueSearchIndexFactory == null ) {
uniqueSearchIndexFactory = new Function() {
@Override
public SearchIndex apply( Class keyType ) {
return new UniqueSearchIndex( keyType );
}
};
}
if ( repoFactory == null ) {
repoFactory = new Supplier() {
@Override
public RepoComposer get() {
return new RepoDefault<>();
}
};
}
if ( filterFactory == null ) {
filterFactory = new Supplier() {
@Override
public Filter get() {
return new FilterDefault();
}
};
}
if ( searchableCollectionFactory == null ) {
searchableCollectionFactory = new Supplier() {
@Override
public SearchableCollectionComposer get() {
return new SearchableCollectionDefault();
}
};
}
if ( objectEditorFactory == null ) {
objectEditorFactory = new Supplier() {
@Override
public ObjectEditorComposer get() {
return new ObjectEditorDefault();
}
};
}
}
static {
init();
}
public static void setMapCreatorFactory( Supplier mapCreatorFactory ) {
SPIFactory.mapCreatorFactory = mapCreatorFactory;
}
public static void setRepoBuilderFactory( Supplier repoBuilderFactory ) {
SPIFactory.repoBuilderFactory = repoBuilderFactory;
}
public static void setSearchIndexFactory( Function searchIndexFactory ) {
SPIFactory.searchIndexFactory = searchIndexFactory;
}
public static void setLookupIndexFactory( Function lookupIndexFactory ) {
SPIFactory.lookupIndexFactory = lookupIndexFactory;
}
public static void setUniqueLookupIndexFactory( Function lookupIndexFactory ) {
SPIFactory.uniqueLookupIndexFactory = lookupIndexFactory;
}
public static void setUniqueSearchIndexFactory( Function factory ) {
SPIFactory.uniqueSearchIndexFactory = factory;
}
public static void setRepoFactory( Supplier repoFactory ) {
SPIFactory.repoFactory = repoFactory;
}
public static void setFilterFactory( Supplier filterFactory ) {
SPIFactory.filterFactory = filterFactory;
}
public static Supplier getObjectEditorFactory() {
return objectEditorFactory;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy