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

com.fleetpin.graphql.database.manager.dynamo.Flattener Maven / Gradle / Ivy

/*
 * 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.
 */

package com.fleetpin.graphql.database.manager.dynamo;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fleetpin.graphql.database.manager.Table;
import com.fleetpin.graphql.database.manager.annotations.Hash;
import com.fleetpin.graphql.database.manager.util.TableCoreUtil;
import java.util.*;
import java.util.stream.Collectors;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;

public abstract class Flattener {

	public static Flattener create(List entityTables, boolean b) {
		if (entityTables.size() > 1) {
			return new FlattenerMulti(entityTables, b);
		}
		return new FlattenerSingle(b);
	}

	public abstract DynamoItem get(Optional extractor, Class type, String id);

	protected abstract void addItem(DynamoItem item);

	public final void addItems(List list) {
		list.forEach(item -> {
			addItem(item);
		});
	}

	public final void add(String table, List> list) {
		list.forEach(item -> {
			var i = new DynamoItem(table, item);
			addItem(i);
		});
	}

	public final  List results(ObjectMapper mapper, Class type) {
		return results(mapper, type, Optional.empty());
	}

	public abstract  List results(ObjectMapper mapper, Class type, Optional limit);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy