Skip to content

Conversation

alexander-yevsyukov
Copy link
Contributor

@alexander-yevsyukov alexander-yevsyukov commented Nov 12, 2020

This PR:

Adds localDate() and localDateTime() methods to the WithTime interface

... thus saving on efforts required for obtaining popular temporals from events or commands.

Previously, only instant() was exposed which required calling LocalDate.from(TemporalAccessor) or LocalDateTime.from(TemporalAccessor). This in turn, caused Error Prone warning because not all TemporalAccessors provide date information (causing DateTimeException).

New methods address removes the whole hassle because Instant does have both date and time information, so the exception would never occur.

Bumps base and config

  • Eliminating calls to Hamcrest.
  • Addressing new ErrorProne warnings.

Refactors MatchCriterion

I encountered Java compiler error telling “unable to instantiate” for declaration of MatchCriterion.PROHIBITED_EXCEPTION member. So, I extracted common bits and non-trivial message composition required for PROHIBITED_EXCEPTION, and the compiler swallowed it.

Makes SignatureMismatch.create() return Optional<>

... as this is the only case we use.

Makes MethodSignature return only one AccessModifier

We use this only for recommending (via warning) correct modifiers during compile time.
It would be strange to recommend two or more things because it would cause a question, “Which one to use when?”
The previous signature was:

protected ImmutableSet<AccessModifier> modifiers(); 

Now it's:

protected AccessModifier modifier();

Encapsulate allowed types of a MethodSignature

Before:

public ImmutableSet<? extends ParameterSpec<EventEnvelope>> paramSpecs() { ... }

After:

public AllowedParams<EventEnvelope> paramSpecs() { ... }

Encapsulates return types of method signatures

Previously, MethodSignature.returnTypes() returned ImmutableSet<TypeToken<?>>.
Now it's just ReturnTypes, and the class encapsulates the checking against a Method.

@alexander-yevsyukov alexander-yevsyukov self-assigned this Nov 12, 2020
@codecov
Copy link

codecov bot commented Nov 13, 2020

Codecov Report

Merging #1319 (1e2dea5) into master (4515237) will decrease coverage by 0.07%.
The diff coverage is 89.47%.

@@             Coverage Diff              @@
##             master    #1319      +/-   ##
============================================
- Coverage     91.06%   90.98%   -0.08%     
- Complexity     4748     4765      +17     
============================================
  Files           609      612       +3     
  Lines         15101    15130      +29     
  Branches        854      856       +2     
============================================
+ Hits          13751    13766      +15     
- Misses         1080     1097      +17     
+ Partials        270      267       -3     

@alexander-yevsyukov alexander-yevsyukov changed the title Id improvements Improve MethodSignature and WithTyme Nov 16, 2020
@alexander-yevsyukov alexander-yevsyukov marked this pull request as ready for review November 16, 2020 19:40
@armiol armiol changed the title Improve MethodSignature and WithTyme Improve MethodSignature and WithTime Nov 17, 2020
Copy link
Contributor

@armiol armiol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexander-yevsyukov LGTM in general. I really liked the shortcut types for the numerous Immutable... collections.

Please see my comments though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants