Rename data sources

This commit is contained in:
Christopher Schnick 2022-05-20 13:36:50 +02:00
parent 136a940e81
commit 628e322ca3
12 changed files with 38 additions and 38 deletions

View file

@ -5,7 +5,7 @@ import io.xpipe.core.store.DataStore;
import java.util.HashMap;
import java.util.Map;
public abstract class CollectionDataSource<DS extends DataStore> extends DataSourceDescriptor<DS> {
public abstract class CollectionDataSource<DS extends DataStore> extends DataSource<DS> {
private final Map<String, String> preferredProviders;

View file

@ -10,15 +10,15 @@ import java.util.Optional;
*
* This instance is only valid in combination with its associated data store instance.
*/
public abstract class DataSourceDescriptor<DS extends DataStore> {
public abstract class DataSource<DS extends DataStore> {
protected DS store;
public DataSourceDescriptor(DS store) {
public DataSource(DS store) {
this.store = store;
}
public DataSourceDescriptor<DS> withStore(DS newStore) {
public DataSource<DS> withStore(DS newStore) {
return null;
}
@ -26,7 +26,7 @@ public abstract class DataSourceDescriptor<DS extends DataStore> {
* Casts this instance to the required type without checking whether a cast is possible.
*/
@SuppressWarnings("unchecked")
public final <DSD extends DataSourceDescriptor<?>> DSD asNeeded() {
public final <DSD extends DataSource<?>> DSD asNeeded() {
return (DSD) this;
}

View file

@ -2,11 +2,11 @@ package io.xpipe.core.source;
import io.xpipe.core.store.DataStore;
public abstract class RawDataSourceDescriptor <DS extends DataStore> extends DataSourceDescriptor<DS> {
public abstract class RawDataSource<DS extends DataStore> extends DataSource<DS> {
private static final int MAX_BYTES_READ = 100000;
public RawDataSourceDescriptor(DS store) {
public RawDataSource(DS store) {
super(store);
}

View file

@ -3,9 +3,9 @@ package io.xpipe.core.source;
import io.xpipe.core.data.node.DataStructureNode;
import io.xpipe.core.store.DataStore;
public abstract class StructureDataSourceDescriptor<DS extends DataStore> extends DataSourceDescriptor<DS> {
public abstract class StructureDataSource<DS extends DataStore> extends DataSource<DS> {
public StructureDataSourceDescriptor(DS store) {
public StructureDataSource(DS store) {
super(store);
}

View file

@ -2,9 +2,9 @@ package io.xpipe.core.source;
import io.xpipe.core.store.DataStore;
public abstract class TableDataSourceDescriptor<DS extends DataStore> extends DataSourceDescriptor<DS> {
public abstract class TableDataSource<DS extends DataStore> extends DataSource<DS> {
public TableDataSourceDescriptor(DS store) {
public TableDataSource(DS store) {
super(store);
}

View file

@ -2,11 +2,11 @@ package io.xpipe.core.source;
import io.xpipe.core.store.DataStore;
public abstract class TextDataSourceDescriptor<DS extends DataStore> extends DataSourceDescriptor<DS> {
public abstract class TextDataSource<DS extends DataStore> extends DataSource<DS> {
private static final int MAX_LINE_READ = 1000;
public TextDataSourceDescriptor(DS store) {
public TextDataSource(DS store) {
super(store);
}

View file

@ -1,7 +1,7 @@
package io.xpipe.core.store;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.xpipe.core.source.DataSourceDescriptor;
import io.xpipe.core.source.DataSource;
import java.time.Instant;
import java.util.Optional;
@ -11,7 +11,7 @@ import java.util.Optional;
* It does not contain any information on what data is stored,
* how the data is stored inside, or what part of the data store makes up the actual data source.
*
* @see DataSourceDescriptor
* @see DataSource
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public interface DataStore {

View file

@ -2,7 +2,7 @@ package io.xpipe.extension;
import io.xpipe.core.config.ConfigOption;
import io.xpipe.core.config.ConfigOptionSet;
import io.xpipe.core.source.DataSourceDescriptor;
import io.xpipe.core.source.DataSource;
import io.xpipe.core.source.DataSourceType;
import io.xpipe.core.store.DataStore;
import javafx.beans.property.Property;
@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
public interface DataSourceProvider<T extends DataSourceDescriptor<?>> {
public interface DataSourceProvider<T extends DataSource<?>> {
static enum GeneralType {
FILE,
@ -33,7 +33,7 @@ public interface DataSourceProvider<T extends DataSourceDescriptor<?>> {
return false;
}
default DataSourceDescriptor<?> convert(T in, DataSourceType t) throws Exception {
default DataSource<?> convert(T in, DataSourceType t) throws Exception {
throw new ExtensionException();
}
@ -48,7 +48,7 @@ public interface DataSourceProvider<T extends DataSourceDescriptor<?>> {
return getId() + "." + key;
}
default Region createConfigOptions(DataStore input, Property<? extends DataSourceDescriptor<?>> source) {
default Region createConfigOptions(DataStore input, Property<? extends DataSource<?>> source) {
return null;
}
@ -75,9 +75,9 @@ public interface DataSourceProvider<T extends DataSourceDescriptor<?>> {
Map<String, List<String>> getFileExtensions();
}
interface ConfigProvider<T extends DataSourceDescriptor<?>> {
interface ConfigProvider<T extends DataSource<?>> {
static <T extends DataSourceDescriptor<?>> ConfigProvider<T> empty(List<String> names, Function<DataStore, T> func) {
static <T extends DataSource<?>> ConfigProvider<T> empty(List<String> names, Function<DataStore, T> func) {
return new ConfigProvider<>() {
@Override
public ConfigOptionSet getConfig() {

View file

@ -39,40 +39,40 @@ public class DataSourceProviders {
@SuppressWarnings("unchecked")
@SneakyThrows
public static StructureDataSourceDescriptor<LocalFileDataStore> createLocalStructureDescriptor(DataStore store) {
return (StructureDataSourceDescriptor<LocalFileDataStore>)
public static StructureDataSource<LocalFileDataStore> createLocalStructureDescriptor(DataStore store) {
return (StructureDataSource<LocalFileDataStore>)
DataSourceProviders.byId("xpbs").getDescriptorClass()
.getDeclaredConstructors()[0].newInstance(store);
}
@SuppressWarnings("unchecked")
@SneakyThrows
public static RawDataSourceDescriptor<LocalFileDataStore> createLocalRawDescriptor(DataStore store) {
return (RawDataSourceDescriptor<LocalFileDataStore>)
public static RawDataSource<LocalFileDataStore> createLocalRawDescriptor(DataStore store) {
return (RawDataSource<LocalFileDataStore>)
DataSourceProviders.byId("binary").getDescriptorClass()
.getDeclaredConstructors()[0].newInstance(store);
}
@SuppressWarnings("unchecked")
@SneakyThrows
public static RawDataSourceDescriptor<LocalFileDataStore> createLocalCollectionDescriptor(DataStore store) {
return (RawDataSourceDescriptor<LocalFileDataStore>)
public static RawDataSource<LocalFileDataStore> createLocalCollectionDescriptor(DataStore store) {
return (RawDataSource<LocalFileDataStore>)
DataSourceProviders.byId("br").getDescriptorClass()
.getDeclaredConstructors()[0].newInstance(store);
}
@SuppressWarnings("unchecked")
@SneakyThrows
public static TextDataSourceDescriptor<LocalFileDataStore> createLocalTextDescriptor(DataStore store) {
return (TextDataSourceDescriptor<LocalFileDataStore>)
public static TextDataSource<LocalFileDataStore> createLocalTextDescriptor(DataStore store) {
return (TextDataSource<LocalFileDataStore>)
DataSourceProviders.byId("text").getDescriptorClass()
.getDeclaredConstructors()[0].newInstance(store);
}
@SuppressWarnings("unchecked")
@SneakyThrows
public static TableDataSourceDescriptor<LocalFileDataStore> createLocalTableDescriptor(DataStore store) {
return (TableDataSourceDescriptor<LocalFileDataStore>)
public static TableDataSource<LocalFileDataStore> createLocalTableDescriptor(DataStore store) {
return (TableDataSource<LocalFileDataStore>)
DataSourceProviders.byId("xpbt").getDescriptorClass()
.getDeclaredConstructors()[0].newInstance(store);
}
@ -89,7 +89,7 @@ public class DataSourceProviders {
@SuppressWarnings("unchecked")
public static <C extends DataSourceDescriptor<?>, T extends DataSourceProvider<C>> T byDataSourceClass(Class<C> c) {
public static <C extends DataSource<?>, T extends DataSourceProvider<C>> T byDataSourceClass(Class<C> c) {
if (ALL == null) {
throw new IllegalStateException("Not initialized");
}

View file

@ -1,6 +1,6 @@
package io.xpipe.extension;
import io.xpipe.core.source.DataSourceDescriptor;
import io.xpipe.core.source.DataSource;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.FileDataStore;
import io.xpipe.core.store.StreamDataStore;
@ -9,7 +9,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public interface SimpleFileDataSourceProvider<T extends DataSourceDescriptor<?>> extends DataSourceProvider<T> {
public interface SimpleFileDataSourceProvider<T extends DataSource<?>> extends DataSourceProvider<T> {
@Override
default boolean prefersStore(DataStore store) {

View file

@ -1,12 +1,12 @@
package io.xpipe.extension;
import io.xpipe.core.source.DataSourceDescriptor;
import io.xpipe.core.source.DataSource;
import io.xpipe.core.store.DataStore;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public interface UniformDataSourceProvider<T extends DataSourceDescriptor<?>> extends DataSourceProvider<T> {
public interface UniformDataSourceProvider<T extends DataSource<?>> extends DataSourceProvider<T> {
@Override
default ConfigProvider<T> getConfigProvider() {

View file

@ -1,6 +1,6 @@
package io.xpipe.extension.comp;
import io.xpipe.core.source.DataSourceDescriptor;
import io.xpipe.core.source.DataSource;
import io.xpipe.fxcomps.Comp;
import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
public class DynamicOptionsBuilder<T extends DataSourceDescriptor<?>> {
public class DynamicOptionsBuilder<T extends DataSource<?>> {
private final List<DynamicOptionsComp.Entry> entries = new ArrayList<>();
private final List<Property<?>> props = new ArrayList<>();