
net.technearts.Repository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marxls Show documentation
Show all versions of marxls Show documentation
net.technearts - object/excel mapping
The newest version!
package net.technearts;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableSet;
import java.util.Optional;
import java.util.Queue;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.function.Predicate;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
public class Repository {
private static final Logger LOG = LoggerFactory.getLogger("Marshaller");
private Table table = HashBasedTable.create();
private Table nonMappedMembers = HashBasedTable.create();
private List> entityPredicates = new ArrayList<>();
public void put(Mapping mapping, int line, Object value) {
if (entityPredicates.stream().allMatch(predicate -> predicate.test(value))) {
table.put(mapping, line, value);
}
}
public Object get(String name, int line) {
if (name == null) {
throw new IllegalArgumentException("Nome não pode ser nulo");
}
return table.column(line).entrySet().stream()
.filter(entry -> name.equals(entry.getKey().getName())).findFirst().orElse(null);
}
public Map get(String name) {
for (Entry> entry : table.rowMap().entrySet()) {
if (name.equals(entry.getKey().getName())) {
return entry.getValue();
}
}
return null;
}
public Map get(Class> klazz) {
for (Entry> entry : table.rowMap().entrySet()) {
if (klazz.getName().equals(entry.getKey().getClassName())) {
return entry.getValue();
}
}
return null;
}
public void addFilter(Predicate
© 2015 - 2025 Weber Informatics LLC | Privacy Policy