Package net.jcores.jre.utils.map

Examples of net.jcores.jre.utils.map.Compound


    /** */
    @SuppressWarnings({ "boxing", "unchecked" })
    @Test
    public void testBasic() {
        Compound c1 = $("a", "b", "c", "d").compound();
        Compound c2 = $("a", "b", "c", "d").compound();
       
        Assert.assertEquals("b", c1.s("a"));
        Assert.assertEquals("b", c2.s("a"));
        Assert.assertEquals("nope", c1.get("b", "nope"));
       
        Compound c3 = $("a", 2.0, "b", 4.0).debug().compound();
        Assert.assertEquals(2.0, c3.d("a"), 0.01);
        Assert.assertEquals(4.0, c3.get("b", Double.class), 0.01);
    }
View Full Code Here


       
        map(new F1<String, Void>() {
            @Override
            public Void f(String x) {
                final String[] delims = delimeters.length > 0 ? delimeters : new String[] {":=", "=", ":"};
                final Compound best = CoreKeeper.$("token", "", "dist", ""+Integer.MAX_VALUE).compound();
               
                // Find best delimeter
                for (String string : delims) { 
                    final int index = x.indexOf(string);
                    if(index >= 0 && index < best.i("dist")) {
                        best.put("dist", index);
                        best.put("token", string);
                    }
                }
               
                final int dist = best.i("dist");
                if(dist < 0) return null;
               
                final String[] split = x.split(best.s("token"));
                rval.put(split[0], split[1]);
               
                return null;
            }
        });
View Full Code Here

    /**
     * @param args
     */
    @SuppressWarnings({ "unchecked", "boxing" })
    public static void main(String[] args) {
        Compound c1 = $("hello", new Long(12345678)).compound();
        Compound c2 = $("hel".concat("lo"), new Long(new Long(12345670) + 8)).compound();

        System.out.println(c1.equals(c2));
        System.out.println(c1);
        System.out.println(c2);

View Full Code Here

TOP

Related Classes of net.jcores.jre.utils.map.Compound

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.