Skip to content

Latest commit

 

History

History
100 lines (68 loc) · 2.79 KB

README.adoc

File metadata and controls

100 lines (68 loc) · 2.79 KB

GitHub Readme Stats

java 8+ 4c7e9f EasyByte groupId EasyByte

What is EasyByte?

EasyByte is a ByteBuffer operate library. Simple,easy to use

Why EasyByte?

  • JDK’s native ByteBuffer that after allocate can’t update capacity, EasyByte can create a dynamic ByteBuffer.

  • Strings are something we need to add frequently but ByteBuffer only support byte array.

  • If you have a container like List,Map,must design a format policy,EasyByte can easy to use.

  • Annoyed by the read and write mode of the native ByteBuffer. ByteBuffer created from EasyByte is read-write separated.

How to use?

Maven

<dependency>
    <groupId>io.github.gongxuanzhang</groupId>
    <artifactId>easyByte-core</artifactId>
    <version>0.0.1</version>
</dependency>

Gradle

kotlin:
implementation("io.github.gongxuanzhang:easyByte-core:0.0.1")

groovy:
implementation group: 'io.github.gongxuanzhang', name: 'easyByte-core', version: '0.0.1'

Some API

import org.gongxuanzhang.easybyte.core.DynamicByteBuffer;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class HowToUse {

    public static void main(String[] args) {
        DynamicByteBuffer allocate = DynamicByteBuffer.allocate();
        allocate.appendString("hello world");
        allocate.appendCollection(helloList());
        allocate.appendMap(helloMap());

        String helloWorld = allocate.getString();
        List<String> list = allocate.getCollection(String.class);
        Map<String, String> map = allocate.getMap(String.class, String.class);
        System.out.println(helloWorld); //  hello world
        System.out.println(list);    //  [hello, world]
        System.out.println(map);   //  {hello=world}
    }

    private static List<String> helloList() {
        return Arrays.asList("hello", "world");
    }

    private static Map<String, String> helloMap() {
        return Collections.singletonMap("hello", "world");
    }
}

Contributing

If you like EasyByte, star it please.

Please feel free to submit an issue.

Fork and PR are always welcomed.