GithubHelp home page GithubHelp logo

jaeho / juri Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 69 KB

A Java serialization/deserialization library to convert Java Objects into Uri and back

License: MIT License

Kotlin 100.00%

juri's Introduction

JUri

JUri is Java/kotlin library that can be used to convert Java/Kotlin Object into their URI representation. It can also be used to convert a URI string to an equivalent Java/Kotlin object. JUri can work with arbitrary pre-existing objects that you added a little annotations.

Juri's basic concept and some method name has inspired from Google Gson.

Goals

Provide simple toUri() and fromUri() methods to convert Java/Kotlin objects to URI and vice-versa

Download

Gradle:

repositories {
	maven { url "https://jitpack.io" }
}

dependencies {
	implementation "com.github.jaeho:juri:$juriVersion"
}

How do I use Juri?

Simple Use cases will look something like this:

First, you have to declare uri model class using @JuriModel annotation.

@JuriModel(scheme = "myapp", host = "search", path = "/{category}/p/{page}")
data class SearchOptions(
        val query: String,
        val sort: String?,
        val category: String?,
        val page: Int
)

If you want Uri model convert to string, look below.

Juri.toUri(SearchOptions("paris", "price:desc", "book", 1)
// It will be "myapp://search/book/p/1?query=paris&sort=price:desc"

Or vice-versa can possible.

Juri.fromUri("myapp://search/book/p/1?query=paris&sort=price:desc", SearchOptions::class.java)
// It will be SearchOptions("paris", "price:desc", "book", 1)

If you want to mark exceptive field, you can using @JuriIgonre and also you wanto mark alternative field, you should add @JuriField. Sometimes when you needs modeling your field on fromUri() you should added function with annotation @JuriOnRestoreModel. If you need more information, check this test-code.

Licencse

The MIT License (MIT)

Copyright (c) 2020 Jaeho Choe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

juri's People

Watchers

Jaeho Choe (최재호) avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.