AbacusUtil Docs | Download | Javadoc | FAQ | Community

(Give me a lever long enough and a fulcrum on which to place it, and I shall move the world --- Archimedes)

AbacusUtil is a general programming library/framework in Java. It's simple, powerful and easy to use with concise APIs. To provide the unmatchable programming experiences and high performance solutions, we think the API design and implementation again and again. First, let's take a quick look:

  • concat/join/split...
  • char[] a = { 'a', 'b', 'c' };
    char[] b = { 'd', 'e', 'f' };
    char[] c = N.concat(a, b);
    
    String str = N.join(c);
    N.println(str);
    
    char[] d = N.string2Array(char[].class, str);
    assertTrue(N.equals(c, d));
    
    int[] e = Array.range(0, 6);
    N.println(e);
    

  • Lambda/Stream/Functional programming...
  • Stream.of("abc", "123", "ab123").filter(str -> str.startsWith("a")).forEach(N::println);
    // abc
    // ab123
    
    List<String> strs = N.asList("Hello Java", "I LIKE Functional Programming");
    
    // average length of words in the strings.
    Stream.of(strs).flatMap2(str -> str.split(" ")).collect(Collectors.averagingDouble(str -> str.length()));
    // 5.833333333333333
    
    // count the characters in upper case.
    Stream.of(strs).flatMapToChar(str -> Stream.from(str.toCharArray())).filter(ch -> Character.isUpperCase(ch)).count();
    // 9
    

  • SQLBuilder/Executor...
  • // Insert
    String sql_insert = NE.insert("gui", "firstName", "lastName", "lastUpdateTime", "createTime").into("account").sql();
    // Or: String sql_insert = NE.insertInto(Account.class, N.asSet("id").sql();
    // sql: INSERT INTO account (gui, first_name, last_name, last_update_time, create_time) VALUES (:gui, :firstName, :lastName, :lastUpdateTime, :createTime)
    long id = sqlExecutor.insert(sql_insert, account);
    
    // Read
    String sql_getById = NE.select("id", "gui", "firstName", "lastName").from("account").where("id = :id").sql();
    // sql: SELECT id AS "id", gui AS "gui", first_name AS "firstName", last_name AS "lastName" FROM account WHERE id = :id
    Account dbAccount = sqlExecutor.queryForEntity(Account.class, sql_getById, id);
    
    //Update
    dbAccount.setFirstName("newFirstName");
    String sql_updateFirstNameById = NE.update("account").set("firstName").where("id = :id").sql();
    // sql: UPDATE account SET first_name = :firstName WHERE id = :id
    sqlExecutor.update(sql_updateFirstNameById, dbAccount);
    
    // Delete
    String sql_deleteByFirstName = NE.deleteFrom("account").where("firstName = :firstName").sql();
    // sql: DELETE FROM account WHERE first_name = :firstName
    sqlExecutor.update(sql_deleteByFirstName, dbAccount);
    

  • XML/JSONParser...
  • String xml = xmlParser.serialize(account);
    // XML: <account><id>0</id><gui>9d436ceb-a85f-40b2-86aa-20625a7d68b0</gui><firstName>3e37c0e9-96c3-40f3-99a2-bde3a384956c</firstName><lastName>38d19d46-6701-4f36-a112-924376154280</lastName><status>0</status><lastUpdateTime>1437609384633</lastUpdateTime><createTime>1437609384633</createTime></account>
    Account account2 = xmlParser.deserialize(Account.class, xml);
    
    String json = jsonParser.serialize(account);
    // JSON: {id:0, gui:"edf40293-2e38-4c51-885b-e74638f7b7d2", firstName:"f063cb51-75f6-4810-a8e6-8e55d2db440f", lastName:"70e6f942-8400-4b84-9f17-02594d99ee2c", status:0, lastUpdateTime:1437609422217, createTime:1437609422217}
    account2 = jsonParser.deserialize(Account.class, json);
    

    Here are the features supported in AbacusUtil:

    "SIMPLE IS BEAUTIFUL" - We always keep it in mind to build the most efficient tools to improve the productivity and quality of software development.

    Here is a presentation from Joshua Bloch: How to Design a Good API and Why it Matters, recommended to everyone.

    Leaving a comment/question at AbacusUtil Google Group...