Skip to content

Zentae/content-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

content-library

Lightweight library that helps content management.

How to include content-library in your project.

<dependency>
    <groupId>io.zentae.contentlibrary</groupId>
    <artifactId>content-library</artifactId>
    <version>2.5.0</version>
    <scope>compile</scope>
</dependency>

Extensions

In the following steps I will show how to setup an Extension.
You need to provide what type of data you want to serialize or deserialize.

Json

Extension<String> extension = new JsonExtension<>();

Yaml

Extension<String> extension = new YamlExtension<>();

Serialization

For the serialization you'll need to provide a file where the data will be stored
as well as the data that needs to be stored.

File file = new File("some file path");
extension.serialize(file, "Some data");

Deserialisation

For the deserialization you only need to provide the file where the stored data is.

String deserializedString = extension.deserialize(file, String.class);

Directories

Directories is a very useful class that will be subject to evolution.
This class extends directly from java.File but adds some useful methods.

Get files

This method returns all the files within this directory.

    Directory directory = new Directory("some directory path");
    directory.getFiles().forEach(file ->
        System.out.println(file.getAbsolutePath()));

Copy files

This methods allows you to copy several files into the following directory.

    File[] files = new File[5];
    Directory directory = new Directory("some directory path");
    directory.copyFiles(files);

Wrappers

Wrappers are indeed very useful when it comes to context or to wrap regardless the type of the data.
They can store whatever object regardless their type. Good for generic stuff.

Generic wrapper

This wrapper is useful for single generic data wrapping.

# The data that needs to be stored.
GamePlayer gamePlayer = null;
# Init object wrapper.
GenericWrapper<GamePlayer> genericWrapper = new GenericWrapper();
# Set the single generic parameter.
genericWrapper.setParameter(gamePlayer);
# Get the stored parameter.
GamePlayer storedGamePlayer = genericWrapper.getParameter();

Map wrapper

This map is also generic it can store objects regardless their type.

# The data that needs to be stored.
Object data = null;
# Init map wrapper.
MapWrapper mapWrapper = new MapWrapper();
# Put the data into the map.
mapWrapper.putParameter("key", data);
# Get the said data.
Object storedData = mapWrapper.getParameter("key", Object.class);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages