Giter VIP home page Giter VIP logo

dynamics's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dynamics's Issues

Support for getting boolean value

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 !

Feature Request: Mutating the dynamic data

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:

  1. Adding a node by path
  2. Removing a node by path

Anyway, thank you for providing this helpful library !

Add support for HashSets

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");
    }
}

Add the Visitor Pattern

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.

Support from getting value from a List or an array

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 !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.