Skip to content

Commit

Permalink
Merge branch 'release/1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
astrapi69 committed May 4, 2019
2 parents ac8327d + 984f174 commit db6fb14
Show file tree
Hide file tree
Showing 17 changed files with 1,317 additions and 71 deletions.
21 changes: 21 additions & 0 deletions .idea/runConfigurations/project_coverage.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/runConfigurations/time_machine_clean_deploy.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/runConfigurations/time_machine_clean_install.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions .idea/runConfigurations/time_machine_javadoc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions .idea/runConfigurations/time_machine_update_license_header.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
## Change log
----------------------

Version 1.1
-------------

ADDED:

- new methods for compute several states of an Interval created

CHANGED:

- update of parent version to 4.8
- update of threeten-extra dependency version to 1.5.0
- update of javadoc. Added graphical scenarios for better understanding the methods

Version 1
-------------

Expand Down
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License

Copyright (C) 2019 Asterios Raptis

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.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Than you can add the dependency to your dependencies:
<properties>
...
<!-- TIME-MACHINE version -->
<time-machine.version>1</time-machine.version>
<time-machine.version>1.1</time-machine.version>
...
</properties>
...
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>de.alpharogroup</groupId>
<artifactId>mvn-java-parent</artifactId>
<version>4.6</version>
<version>4.8</version>
</parent>

<artifactId>time-machine</artifactId>
<version>1</version>
<version>1.1</version>

<name>${project.artifactId}</name>

Expand Down Expand Up @@ -48,7 +48,7 @@

<properties>
<!-- THREETEN-EXTRA version -->
<threeten-extra.version>1.4</threeten-extra.version>
<threeten-extra.version>1.5.0</threeten-extra.version>
</properties>

<dependencyManagement>
Expand All @@ -58,7 +58,7 @@
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threeten-extra</artifactId>
<version>1.4</version>
<version>${threeten-extra.version}</version>
</dependency>

</dependencies>
Expand Down
39 changes: 23 additions & 16 deletions src/main/java/de/alpharogroup/time/gap/TimeGapExtensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.time.temporal.Temporal;

import lombok.NonNull;
import lombok.experimental.UtilityClass;
Expand All @@ -38,42 +39,48 @@ public class TimeGapExtensions
{

/**
* Checks if the given first {@link LocalDate} has a time gap before the given second
* {@link LocalDate} with the given {@link ChronoUnit}
* Checks if the given first {@link Temporal} has a time gap before the given second
* {@link Temporal} with the given {@link ChronoUnit}
*
* @param localDate
* the local date
* @param otherLocalDate
* the other local date
* @param <T>
* the generic type of the temporal
* @param inclusive
* the temporal from where to check. Note this is handled inclusive
* @param otherExclusive
* the other temporal. Note this is handled exclusive
* @param chronoUnit
* the chrono unit
* @return true, if the given first {@link LocalDate} has a time gap before the given second
* {@link LocalDate} with the given {@link ChronoUnit} otherwise false
*/
public boolean isBeforeTimeGap(LocalDate localDate, LocalDate otherLocalDate,
@NonNull ChronoUnit chronoUnit)
public static <T extends Temporal> boolean isBeforeTimeGap(final @NonNull T inclusive,
final @NonNull T otherExclusive, @NonNull ChronoUnit chronoUnit)
{
long between = chronoUnit.between(localDate, otherLocalDate);
long between = chronoUnit.between(inclusive, otherExclusive);
return between < -1;
}

/**
* Checks if the given first {@link LocalDate} has a time gap after the given second
* {@link LocalDate} with the given {@link ChronoUnit}
*
* @param localDate
* the local date
* @param otherLocalDate
* the other local date
* @param <T>
* the generic type of the temporal
*
* @param inclusive
* the temporal from where to check. Note this is handled inclusive
* @param otherExclusive
* the other temporal. Note this is handled exclusive
* @param chronoUnit
* the chrono unit
*
* @return true, if the given first {@link LocalDate} has a time gap after the given second
* {@link LocalDate} with the given {@link ChronoUnit} otherwise false
*/
public boolean isAfterTimeGap(LocalDate localDate, LocalDate otherLocalDate,
@NonNull ChronoUnit chronoUnit)
public static <T extends Temporal> boolean isAfterTimeGap(final @NonNull T inclusive,
final @NonNull T otherExclusive, @NonNull ChronoUnit chronoUnit)
{
long between = chronoUnit.between(localDate, otherLocalDate);
long between = chronoUnit.between(inclusive, otherExclusive);
return 1 < between;
}
}
Loading

0 comments on commit db6fb14

Please sign in to comment.