uri-query-builder

Spring Boot Starter Parent

License

License

GroupId

GroupId

io.eyolas.http
ArtifactId

ArtifactId

uri-query-builder
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

uri-query-builder
Spring Boot Starter Parent
Project Organization

Project Organization

Pivotal Software, Inc.
Source Code Management

Source Code Management

https://github.com/eyolas/uri-query-builder

Download uri-query-builder

How to add to project

<!-- https://jarcasting.com/artifacts/io.eyolas.http/uri-query-builder/ -->
<dependency>
    <groupId>io.eyolas.http</groupId>
    <artifactId>uri-query-builder</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.eyolas.http/uri-query-builder/
implementation 'io.eyolas.http:uri-query-builder:0.0.1'
// https://jarcasting.com/artifacts/io.eyolas.http/uri-query-builder/
implementation ("io.eyolas.http:uri-query-builder:0.0.1")
'io.eyolas.http:uri-query-builder:jar:0.0.1'
<dependency org="io.eyolas.http" name="uri-query-builder" rev="0.0.1">
  <artifact name="uri-query-builder" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.eyolas.http', module='uri-query-builder', version='0.0.1')
)
libraryDependencies += "io.eyolas.http" % "uri-query-builder" % "0.0.1"
[io.eyolas.http/uri-query-builder "0.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.3.2

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 1.1.7.RELEASE

Project Modules

There are no modules declared in this project.

Build Status

Uri query builder

Helper for build the query part of uri

Usage

Instantiate UriQueryBuilder and add params. Use method build for build the String.

For each param :

  • if the key is null or empty, builder skip the param
  • value:
    • if value is null, set "" to value
    • if value is an instance of QueryList or QueryMap, builder loop on collection
    • else String.valueof

Simple example

UriQueryBuilder builder = new UriQueryBuilder().param("test", "simpleTest");
Assert.assertEquals("?test=simpleTest", builder.build());

QueryList

QueryList is an representation of query list.

QueryList has 4 type :

  • NONE: No bracket and no index. ex : ?club=asse&club=psg&club=om
  • BRACKET: With bracket. ex: ?club[]=asse&club[]=psg&club[]=om
  • INDEXED: Indexed. ex: ?club[0]=asse&club[1]=psg&club[2]=om
  • SEMICOLON: ex: ?club=asse;psg;om

example type INDEXED:

List<String> l = Arrays.asList("asse", "psg", "om");
QueryArrayList<String> list = new QueryArrayList<>(l);
list.setQueryListType(QueryListType.INDEXED);
UriQueryBuilder builder = new UriQueryBuilder()
        .param("club", list);
Assert.assertEquals("?club[0]=asse&club[1]=psg&club[2]=om", builder.build());

QueryMap

QueryMap is an representation of query map.

example:

QueryLinkedHashMap<String, String> map = new QueryLinkedHashMap<>();
map.put("java", "java");
map.put("js", "javascript");
map.put("rb", "ruby");
map.put("coffee", "coffeescript");
UriQueryBuilder builder = new UriQueryBuilder()
        .param("language", map);

Assert.assertEquals("?language[java]=java&language[js]=javascript&language[rb]=ruby&language[coffee]=coffeescript", builder.build());

License

The MIT License

Versions

Version
0.0.1