forked from apache/nifi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NIFI-13030 Adding endpoint for comparing versions of registered flows
This closes apache#8670 Signed-off-by: Peter Gyori <pgyori@apache.org>
- Loading branch information
1 parent
21f0ca4
commit 0a5be35
Showing
12 changed files
with
802 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
82 changes: 82 additions & 0 deletions
82
...work/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ClosedOpenInterval.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,82 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.nifi.web.util; | ||
|
||
/** | ||
* This implementation includes the lower boundary but does not include the higher boundary. | ||
*/ | ||
final class ClosedOpenInterval implements Interval { | ||
private final int lowerBoundary; | ||
private final int higherBoundary; | ||
|
||
/** | ||
* @param lowerBoundary Inclusive index of lower boundary | ||
* @param higherBoundary Exclusive index of higher boundary. In case of 0, the higher boundary is unspecified and the interval is open. | ||
*/ | ||
ClosedOpenInterval(final int lowerBoundary, final int higherBoundary) { | ||
if (lowerBoundary < 0) { | ||
throw new IllegalArgumentException("Lower boundary cannot be negative"); | ||
} | ||
|
||
if (higherBoundary < 0) { | ||
throw new IllegalArgumentException("Higher boundary cannot be negative"); | ||
} | ||
|
||
if (higherBoundary <= lowerBoundary && higherBoundary != 0) { | ||
throw new IllegalArgumentException( | ||
"Higher boundary cannot be lower than or equal to lower boundary except when unspecified. Higher boundary is considered unspecified when the value is set to 0" | ||
); | ||
} | ||
|
||
this.lowerBoundary = lowerBoundary; | ||
this.higherBoundary = higherBoundary; | ||
} | ||
|
||
@Override | ||
public RelativePosition getRelativePositionOf(final int otherIntervalLowerBoundary, final int otherIntervalHigherBoundary) { | ||
if (otherIntervalLowerBoundary < 0) { | ||
throw new IllegalArgumentException("Lower boundary cannot be negative"); | ||
} | ||
|
||
if (otherIntervalHigherBoundary <= 0) { | ||
// Note: as a design decision the implementation currently does not support comparison with unspecified higher boundary | ||
throw new IllegalArgumentException("Higher boundary must be positive"); | ||
} | ||
|
||
if (otherIntervalLowerBoundary >= otherIntervalHigherBoundary) { | ||
throw new IllegalArgumentException("Higher boundary must be greater than lower boundary"); | ||
} | ||
|
||
if (otherIntervalHigherBoundary <= lowerBoundary) { | ||
return RelativePosition.BEFORE; | ||
} else if (otherIntervalLowerBoundary < lowerBoundary && otherIntervalHigherBoundary > higherBoundary && !this.isEndUnspecified()) { | ||
return RelativePosition.EXCEEDS; | ||
} else if (otherIntervalLowerBoundary < lowerBoundary) { | ||
return RelativePosition.TAIL_INTERSECTS; | ||
} else if (otherIntervalHigherBoundary <= higherBoundary || this.isEndUnspecified()) { | ||
return RelativePosition.WITHIN; | ||
} else if (otherIntervalLowerBoundary < higherBoundary) { | ||
return RelativePosition.HEAD_INTERSECTS; | ||
} else { | ||
return RelativePosition.AFTER; | ||
} | ||
} | ||
|
||
private boolean isEndUnspecified() { | ||
return higherBoundary == 0; | ||
} | ||
} |
Oops, something went wrong.