Semantic ID

Utilities for working with versioned entity-bound identifiers

Лицензия

Лицензия

Категории

Категории

Ant Компиляция и сборка
Группа

Группа

com.truward.semantic
Идентификатор

Идентификатор

semantic-id
Последняя версия

Последняя версия

3.0.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

Semantic ID
Utilities for working with versioned entity-bound identifiers
Ссылка на сайт

Ссылка на сайт

https://github.com/truward/semantic-id
Система контроля версий

Система контроля версий

https://github.com/truward/semantic-id

Скачать semantic-id

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.truward.semantic/semantic-id/ -->
<dependency>
    <groupId>com.truward.semantic</groupId>
    <artifactId>semantic-id</artifactId>
    <version>3.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.truward.semantic/semantic-id/
implementation 'com.truward.semantic:semantic-id:3.0.3'
// https://jarcasting.com/artifacts/com.truward.semantic/semantic-id/
implementation ("com.truward.semantic:semantic-id:3.0.3")
'com.truward.semantic:semantic-id:jar:3.0.3'
<dependency org="com.truward.semantic" name="semantic-id" rev="3.0.3">
  <artifact name="semantic-id" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.truward.semantic', module='semantic-id', version='3.0.3')
)
libraryDependencies += "com.truward.semantic" % "semantic-id" % "3.0.3"
[com.truward.semantic/semantic-id "3.0.3"]

Зависимости

provided (1)

Идентификатор библиотеки Тип Версия
com.google.code.findbugs : jsr305 jar 1.3.9

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.8.2
org.mockito : mockito-all jar 1.9.0

Модули Проекта

Данный проект не имеет модулей.

semantic-id

Overview

This library provides support for creating semantically meaningful identifiers for use in SOA environment.

Semantically meaningful identifiers (further referred simply as 'semantic IDs) allow encoded representation of internal IDs used within the service to be translated to and from opaque string IDs that conceal the nature of internal identifiers and thus allow flexibility of internal implementation (e.g. change from internal ID to external and vice versa).

Also semantic IDs allow easier debugging, i.e. when referred from system logs, developers can easily understand what service/entity particular ID refers to.

Representation

Semantic ID includes 3 parts:

  • Encoded service name and version, e.g. 'foo1'
  • Optional, encoded entity name, e.g. 'user'
  • Encoded ID, e.g. 'q6b60'

Examples of such IDs: foo1-user-q6b60, req-9j35zf3.

Notes:

  • ID are case insensitive, i.e. semantic ID a-b-1cd should always be equivalent to A-B-1CD and vice versa.
  • Encoded ID prefixes that are used to construct an instance of codec are always required when decoding an ID. E.g. foo1-qw1 is a valid semantic ID (with service name foo and version 1), qw1 is not.
    • Note, that ID may be created without any prefixes, in this case only ID body is required for decoding

How to use

Add to dependencies in your pom.xml

<dependency>
  <groupId>com.truward.semantic</groupId>
  <artifactId>semantic-id</artifactId>
  <version>LATEST</version> <!-- Use of specific version instead of LATEST is preferred -->
</dependency>

Then in java code:

final IdCodec userIdCodec = SemanticIdCodec.forPrefixNames("foo1", "user");

//...

// create record:
final long id = database.insertNewRecord(userData);
return userIdCodec.encodeLong(id); // produces something like "foo1-user-1"


// get record
final long id = userIdCodec.decodeLong(semanticId /* e.g. "foo1-user-1" would be converted to 1, and converting of "bar-item-1" would not be possible (resulting in exception) */);
final User user = database.queryUser(id); // using internal ID
return mapToUser(user);

Версии библиотеки

Версия
3.0.3
2.0.2
2.0.1
1.0.0