alexheretic / dynamics Goto Github PK
View Code? Open in Web Editor NEWJava library for handling nested dynamic data
License: Apache License 2.0
Java library for handling nested dynamic data
License: Apache License 2.0
Hi !
Is there any existing way to get boolean value without resorting to casting like this ?
Boolean b = (Boolean) dyna.dget("status.active").asObject();
Thank you !
Great library ! I wish i encountered this sooner to avoid all the headaches with splitting and loops.
I notice the current impl is to fetch and convert and dealing with possibly non existing path of map data.
Hence a feature request mutation capability for this library.
Two things quickly come to mind:
Anyway, thank you for providing this helpful library !
Hi,
It would be nice if the library would support HashSets. The following unit test illustrates my use case:
import alexh.weak.Dynamic;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
import java.util.HashSet;
import java.util.List;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
public class DynamicsAddHashSetSupport {
@Test
public void returnsTwoProducts() {
final ImmutableBiMap<String, Object> root = ImmutableBiMap.of(
"products", ImmutableList.of(new HashSet<>(asList("Product 1", "Product 2"))));
final List<String> products = Dynamic.from(root)
.get("products")
.children()
.map(product -> product.convert().toString())
.collect(toList());
assertThat(products).contains("Product 1", "Product 2");
}
}
If it isn't too much to ask - a module-info.java available would be nice. You can keep Java 8 compatibility by making a multi-release jar.
Hi,
It is a very nice job first of all, and cannot find any equivalent so far.
However, would it be possible to add the visitor pattern out of the box to the library please ?
I would be glad to provide a Pull Request for that.
Cheers.
Hello again from a long time fan !
Does dynamics currently support accessing values by array or list index ?
Map<String, Object> data = mapBuilder()
.put("hello", "world")
.put("list", Lists.newArrayList(mapBuilder()
.put("nestedHello", "nestedWorld")
.build()))
.build();
Dynamic dyna = Dynamic.from(data);
assertEquals("world", dyna.get("hello").asString());
// both fails
assertEquals("nestedWorld", dyna.dget("list[0].nestedHello").asString());
assertEquals("nestedWorld", dyna.dget("list.0.nestedHello").asString());
Thank you !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.