Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6566 customer retention logic refactoring
- Loading branch information
Showing
7 changed files
with
181 additions
and
120 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
backend/de.metas.contracts/src/main/java/de/metas/contracts/CustomerRetentionId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package de.metas.contracts; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
import de.metas.util.Check; | ||
import de.metas.util.lang.RepoIdAware; | ||
|
||
/* | ||
* #%L | ||
* de.metas.contracts | ||
* %% | ||
* Copyright (C) 2020 metas GmbH | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 2 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-2.0.html>. | ||
* #L% | ||
*/ | ||
|
||
public class CustomerRetentionId implements RepoIdAware | ||
{ | ||
int repoId; | ||
|
||
@JsonCreator | ||
public static CustomerRetentionId ofRepoId(final int repoId) | ||
{ | ||
return new CustomerRetentionId(repoId); | ||
} | ||
|
||
public static CustomerRetentionId ofRepoIdOrNull(final int repoId) | ||
{ | ||
return repoId > 0 ? ofRepoId(repoId) : null; | ||
} | ||
|
||
private CustomerRetentionId(final int repoId) | ||
{ | ||
this.repoId = Check.assumeGreaterThanZero(repoId, "repoId"); | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public int getRepoId() | ||
{ | ||
return repoId; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.