GithubHelp home page GithubHelp logo

masaru-b-cl / baseunits Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dai0304/baseunits

0.0 1.0 0.0 2.45 MB

基礎的な単位(時間や金額等)にまつわるドメインモデル群を含むクラスライブラリ

Java 99.92% Groovy 0.08%

baseunits's Introduction

BaseUnits Library

基礎的な単位にまつわるドメインモデル群を含むクラスライブラリ。現在は「時間」と「金額」を主に扱っているが、 必要に応じて要望があれば「重さ」「長さ」などのドメインも取り扱っていく。

require Java 8 or later.

How to use?

If you're using Maven, add this to your pom.xml under the and section:

v2.16 or later

  • repositories: jcenter
  • groupId: jp.xet
  • artifactId: baseunits

see https://bintray.com/dai0304/maven/baseunits

v2.0〜2.15

Example

// 日付の仕様。ある日付がその仕様を満たすかどうか、とかチェックできる
DateSpecification mlkBirthday = DateSpecification.fixed(1, 15);
// こういう風に。ここではマーチンルーサーキングの誕生日。
CalendarDate jan15_2005 = CalendarDate.from(2005, 1, 15);
assertThat(mlkBirthday.isSatisfiedBy(jan15_2005), is(true));
    
// 2005年(期間)の中で、キング牧師の誕生日を引っ張って来る(仕様を満たす日を探す)
CalendarDate mlk2005 = mlkBirthday.firstOccurrenceIn(CalendarInterval.year(2005));
assertThat(mlk2005, is(jan15_2005));
    
// 誕生日と逝去日の期間をつくって、その範囲で使用を満たす日付を順次取得するイテレータ
CalendarInterval mlkLifetime = CalendarInterval.inclusive(1929, 1, 15, 1968, 4, 4);
Iterator<CalendarDate> mlkBirthdays = mlkBirthday.iterateOver(mlkLifetime);
assertThat(mlkBirthdays.next(), is(CalendarDate.from(1929, 1, 15)));
assertThat(mlkBirthdays.next(), is(CalendarDate.from(1930, 1, 15)));
    
// っていうか、そもそもキング牧師って何日間生きたの?
assertThat(mlkLifetime.length(), is(Duration.days(14325)));

License

Distributed under the Apache License v2.0. See the file copyright/LICENSE.txt.

baseunits's People

Contributors

dai0304 avatar dependabot-preview[bot] avatar solum13 avatar

Watchers

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.