GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Identifiers/identifiers-java: Java implementation of the identifiers spec

BranchesTags
Open more actions menu

Latest commit

 

History

65 Commits
65 Commits

Folders and files

NameName
Last commit message
Last commit date
spec @ 911cff5
spec @ 911cff5
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

Java implementation of Identifiers spec

Build Status Coverage Status Maven Central

About Identifiers

Identifiers are self-describing strings of data that can be decoded into semantically-meaningful values. Identifiers can define basic data types, like numbers and bytes. They can also describe values like geolocations, date-times and uuids.

Try out an online version at identifiers.io

Installing the Identifiers Library

Maven Central coordinates:

<dependency>
   <groupId>io.identifiers</groupId>
   <artifactId>identifiers</artifactId>
   <version>0.1.0</version>
</dependency>

Usage

Identifiers comes with a set of static factory methods to encode Identifier instances and decode these encoded strings.

import io.identifiers.Factory;
import io.identifiers.Identifier;

Identifier<String> stringId = Factory.forString.create("a string value");

String encodedDataId = stringId.toDataString(); // smaller, good for data storage and transmission
String encodedHumanId = stringId.toHumanString(); // good for human interaction like emails and URLs

Identifier<String> decodedStringId = Factory.decodeFromString(encodedDataId);
// also decodes human strings
decodedStringId = Factory.decodeFromString(encodedHumanId);

Factories are provided for the following identifier types:

  • string
  • boolean
  • integer (32-bit signed ints)
  • float (64-bit signed decimals)
  • long (64-bit signed ints)
  • bytes
  • UUID (any version)
  • Datetime (Java Instant type)
  • Geo (decimal latitude / longitude)

Structured Identifiers

All the factory methods come with List and Map factory methods to create typed structured identifiers.

import io.identifiers.Factory;
import io.identifiers.Identifier;

// For datetime IDs
import java.time.Instant;

// List identifiers are declared as generic Lists.
ListIdentifier<Boolean> booleanListId = Factory.forString.createList(true, false);

Map<String, Instant>> dates = new HashMap<>();
dates.put("before", Instant.parse("2010-01-01"));
dates.put("after", Instant.parse("2011-12-31"));

// Map identifiers are declared as generic Maps with String keys.
MapIdentifier<Instant> Factory.forDatetime.createMap(dates);

Composite Identifiers

Different types of identifiers can be combined into a composite identifier. They can be composed as either Lists or Maps.

import io.identifiers.Factory;
import io.identifiers.Identifier;

ListIdentifier<Identifier<?>> compositeListId = Factory.forComposite.createList(
	Factory.forString.create("s1"),
	Factory.forFloat.createList(22.1, 6543.87),
	Factory.forBoolean.createMap(java.util.Collections.singletonMap("flag", true)));

About

Java implementation of the identifiers spec

Resources

Readme
MIT license
Activity
Custom properties

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.